Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to change highstock date to persian date

I'm using highcharts. I'm trying to change its date to Persian but since it is using Date.UTC I can not change it!

I've seen the http://api.highcharts.com/highstock#lang but it seems that it doesn't support persian.

Do you know any way to change it into persian date? One method I can come across with is the algorithm that changes UTC date to Persian date.

Is there any way to solve this problem? Please help me...

Thank you

like image 221
bahar_Agi Avatar asked Mar 27 '13 07:03

bahar_Agi


1 Answers

You will have to do a bit of work to get this into highcharts.

Firstly, find a javascript library which converts dates to persian date. This one looks promising: http://intldate.codeplex.com/

Secondly, you need to customise the highcharts date formatting. Highcharts provides an API to do this:

http://api.highcharts.com/highcharts#Highcharts.dateFormat()

You need to use the dateFormats hook to add a %P option to the date format string which prints in persian format using the javascript library you choose. Once you have defined a %P format, you can customise the date formats to be used on the x-axis: http://api.highcharts.com/highcharts#xAxis.dateTimeLabelFormats

{
second: '%H:%M:%S',
minute: '%H:%M',
hour: '%H:%M',
day: '%P',
week: '%P',
month: '%P',
year: '%P'
} 

Note, you can define several dateFormat parameters, not just %P, to handle days, months etc.

like image 93
SteveP Avatar answered Sep 20 '22 18:09

SteveP