ArticleZip > Set Additional Data To Highcharts Series

Set Additional Data To Highcharts Series

Highcharts is a powerful tool for creating interactive and visually appealing charts on the web. In this guide, we'll explore how to set additional data to Highcharts series to enhance the functionality and customization of your charts.

Adding extra data to your Highcharts series allows you to include more information in your charts without cluttering the chart itself. This can be useful for providing additional context or details that are relevant to the data being displayed.

To set additional data to a Highcharts series, you can use the `data` property of the series object. This property accepts an array of data points, each of which can include not only the value to be displayed on the chart but also any additional data that you want to associate with that point.

Here's an example of how you can set additional data to a Highcharts series using the `data` property:

Javascript

Highcharts.chart('container', {
    series: [{
        name: 'My Series',
        data: [
            { y: 10, myCustomData: 'Additional Info 1' },
            { y: 20, myCustomData: 'Additional Info 2' },
            { y: 30, myCustomData: 'Additional Info 3' }
        ]
    }]
});

In this example, each data point in the series includes a `y` value (which represents the value to be displayed on the chart) and a `myCustomData` property that contains the additional information you want to include.

Once you have set the additional data to your Highcharts series, you can access this data in various event handlers or tooltip formatters to display it to the user. For example, you can customize the tooltip of the chart to show the additional data when the user hovers over a data point.

To access the additional data in the tooltip formatter, you can use the `point` object provided by Highcharts, like this:

Javascript

tooltip: {
    formatter: function() {
        return 'Value: ' + this.y + '<br>' + 'Additional Info: ' + this.point.myCustomData;
    }
}

In this tooltip formatter function, `this.y` represents the value of the data point, and `this.point.myCustomData` allows you to access the additional data associated with that point.

By setting additional data to your Highcharts series and customizing how this data is displayed, you can create more informative and engaging charts for your users. Experiment with different ways of incorporating extra information into your charts to provide a richer experience for your audience.

So, go ahead and try setting additional data to your Highcharts series to take your charting to the next level! Happy charting!