AG Charts TypeScript Types

13.2.1 · active · verified Sun Apr 19

AG Charts is a high-performance, canvas-based charting library for JavaScript and TypeScript, offering extensive customizability and no third-party dependencies for its core functionality. It integrates seamlessly with popular frameworks like React, Angular, and Vue. The `ag-charts-types` package, currently at stable version 13.2.1, provides comprehensive TypeScript type definitions, enabling type-safe development for AG Charts applications. The library maintains a frequent release cadence, delivering continuous improvements and new features across minor and patch versions, with significant breaking changes typically reserved for major version bumps. Its key differentiators include exceptional rendering performance, a highly flexible API for detailed customization, and a robust feature set suitable for enterprise data visualization.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to create a basic line chart using AG Charts, displaying sales and profit data over several years with custom styling and axes configuration.

import * as AgCharts from 'ag-charts-community';
import { AgChartOptions } from 'ag-charts-community';

const data = [
  { year: '2020', sales: 1500, profit: 800 },
  { year: '2021', sales: 1800, profit: 950 },
  { year: '2022', sales: 2200, profit: 1100 },
  { year: '2023', sales: 2500, profit: 1300 },
];

const options: AgChartOptions = {
  container: document.getElementById('myChart') ?? undefined,
  data: data,
  title: {
    text: 'Sales and Profit by Year',
  },
  subtitle: {
    text: 'Example using AG Charts',
  },
  series: [
    {
      type: 'line',
      xKey: 'year',
      yKey: 'sales',
      yName: 'Sales',
      stroke: '#007bff',
      marker: {
        enabled: true,
      },
    },
    {
      type: 'line',
      xKey: 'year',
      yKey: 'profit',
      yName: 'Profit',
      stroke: '#28a745',
      marker: {
        enabled: true,
      },
    },
  ],
  axes: [
    {
      type: 'category',
      position: 'bottom',
      title: {
        text: 'Year',
      },
    },
    {
      type: 'number',
      position: 'left',
      title: {
        text: 'Amount',
      },
    },
  ],
};

// Ensure the container exists in your HTML: <div id="myChart" style="height: 400px; width: 600px;"></div>
AgCharts.create(options);

view raw JSON →