Highcharts Configuration Options in Detail
Highcharts provides a large number of configuration options and parameters, allowing you to easily customize charts to meet user requirements. This chapter introduces the use of Highcharts configuration options in detail:
Parameter Configuration (Properties + Events)
-
chart.events.addSeries: Add a data series to the chart.
-
chart.events.click: The click event that occurs on the chart's plotting area.
-
chart.events.load: The chart load event.
-
chart.events.redraw: The chart redraw event, triggered when clicking a legend to show or hide a plot.
-
chart.events.selection: When the chart curve can be selected for zooming, this event can be triggered when a chart selection operation occurs.
-
chart.height: The height value of the drawn chart.
-
chart.inverted: Swap the X and Y axes in the chart.
-
chart.polar: Whether it is a polar chart.
-
chart.reflow: When the window size changes, the chart width automatically adapts to the window size change.
-
chart.renderTo: The location where the chart is loaded, a DOM object on the page.
-
chart.showAxes: Whether to show the axes in an empty chart.
-
chart.type: The chart type, default is line, and there are alsobar/column/pie……
-
chart.width: The width of the chart's plotting area, default is auto.
-
chart.zoomType: The zoom type of the data report in the chart, which can zoom along the X axis, the Y axis, or both XY axes at the same time.
-
colors: The colors between data series when there are many columns in the chart. It is an array and is generally not modified.
-
credits.enabled: Whether to allow displaying copyright information.
-
credits.href: The link to the copyright owner.
-
credits.text: The text displayed for the copyright information.
-
exporting.buttons.exportButton.enabled: Whether to allow displaying the export button.
-
exporting.buttons.exportButton.menuItems: The menu options of the export button.
-
exporting.buttons.exportButton.onclick: The event when the export button is clicked, not the internal menu.
-
exporting.buttons.printButton.enabled: Whether to allow the print button.
-
exporting.buttons.printButton.onclick: The click event of the print button.
-
exporting.enabled: Whether the print and export buttons are enabled.
-
exporting.filename: The filename of the exported file.
-
exporting.type: The default file format of the exported image.
-
exporting.url: The endpoint URL that handles SVG chart conversion and export.
-
exporing.width: The default width of the exported image.
-
labels: A tag that can be loaded anywhere on the chart, containing items and style.
-
lang: Language configuration, including settings related to the export button menu, time and date names, etc.
-
legend.enabled: Whether to enable the legend.
-
navigation.buttonOptions.enabled: Whether all navigation buttons in the chart are clickable.
-
plotOptions.area.allowPointSelect: Whether to allow clicking on data points.
-
plotOptions.area.color: The color of the plot.
-
plotOptions.area.dataLabels.enabled: Whether to enable data labels.
-
plotOptions.area.enableMouseTracking: Whether to enable mouse-tracking tooltips for data points in the chart.
-
plotOptions.area.events.checkboxClick: The click event on a checkbox in the chart legend.
-
plotOptions.area.events.click: The click event on a data point in the chart.
-
plotOptions.area.events.hide: The event triggered when a data series is hidden in the chart.
-
plotOptions.area.events.show: The event triggered when a data series is shown in the chart.
-
plotOptions.area.events.legendItemClick: The event triggered when an item in the chart legend is clicked; setting it directly to false makes it non-clickable.
-
plotOptions.area.events.mouseOut: The mouse-out event on a data point.
-
plotOptions.area.events.mouseOver: The mouse-over event on a data point.
-
plotOptions.area.marker.enabled: Whether to show point markers in the plot.
-
plotOptions.area.marker.states.hover.enabled: Whether to enable the hover state of markers.
-
plotOptions.area.marker.states.select.enabled: Whether to enable the select state of markers.
-
plotOptions.area.point.events.click: The click event on each individual point in the chart.
-
plotOptions.area.point.events.mouseOut
-
plotOptions.area.point.events..mouseOver
-
plotOptions.area.point.events.remove: The event triggered when a point is removed from the chart.
-
plotOptions.area.point.events.select: The point selection event in the chart.
-
plotOptions.area.point.events.unselect: The event triggered when a point is deselected in the chart.
-
plotOptions.area.point.events.update: The event triggered when data in the chart is updated.
-
plotOptions.area.visible: Whether a data series is shown or hidden by default on load.
-
plotOptions.area.zIndex: In the case of multiple series, adjusts the stacking order of each series.
-
The point.events above also apply to other area-type charts (arearange, areaspline, areasplinerange), other column-type charts (bar, column), and all charts.
-
plotOptions.area.showInLegend: Whether to show it in the legend.
-
plotOptions.area.stacking: Whether to stack by value or by percentage.
-
plotOptions.area.states.hover.enabled: Whether to enable the hover state.
-
plotOptions.area.stickyTracking: Sticky mouse tracking of data points.
-
plotOptions.arearange, plotOptions.areaspline, and plotOptions.areasplinerange are similar to plotOptions.area
-
plotOptions.bar.groupPadding: For grouped bar charts, the padding between groups.
-
plotOptions.bar.grouping: Whether to group the data.
-
plotOptions.bar.minPointLength:: Defines the minimum length of a point when its value is zero
-
plotOptions.bar.showInLegend: Whether to show it in the legend.
-
plotOptions.bar.stacking: Whether to stack by value or by percentage (normal/percent).
-
plotOptions.column and plotOptions.columnrange are similar to plotOptions.bar
-
The configuration of plotOptions.line is similar to that of plotOptions.area.
-
plotOptions.pie.ignoreHiddenPoint: In a pie chart, when a series is hidden by clicking the legend, whether the whole pie is redistributed to 100%, or simply hidden on the original chart leaving a gap.
-
plotOptions.pie.innerSize: When drawing a pie chart, how much blank space is reserved at the center.
-
plotOptions.pie.slicedOffset: Used together with allowPointSelect; when a point is clicked, the corresponding slice is pulled out, and this parameter configures the offset distance.
-
Other common configuration parameters of plotOptions.pie are similar to plotOptions.area; the configurations of plotOptions.scatter, plotOptions.series, and plotOptions.spline are similar to plotOptions.area.
-
series: It is an array.
-
series.data.color: The color of a particular data item.
-
series.data.dataLabels: The data label of a particular data item in the series.
-
series.data.events is similar to the configuration of plotOptions.area.point.events.
-
series.data.marker is similar to the configuration of plotOptions.area.marker.
-
series.data.name: Configures the name of the data point.
-
series.data.sliced: In a pie chart, configures the separation distance of a slice.
-
series.data.x: The x value of the point.
-
series.data.y: The y value of the point.
-
series.name: The name of the data series.
-
series.stack: The group index for stacking.
-
series.type: The display type of the data series.
-
series.xAxis, series.yAxis: When using multiple axes, specifies which axis a series corresponds to.
-
subtitle: Configures the subtitle of the chart.
-
title: Configures the title of the chart.
-
tooltip: Configures the tooltips for data in the chart.
-
tooltip.valueDecimals: The number of decimal places allowed.
-
tooltip.percentageDecimals: The number of decimal places allowed for percentages.
-
xAxis, yAxis configures and sets the axes
-
allowDecimals: Whether decimals are allowed on the axis.
-
categories: An array of categories for the axis.
-
plotLines: Draws plot lines.
-
tickColor: The color of the tick marks.
-
tickInterval: The interval step of the ticks.
-
labels.rotation: The rotation angle of the tick labels
Chart: Chart area options
The Chart options are used to set properties related to the chart area.
| Parameters | Description | Default value |
|---|---|---|
| backgroundColor | Sets the background color of the chart area | #FFFFFF |
| borderWidth | Sets the border width of the chart | 0 |
| borderRadius | Sets the border radius of the chart | 5 |
| renderTo | The container where the chart is placed; typically a DIV is placed in the HTML and its id attribute value is obtained | null |
| defaultSeriesType | Default chart types: line, spline, area, areaspline, column, bar, pie, scatter | 0 |
| width | The chart width; by default it adapts to the width of the chart container | null |
| height | The chart height; by default it adapts to the height of the chart container | null |
| margin | Sets the spacing between the chart and other elements, as an array, e.g., [0,0,0,0] | [null] |
| plotBackgroundColor | The background color of the main chart area, i.e., the area enclosed by the X and Y axes | null |
| plotBorderColor | The border color of the main chart area, i.e., the border color of the area enclosed by the X and Y axes | null |
| plotBorderWidth | The border width of the main chart area | 0 |
| shadow | Whether to enable a shadow; requires the backgroundColor to be set. | false |
| reflow | Whether to automatically use the chart area's height and width; if width and height are not set, the size adapts automatically. | true |
| zoomType | Zoom by dragging the mouse, along the x-axis or y-axis; can be set to: 'x', 'y', 'xy' | '' |
| events | Event callbacks; supports callback functions for the addSeries, click, load, selection methods, etc. |
Color: Color options
The Color options are used to set the color scheme of the chart.
| Parameters | Description | Default value |
|---|---|---|
| color | Used to display the colors of line, column, pie and other charts, in array form. | array |
Highcharts provides several color schemes by default. When there are more shapes to display than colors available, the extra shapes automatically start again from the first color scheme. How to customize the color scheme:
Highcharts.setOptions({
colors: ['#058DC7', '#50B432', '#ED561B', '#DDDF00', '#24CBE5', '#64E572', '#FF9655',
'#FFF263', '#6AF9C4']
});
Title: Title options
The Title options are used to set properties related to the chart title.
| Parameters | Description | Default value |
|---|---|---|
| text | The title text content. | Chart title |
| align | The horizontal alignment. | center |
| verticalAlign | The vertical alignment. | top |
| margin | The spacing between the title and subtitle, or between the main chart areas. | 15 |
| floating | Whether to float; if true, the title can be offset from the main chart area and can be used together with the x and y properties. | false |
| style | Sets the CSS style. | {color: '#3E576F', |
| fontSize: '16px'} |
Subtitle: Subtitle options
The properties provided by the subtitle are roughly the same as those of the title; refer to the title options above. It is worth noting that the subtitle's text option defaults to '', i.e., empty, so the subtitle is not displayed by default.
xAxis: X-axis options
The X-axis options are used to set properties related to the chart's X axis.
| Parameters | Description | Default value |
|---|---|---|
| categories | Sets the X-axis category names, as an array, e.g., categories: ['Apples', 'Bananas', 'Oranges'] | [] |
| title | The X-axis name; supports properties such as text, enabled, align, rotation, style, etc. | |
| labels | Sets the style of each X-axis category name, the formatter format, the rotation angle, etc. | array |
| max | The X-axis maximum value (when categories is empty); if null, the maximum is automatically matched based on the X-axis data. | null |
| min | The X-axis minimum value (when categories is empty); if null, the minimum is automatically matched based on the X-axis data. | array |
| gridLineColor | Grid (vertical line) color | #C0C0C0 |
| gridLineWidth | Grid (vertical line) width | 1 |
| lineColor | Baseline color | #C0D0E0 |
| lineWidth | Baseline width | 0 |
yAxis: Y-axis options
The Y-axis options are basically the same as the xAxis options above; refer to the parameters in the table above, and they are not listed separately.
Series: Data series options
The data series options are used to set properties related to the data displayed in the chart.
| Parameters | Description | Default value |
|---|---|---|
| data | The data series displayed in the chart, which can be an array or JSON-formatted data. E.g., data:[0, 5, 3, 5], or | |
| data: [{name: 'Point 1',y: 0}, {name: 'Point 2',y: 5}] | '' | |
| name | Displays the name of the data series. | '' |
| type | The data series type; supports area, areaspline, bar, column, line, pie, scatter or spline | line |
plotOptions: Data Point Options
plotOptions is used to set properties related to the data points in the chart. The property settings of plotOptions vary slightly depending on the chart type; the common options are listed below.
| Parameters | Description | Default value |
|---|---|---|
| enabled | Whether to display data directly on the data points | false |
| allowPointSelect | Whether to allow selecting data points with the mouse | false |
| formatter | A callback function that formats the displayed data content | formatter: function() {return this.y;} |
Tooltip: Data point tooltip
Tooltip is used to set the information displayed in the tooltip when the mouse hovers over a data point.
| Parameters | Description | Default value |
|---|---|---|
| enabled | Whether to display the tooltip | true |
| backgroundColor | Sets the background color of the tooltip | rgba(255, 255, 255, .85) |
| borderColor | The tooltip border color; by default it automatically matches the color of the data series | auto |
| borderRadius | The tooltip border radius | 5 |
| shadow | Whether to display the tooltip shadow | true |
| style | Sets the tooltip content style, such as font color, etc. | color:'#333' |
| formatter | A callback function used to format the output content of the tooltip. The returned content supports html tags such as:, , , ,
, |
2 |
Legend: Legend options
legend is used to set properties related to the legend.
| Parameters | Description | Default value |
|---|---|---|
| layout | The display layout; supports horizontal and vertical | horizontal |
| align | The alignment. | center |
| backgroundColor | The legend background color. | null |
| borderColor | The legend border color. | #909090 |
| borderRadius | The legend border radius | 5 |
| enabled | Whether to show the legend | true |
| floating | Whether it can float, used together with the x and y properties. | false |
| shadow | Whether to display a shadow | false |
| style | Sets the legend content style | '' |
For more detailed information, please refer to the English documentation on the Highcharts official website:http://api.highcharts.com/highcharts