score:42
Internally Highcharts uses javascript Date numbers (the number of milliseconds since Jan 1st 1970) to represent dates. See Mozilla reference.
To get dates on an axis you will first need to set the axis type to 'datetime':
xAxis: {
type: 'datetime'
}
You have a few options when specifying the series data (all three examples produce the same chart):
Setting a start point and using a fixed interval between points
pointStart: Date.UTC(2012, 2, 6, 10), pointInterval: 1000 * 60 * 60, data: [5, 6, 4]
Specifying the exact date using the Date.UTC method. This way its readable for humans:
data: [ [Date.UTC(2012, 2, 6, 10), 5], [Date.UTC(2012, 2, 6, 11), 6], [Date.UTC(2012, 2, 6, 12), 4]]
Or specifying the epoch time directly:
[[1331028000000, 5], [1331031600000, 6], [1331035200000, 4]]
Example on jsfiddle
score:4
Adding to @eolsson, epoch time is usually the way to go since technically, Date() objects are javascript, not JSON, and you're unlikely to find an off-the-shelf serializer that generates them.
You'll want to format the date, too, something like this --
xAxis: {
type: 'datetime',
labels: {
formatter: function() {
return Highcharts.dateFormat('%e %b', this.value*1000); // milliseconds not seconds
},
}
}
The date formatting is done php style.
Source: stackoverflow.com
Related Query
- What format does the highcharts js library accept for dates?
- Highmaps: what is the code for a county?
- jspdf is not able to capture the div content properly for highcharts to download as pdf format
- Why does this Highcharts graph only show tooltip for the first and last nodes?
- How do I use dates from a LinkedHashMap for the x-axis on a Highcharts line graph (using Thymeleaf)?
- Simple, Open source PHP wrapper for Highcharts library
- Slider implementation for the dates on the x-axis not working correctly in Highcharts
- How to get the correct the date-time format for highcharts in R (using rcharts)
- Tooltip in Highcharts doesn't show the right format for Date
- How to modify the code so that Highcharts graph does not cover fixed navigation bar at the top of the page?
- What is the solution for Highcharts hover
- What is the format of 'date' when for highchart?
- what should be the initial dataset from millions of data points for stock line highcharts
- Why does highcharts not accept an array for second y axis?
- Highcharts setExtremes() does not display the correct interval for one day
- How to get highcharts dates in the x axis?
- Customize tooltip and format the number to 2 decimal places of highcharts
- Highcharts - How to set custom colors for the series
- What is the best strategy for testing D3/HighCharts/SVG?
- Why does HighCharts reverse the order of my series?
- Customizing the Stockchart range selector buttons from HighCharts library in GWT (and Javascript in general)
- Why are the labels for my opposite yaxis in Highcharts not showing up?
- Sort the series data for every X-Axis in Highcharts
- Add onclick event on chart made with the highcharts library
- Using PhantomJS to create HighCharts grahps server side for use in PDF creation (PHP) - results in exit code 11 from PHPs exec();
- How to completely disable the mouse/finger interaction for highcharts
- Format Highcharts xAxis for stock data
- How to customize the crosshair Line for Highcharts
- What should be the right borderWidth in a solidgauge Highcharts chart?
- How to format datetime for (x,y) pair data for Highcharts
More Query from same tag
- JQuery animation doesn't work in IE8
- (Highcharts) Display Newest Data From Text File Only
- Highcharts treemap with colouraxis updating styles
- How do I create a pie chart from VML shapes?
- Optimal display for overlapping series in a line chart
- Highcharts Legend Custom HTML
- If a point is clicked then add a marker in highcharts
- Highcharts duplicating Legend Tags
- How is it possible to show the menu of a chart with React Highcharts?
- Representing sparse data in a Highcharts series
- Network chart nodes relation nodes merging -> highcharts
- Change in highcharts version breaks animation of elements
- Programmatically display Highstocks legend
- Rails and Highcharts
- *Highcharts* Tooltip format
- High chart formatter not working on Highchart API
- stop auto adjusting scale in highcharts
- Highcharts - Gauge chart data label not positioning correctly
- RRD raw data to JSON
- Lazy HighCharts and Loading Json Data
- Highcharts Dynamic tooltip positioning
- Highchart - change the minor spacing for linear guage chart
- Highcharts - Grouped Scatter? (relative to Grouped Column)
- Using HighchartsExport Library for .Net I am getting Blank Page
- Datetime format for series - Highcharts
- How to center text vertically in a custom highcharts button
- highcharts show additional custom data in tooltip
- Is there a way to call two function-based views from views.py from one url? - Django or even by using Class-based view
- resize highchart on load
- how to change the color of column in chart ?