JavaScript Time Ticks Chart
Example that showcases the TimeTickStrategy
feature.
TimeTickStrategy
is one of the available options for automatic axis tick placement and formatting. It is designed for depicting milliseconds timestamp data with extremely high resolution and flexibility.
The effective range of TimeTickStrategy
starts from maximum of 100 hours all the way down to individual milliseconds level.
For this entire range, the tick labels are formatted dynamically showing the currently relevant precision with all the required accuracy.
As can be seen from the simplicity of this examples source code, TimeTickStrategy
is really straightforward to use, and does not require any gimmicks from the user.
// TimeTickStrategy example usage.
// (1) Enable TimeTickStrategy for Axis.
chart.getDefaultAxisX().setTickStrategy(AxisTickStrategies.Time)
// (2) Push data where X is in milliseconds.
series.add([
{ x: 0, y: 0 }, // 00:00:00
{ x: 1000, y: 0 }, // 00:00:01
{ x: 2000, y: 0 }, // 00:00:02
{ x: 2001, y: 0 }, // 00:00:02.001
{ x: 2001.001, y: 0 }, // 00:00:02.001001
])
What is the difference between Time ticks and DateTime ticks?
The effective Axis range; TimeTickStrategy
is used for depicting high-resolution data within some days max., while DateTimeStrategy
is used for depicting lower resolution data over the span of long times, like some months or even tens of years.