Highcharts Charting Library

12.6.0 · active · verified Sun Apr 19

Highcharts is a robust, pure JavaScript/TypeScript charting framework engineered for creating highly responsive, interactive, and accessible charts across web and mobile platforms. The current stable version is 12.6.0. It offers a comprehensive suite encompassing core charting functionalities, specialized financial charts (Highcharts Stock), geographical maps (Highcharts Maps), and project management Gantt charts. Key differentiators include its lightweight core library, which is under 100kB gzipped with zero external dependencies, comprehensive ES6 module support enabling efficient tree-shaking for minimal bundle sizes, extensive customizability through code or CSS, and built-in accessibility features such as keyboard navigation and screen reader support. It seamlessly integrates with popular frontend frameworks and any backend stack, primarily focusing on client-side rendering with bundlers, while advising the use of `highcharts-export-server` for static server-side chart generation.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart initializes Highcharts with two commonly used modules (exporting for data/image export and series-label for better readability). It then renders a basic line chart displaying temperature trends, demonstrating a typical setup for a modern web application using TypeScript and Highcharts.

import Highcharts from 'highcharts';
import HighchartsExporting from 'highcharts/modules/exporting';
import HighchartsSeriesLabel from 'highcharts/modules/series-label';

// Initialize modules by passing the Highcharts instance to them
// This attaches their functionality to the core Highcharts object.
HighchartsExporting(Highcharts);
HighchartsSeriesLabel(Highcharts);

// Create a container element where the chart will be rendered
document.body.innerHTML = '<div id="container" style="width: 100%; height: 400px; margin-top: 20px;"></div>';

// Define the chart configuration using TypeScript types for clarity and strong typing
const chartOptions: Highcharts.Options = {
    chart: {
        type: 'line',
        renderTo: 'container',
        zoomType: 'x' // Enable zooming along the X-axis
    },
    title: {
        text: 'Annual Temperature Trends',
        align: 'left'
    },
    subtitle: {
        text: 'Source: World Weather Data',
        align: 'left'
    },
    xAxis: {
        categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
        title: { text: 'Month' }
    },
    yAxis: {
        title: {
            text: 'Temperature (°C)',
        }
    },
    tooltip: {
        valueSuffix: '°C' // Add unit to tooltip values
    },
    plotOptions: {
        series: {
            label: {
                connectorAllowed: false // Disable connector lines for series labels
            },
            pointStart: 0 // Start points from category index 0
        }
    },
    series: [
        {
            name: 'Tokyo',
            data: [7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6]
        } as Highcharts.SeriesLineOptions, // Type assertion for specific series type
        {
            name: 'New York',
            data: [-0.2, 0.8, 5.7, 11.3, 17.0, 22.0, 24.8, 24.1, 20.1, 14.1, 8.6, 2.5]
        } as Highcharts.SeriesLineOptions
    ],
    responsive: {
        rules: [{
            condition: {
                maxWidth: 500
            },
            chartOptions: {
                legend: {
                    layout: 'horizontal',
                    align: 'center',
                    verticalAlign: 'bottom'
                }
            }
        }]
    },
    credits: {
        enabled: false // Commonly disabled for cleaner integration in applications
    },
    exporting: {
        enabled: true // Enables the download CSV, PNG, PDF options provided by the module
    }
};

// Create the chart instance by passing the configuration options
Highcharts.chart(chartOptions);

view raw JSON →