AG Charts Community Edition

13.2.1 · active · verified Sun Apr 19

AG Charts is a high-performance, canvas-based JavaScript charting library designed for enterprise applications, offering a comprehensive suite of chart types including line, bar, area, scatter, pie, and many more. It's built without external third-party dependencies for its core functionality, emphasizing performance and customization. The library supports modern web development with full TypeScript types and dedicated framework wrappers for React, Angular, and Vue. Currently, the stable version is 13.2.1, with a rapid release cadence that includes frequent patch and minor updates, and periodic major version releases introducing significant enhancements and breaking changes. Key differentiators include its superior rendering performance, deep customization capabilities via a flexible options API, and a robust feature set suitable for complex data visualizations.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart initializes a combined line and bar chart displaying monthly weather data (temperature and rainfall) using `ag-charts-community`. It demonstrates basic chart configuration with data, series, axes, and titles, and dynamically creates a DOM container if one doesn't exist.

import * as agCharts from 'ag-charts-community';

const options: agCharts.AgChartOptions = {
    container: document.getElementById('myChart'),
    data: [
        { month: 'Jan', avgTemp: 2, rainfall: 40 },
        { month: 'Feb', avgTemp: 2.3, rainfall: 45 },
        { month: 'Mar', avgTemp: 4.8, rainfall: 50 },
        { month: 'Apr', avgTemp: 7.6, rainfall: 55 },
        { month: 'May', avgTemp: 10.7, rainfall: 60 },
        { month: 'Jun', avgTemp: 13.9, rainfall: 65 },
        { month: 'Jul', avgTemp: 16.2, rainfall: 70 },
        { month: 'Aug', avgTemp: 15.9, rainfall: 75 },
        { month: 'Sep', avgTemp: 13.3, rainfall: 80 },
        { month: 'Oct', avgTemp: 9.3, rainfall: 70 },
        { month: 'Nov', avgTemp: 5.7, rainfall: 60 },
        { month: 'Dec', avgTemp: 3.1, rainfall: 50 }
    ],
    series: [
        {
            type: 'line',
            xKey: 'month',
            yKey: 'avgTemp',
            yName: 'Avg Temperature (°C)'
        },
        {
            type: 'bar',
            xKey: 'month',
            yKey: 'rainfall',
            yName: 'Rainfall (mm)'
        }
    ],
    axes: [
        {
            type: 'category',
            position: 'bottom',
            title: { text: 'Month' }
        },
        {
            type: 'number',
            position: 'left',
            keys: ['avgTemp'],
            title: { text: 'Temperature (°C)' }
        },
        {
            type: 'number',
            position: 'right',
            keys: ['rainfall'],
            title: { text: 'Rainfall (mm)' },
            grid: { enabled: false }
        }
    ],
    title: {
        text: 'Monthly Weather Data'
    },
    subtitle: {
        text: 'London, 2023'
    }
};

// Ensure a container element exists for the chart
if (!document.getElementById('myChart')) {
    const chartDiv = document.createElement('div');
    chartDiv.id = 'myChart';
    chartDiv.style.height = '400px';
    chartDiv.style.width = '600px';
    document.body.appendChild(chartDiv);
}

agCharts.AgCharts.create(options);

view raw JSON →