Highcharts Time Series, Zoomable Chart
The following example demonstrates a time-based spline chart.
We learned the Highcharts configuration syntax in the previous chapters. Now let's look at a complete example:
Configure
Chart
Configure a zoomable chart. chart.zoomType specifies the dimension the user can drag; the user can zoom by dragging the mouse, and the possible values are x, y, or xy:
var chart = {
zoomType: 'x'
};
plotOptions
Configure the chart area using plotOptions:
Configure two Y axes:
var plotOptions = {
area: {
fillColor: {
linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1},
stops: [
[0, Highcharts.getOptions().colors[0]],
[1, Highcharts.Color(Highcharts.getOptions().colors[0]).setOpacity(0).get('rgba')]
]
},
marker: {
radius: 2
},
lineWidth: 1,
states: {
hover: {
lineWidth: 1
}
},
threshold: null
}
};
plotOptions
plotOptions is used to set the data point-related properties of the chart.
var plotOptions = {
series: {
cursor: 'pointer',
point: {
events: {
click: function (e) {
hs.htmlExpand(null, {
pageOrigin: {
x: e.pageX || e.clientX,
y: e.pageY || e.clientY
},
headingText: this.series.name,
maincontentText: Highcharts.dateFormat('%A, %b %e, %Y', this.x)
+ ':
' + this.y + ' visits',
width: 200
});
}
}
},
marker: {
lineWidth: 1
}
}
}
Example
Filename: highcharts_line_time.htm
Highcharts 教程 | Runoob Tutorial(runoob.com)
The output of the above example is:
Highcharts Spline Chart