Displaying Persian dates in highchart from its corresponding Georgian date
Then better way to override date formating is to use Highcharts.dateFormats
(and persianDate library), This allows conversion of all dates (not x or y axis) to Persian calendar.
Sample: http://jsfiddle.net/smpaB/1/
Add pesianDate library with:
<script src="http://rawgithub.com/babakhani/PersianDate/master/dist/persian-date.min.js"></script>
And configure highcharts with:
Highcharts.dateFormats = {
'a': function(ts){return new persianDate(ts).format('dddd')},
'A': function(ts){return new persianDate(ts).format('dddd')},
'd': function(ts){return new persianDate(ts).format('DD')},
'e': function(ts){return new persianDate(ts).format('D')},
'b': function(ts){return new persianDate(ts).format('MMMM')},
'B': function(ts){return new persianDate(ts).format('MMMM')},
'm': function(ts){return new persianDate(ts).format('MM')},
'y': function(ts){return new persianDate(ts).format('YY')},
'Y': function(ts){return new persianDate(ts).format('YYYY')},
'W': function(ts){return new persianDate(ts).format('ww')}
};
I developed a Jalali Date library, JDate
, that is compatible with original javascript Date
class. Dates in highchart/highstock charts can be converted to Jalali by replacing window.Date
with JDate
. With this method all date outputs is converted to jalali calendar, And also, date input features (like YTD feature, or range selector) works with jalali calendar.
Demo: https://tahajahangir.github.io/jdate/jalali-highcharts-demo.html
The main part of script in above demo, is:
<script src="//raw.githack.com/tahajahangir/jdate/master/jdate.min.js"></script>
<script>
window.Date = JDate;
Highcharts.setOptions({
lang: {
months: ['فروردين', 'ارديبهشت', 'خرداد', 'تیر', 'مرداد', 'شهریور', 'مهر', 'آبان', 'آذر', 'دی', 'بهمن', 'اسفند'],
shortMonths: ['فروردين', 'ارديبهشت', 'خرداد', 'تیر', 'مرداد', 'شهریور', 'مهر', 'آبان', 'آذر', 'دی', 'بهمن', 'اسفند'],
weekdays: ["یکشنبه", "دوشنبه", "سه شنبه", "چهارشنبه", "پنجشنبه", "جمعه", "شنبه"]
}
});
</script>
I borrowed this js script and tried it out here. Not sure if that is what you are after though.