Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/highcharts/highcharts/llms.txt

Use this file to discover all available pages before exploring further.

Overview

Highcharts provides official wrappers and components for popular JavaScript frameworks, making it easy to create reactive, component-based charts.

React Integration

Use the official @highcharts/react wrapper for seamless React integration.

Installation

npm install highcharts @highcharts/react

Basic Example

import React from 'react';
import { Chart, Series, Title } from '@highcharts/react';

export default function ChartComponent() {
    return (
        <div>
            <Chart>
                <Title>Line chart</Title>
                <Series type="line" data={[1, 2, 3]} />
            </Chart>
        </div>
    );
}

React Hooks Example

import React, { useRef, useEffect } from 'react';
import Highcharts from 'highcharts';
import HighchartsReact from 'highcharts-react-official';

const ChartWithRef = () => {
    const chartComponentRef = useRef(null);

    useEffect(() => {
        // Access the chart instance
        const chart = chartComponentRef.current?.chart;
        
        if (chart) {
            // Perform operations on the chart
            console.log('Chart instance:', chart);
            
            // Example: Add a point after 2 seconds
            setTimeout(() => {
                chart.series[0].addPoint(Math.random() * 10);
            }, 2000);
        }
    }, []);

    const options = {
        title: { text: 'Chart with Ref' },
        series: [{ type: 'line', data: [1, 2, 3, 4, 5] }]
    };

    return (
        <HighchartsReact
            highcharts={Highcharts}
            options={options}
            ref={chartComponentRef}
        />
    );
};

export default ChartWithRef;
Use refs to access the chart instance directly and call Highcharts API methods.

Vue Integration

Integrate Highcharts with Vue 3 using the official wrapper.

Installation

npm install highcharts highcharts-vue

Basic Example

<template>
  <div>
    <highcharts :options="chartOptions"></highcharts>
  </div>
</template>

<script setup>
import { ref } from 'vue';
import { Chart } from 'highcharts-vue';

const chartOptions = ref({
  title: {
    text: 'My Vue Chart'
  },
  series: [{
    type: 'line',
    data: [1, 2, 3, 4, 5]
  }]
});
</script>

Global Registration

// main.js
import { createApp } from 'vue';
import App from './App.vue';
import Highcharts from 'highcharts';
import HighchartsVue from 'highcharts-vue';

const app = createApp(App);

app.use(HighchartsVue, { highcharts: Highcharts });
app.mount('#app');

Angular Integration

Use highcharts-angular for Angular applications.

Installation

npm install highcharts highcharts-angular

Module Setup

// app.module.ts
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { HighchartsChartModule } from 'highcharts-angular';
import { AppComponent } from './app.component';

