Highcharts Tutorial
Chart Types
A negative area chart in Highcharts is a chart type used to represent data with negative values as an area below the x-axis, while positive values are represented as an area above the x-axis. This chart type is useful when you want to show the relationship between positive and negative values, and how they contribute to the total.
To create a negative area chart in Highcharts, you can use the chart.type
option set to 'areaspline'
or 'area'
. The data for the chart should be in a format with both positive and negative values.
Here's an example of how to create a negative area chart in Highcharts using the areaspline
chart type:
Highcharts.chart('container', { chart: { type: 'areaspline' }, title: { text: 'Negative Area Chart' }, xAxis: { categories: ['Category 1', 'Category 2', 'Category 3', 'Category 4', 'Category 5'] }, yAxis: { title: { text: 'Value' } }, series: [{ name: 'Series 1', data: [10, -20, 30, -40, 50] }] });
In this example, we first create a Highcharts chart object and configure it with the following options:
chart.type
is set to 'areaspline'
to create an areaspline charttitle.text
is set to 'Negative Area Chart'
to set the main titlexAxis.categories
is set to an array of category labels for the x-axisyAxis.title
is used to set the label for the y-axisseries
is set to an array of objects with a name
and data
property to define the series data. The data
property contains an array of values for each category, with positive and negative values. The areaspline
chart type automatically fills the area below the x-axis for negative values and above the x-axis for positive values.With these options, you can create a negative area chart in Highcharts. You can also customize the chart further by adding additional data points, setting the color scheme and style of the chart, and adjusting the chart options to best represent your data.
Customizing negative area charts in Highcharts:
Highcharts.chart('container', { chart: { type: 'area' }, series: [{ data: [5, -3, 4, -7, 2] }], // Other configuration options... });
Highcharts area chart with negative values:
Highcharts.chart('container', { chart: { type: 'area' }, series: [{ data: [5, -3, 4, -7, 2] }], // Other configuration options... });
Negative area chart API in Highcharts:
const chart = Highcharts.chart('container', { // Chart configuration }); // Access chart API methods chart.series[0].addPoint(-10);
Highcharts area chart series options for negative values:
series: [{ negativeColor: '#FFA07A', // Set color for negative values threshold: -5 // Define threshold for negative values }],
Highcharts inverted negative area chart:
chart: { inverted: true },
Highcharts stacked negative area chart:
stack
option.series: [{ stacking: 'normal', // 'normal' for stacked area data: [5, -3, 4, -7, 2] }],
Highcharts dual-axis negative area chart:
yAxis: [{ // Primary axis options }, { opposite: true, // Secondary axis for negative values // Secondary axis options }],
Highcharts streaming negative area chart:
series: [{ data: [] }],
Highcharts area chart with positive and negative values:
series: [{ data: [5, -3, 4, -7, 2] }],
Highcharts area chart tooltip for negative values:
tooltip: { pointFormatter: function () { return 'Value: ' + this.y; } },
Highcharts area chart gradient for negative values:
series: [{ color: { linearGradient: { x1: 0, x2: 0, y1: 0, y2: 1 }, stops: [ [0, '#FFFFFF'], [1, '#7CB5EC'] ] }, data: [5, -3, 4, -7, 2] }],
Highcharts area chart data format with negatives:
series: [{ data: [5, -3, 4, -7, 2] }],
Highcharts area chart color options for negative values:
series: [{ color: '#FFA07A', // Set color for the entire series negativeColor: '#FF6347' // Set color for negative values }],
Highcharts drilldown with negative area chart:
drilldown: { series: [{ name: 'Details', id: 'details', data: [/* Drilldown data with negatives */] }] },