Crownfield
Posts: 2
Joined: Mon Aug 08, 2016 8:37 am

How to format data for HighStock chart?

I'm a HighCharts beginner started with a small StockChart / Candlestick Chart as follows:

Code: Select all

<script type="text/javascript">
$(function () { 
    $('#container').highcharts('StockChart',{
        chart: {
            type: 'candlestick'
        },
        title: {
            text: 'My first Candlestick Chart'
        }, 
		
		series:  [{
            data: [{ 
			         date: 2016-08-01,
					 open: 30, 
					 high: 44,
					 low: 20,
					 close: 25
					}, { 
			         date: 2016-08-02,
					 open: 35, 
					 high: 45,
					 low: 22,
					 close: 27
					}]
        }]
    });
});
</script>
The Candlesticks are displayed, but the date is corrupt as you can see in attached screenshot.

I' wondering about the poor documentation of data usage. There exists many examples, but all examples are very identical and offer extremely limited insight how to use Data. How should JSON-formated Data or XML-formated Data or CSV-formated data look like? Could you give me help how to use `date` in Time Series data?
Attachments
My First Candlestick.PNG
My First Candlestick.PNG (16.38 KiB) Viewed 9395 times
sdo

Re: How to format data for HighStock chart?

Hi. I cannot find any data's 'date' property to be allowed in Highcharts.
The correct format for dates is timestamp in milliseconds and manually it can be set through 'x' property.
API: http://api.highcharts.com/highstock#ser ... tick>.data
If you have different date format you should parse it to timestamp.

Example: http://jsfiddle.net/grw3hamv/

Regards
Crownfield
Posts: 2
Joined: Mon Aug 08, 2016 8:37 am

Re: How to format data for HighStock chart?

Thank you very much for your answer.
kiyo
Posts: 1
Joined: Tue Jun 08, 2021 6:20 am

Re: How to format data for HighStock chart?

How change display for date formats as Japanese style ?
NG: dd/mm
OK: mm/dd
User avatar
sebastian.h
Posts: 1734
Joined: Fri Aug 07, 2020 7:08 am

Re: How to format data for HighStock chart?

Hi kiyo,

But where exactly would you like to show the date in a different format? Here is an example with changed datalabels.format.

Live demo:
https://jsfiddle.net/BlackLabel/bxL78h2t/

Here you find information on how to set the date format.
https://api.highcharts.com/highstock/time
https://api.highcharts.com/highstock/ti ... zoneOffset
https://api.highcharts.com/highstock/pl ... els.format

Let me know if that was what you were looking for.
Best regards.
Sebastian Hajdus
Highcharts Developer

Return to “Highcharts Stock”