@NgModule({
  declarations: [AppComponent],
  imports: [
    BrowserModule,
    HighchartsChartModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Component Example

import { Component } from '@angular/core';
import * as Highcharts from 'highcharts';

@Component({
  selector: 'app-chart',
  template: `
    <highcharts-chart
      [Highcharts]="Highcharts"
      [options]="chartOptions"
      style="width: 100%; height: 400px; display: block;"
    ></highcharts-chart>
  `
})
export class ChartComponent {
  Highcharts: typeof Highcharts = Highcharts;
  
  chartOptions: Highcharts.Options = {
    title: {
      text: 'My Angular Chart'
    },
    series: [{
      type: 'line',
      data: [1, 2, 3, 4, 5]
    }]
  };
}

Vanilla JavaScript

For projects without a framework, use Highcharts directly.

CDN Usage

<!DOCTYPE html>
<html>
<head>
    <script src="https://code.highcharts.com/highcharts.js"></script>
</head>
<body>
    <div id="container"></div>
    
    <script>
        Highcharts.chart('container', {
            title: {
                text: 'My Chart'
            },
            series: [{
                type: 'line',
                data: [1, 2, 3, 4, 5]
            }]
        });
    </script>
</body>
</html>

NPM/ES Modules

import Highcharts from 'highcharts';

Highcharts.chart('container', {
    title: {
        text: 'My Chart'
    },
    series: [{
        type: 'line',
        data: [1, 2, 3, 4, 5]
    }]
});

TypeScript Support

Highcharts provides comprehensive TypeScript definitions.
import * as Highcharts from 'highcharts';

const options: Highcharts.Options = {
    chart: {
        type: 'line'
    },
    title: {
        text: 'TypeScript Chart'
    },
    series: [{
        type: 'line',
        data: [1, 2, 3, 4, 5]
    }]
};

const chart: Highcharts.Chart = Highcharts.chart('container', options);

// Type-safe API calls
chart.series[0].addPoint(6);
chart.setTitle({ text: 'Updated Title' });
TypeScript provides autocomplete and type checking for all Highcharts options and API methods.

Loading Additional Modules

import Highcharts from 'highcharts';
import HighchartsReact from 'highcharts-react-official';
import highcharts3d from 'highcharts/highcharts-3d';
import exporting from 'highcharts/modules/exporting';

// Initialize modules
highcharts3d(Highcharts);
exporting(Highcharts);

const ChartComponent = () => {
    const options = {
        chart: {
            type: 'column',
            options3d: {
                enabled: true,
                alpha: 15,
                beta: 15
            }
        },
        series: [{ data: [1, 2, 3, 4, 5] }]
    };

    return <HighchartsReact highcharts={Highcharts} options={options} />;
};
import Highcharts from 'highcharts';
import highcharts3d from 'highcharts/highcharts-3d';
import exporting from 'highcharts/modules/exporting';

// Initialize modules
highcharts3d(Highcharts);
exporting(Highcharts);

export default {
    data() {
        return {
            chartOptions: {
                chart: {
                    type: 'column',
                    options3d: {
                        enabled: true
                    }
                },
                series: [{ data: [1, 2, 3, 4, 5] }]
            }
        };
    }
};
import * as Highcharts from 'highcharts';
import HC_3D from 'highcharts/highcharts-3d';
import HC_exporting from 'highcharts/modules/exporting';

// Initialize modules
HC_3D(Highcharts);
HC_exporting(Highcharts);

@Component({
    selector: 'app-chart',
    template: `<highcharts-chart [Highcharts]="Highcharts" [options]="chartOptions"></highcharts-chart>`
})
export class ChartComponent {
    Highcharts: typeof Highcharts = Highcharts;
    chartOptions: Highcharts.Options = {
        chart: {
            type: 'column',
            options3d: { enabled: true }
        },
        series: [{ type: 'column', data: [1, 2, 3, 4, 5] }]
    };
}

Common Modules

3D Charts

import highcharts3d from 'highcharts/highcharts-3d';
highcharts3d(Highcharts);

Exporting

import exporting from 'highcharts/modules/exporting';
exporting(Highcharts);

Accessibility

import accessibility from 'highcharts/modules/accessibility';
accessibility(Highcharts);

Annotations

import annotations from 'highcharts/modules/annotations';
annotations(Highcharts);

Boost

import boost from 'highcharts/modules/boost';
boost(Highcharts);

Drilldown

import drilldown from 'highcharts/modules/drilldown';
drilldown(Highcharts);

Best Practices

Important Considerations:
  • Always import and initialize modules before creating charts
  • Use refs to access chart instances in React and Angular
  • Avoid recreating chart options on every render
  • Use memoization for complex chart options
  • Clean up chart instances in component unmount hooks
Performance Tips:
  • Lazy load Highcharts modules only when needed
  • Use the boost module for large datasets
  • Debounce chart updates when data changes frequently
  • Consider using web workers for data processing

Server-Side Rendering (SSR)

'use client'; // Mark as client component

import { useEffect, useState } from 'react';
import dynamic from 'next/dynamic';

const HighchartsReact = dynamic(
  () => import('highcharts-react-official'),
  { ssr: false }
);

export default function Chart() {
  const [Highcharts, setHighcharts] = useState(null);

  useEffect(() => {
    import('highcharts').then(module => {
      setHighcharts(module.default);
    });
  }, []);

  if (!Highcharts) return <div>Loading...</div>;

  const options = {
    series: [{ data: [1, 2, 3] }]
  };

  return <HighchartsReact highcharts={Highcharts} options={options} />;
}

Next Steps

Basic Charts

Explore basic chart examples and patterns

API Reference

Browse the complete API documentation