score:8
score:0
You can use it babakhani persian date js for example:
xAxis: {
type: 'datetime',
labels: {
formatter: function () {
var date = new Date(this.value);
var pdate = persianDate(date);
return (pdate.pDate.year - 1300) + "/" + pdate.pDate.month;
}
}
}
score:0
Update for 2 first answer
- Mark answer: http://jsfiddle.net/xgru6nya/
- Taha Jahangir answer: http://jsfiddle.net/ab7kde83/
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="https://cdn.jsdelivr.net/npm/persiandate@0.2.1/dist/persiandate.min.js"></script>
<div id="container" style="height: 400px"></div>
var chart = new Highcharts.Chart({
chart: {
renderTo: 'container'
},
xAxis: {
type: 'datetime',
labels: {
formatter: function() {
var someDate = new Date(this.value);
return persianDate(someDate).format('YYYY-MMMM-D');
}
}
},
series: [{
data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4],
pointStart: Date.UTC(2010, 0, 1),
pointInterval: 24 * 3600 * 1000 // one day
}]
});```
score:10
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>
score:14
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')}
};
Source: stackoverflow.com
Related Query
- Displaying Persian dates in highchart from its corresponding Georgian date
- Populate Highcharts X-Axis With Dates Given a From And To Date
- Highchart : by passing FROM DATE and TO DATE x axis labels should set
- Why does my Highchart look different when I transfer my code from Jsfiddle to my server?
- how to display menu from date in highchart
- Loading data to Highchart from MySQL and displaying in appropriate way
- Highcharts displaying Date axis from milliseconds
- Highchart (pie chart) with data from HTML table not displaying legend
- Highchart group by month from corresponding column data
- How to render Gantt Highchart from data source
- How do I add a dropdown to change endRow value in a chart displaying date from an HTML table
- Displaying highchart and using php to get data for the chart from mysql database
- Highchart data from ajax its not working for me
- How to display highchart series line marker symbol from tooltip formatter?
- Remove Zero From the HIGHCHART
- Persian (farsi) numbers in highchart
- Convert from string with milliseconds to date object Javascript
- how to change highstock date to persian date
- How to dynamically change axis from linear to logarithmic in HighChart
- How can I generate a real-time highchart from my database data?
- Scatter tooltip of highchart is not being displaying
- Remove UTC date from Highcharts tooltip
- Using PhantomJS to create HighCharts grahps server side for use in PDF creation (PHP) - results in exit code 11 from PHPs exec();
- how to assign date time to highchart with intervals and date start
- How can I prevent my HighChart bar chart from being inverted?
- Highcharts X-Axis time from JS date
- Highchart - xAxis weekly date can start any day?
- Remove Image/Symbol from Highchart Graph
- AJAX displaying values from two different functions in a single Highcharts chart instead of two different ones
- How to update Highchart from inside react a component?
More Query from same tag
- Highcharts credits to be enabled while printing
- Drill down in Line Chart Highcharts
- How to pass the database data and display it in yii2 highCharts?
- R-highcharter combine tooltips
- Packed Bubble Chart with Gradient Legend in Highcharts
- Highcharts dataLabel overlap
- In PHP , How to convert JSON into highchart supported format
- Maximum number of categories in a Basic Bar chart
- how to add hover effect in hightcharts?
- highcharts - exported png in horizontal bar charts
- How can I have both years and string-formatted x-axes in two charts in HighCharts?
- My Highchart graphs are really slow when I choose 30 day graphs
- Pie chart options in ZingChart
- Old state is being shown despite updating in React Highcharts click event
- Highcharts in Angular - accessing the API
- How to use selenium IDE to find/check if a div object has children?
- Highcharts how to pass data from server into chart
- Highcharts Pie Custom Legend, possible?
- react-highcharts alignThreshold
- Highcharts connecting scatter chart and pie chart with single legend
- Stop Highcharts Networkgraph from redrawing the markers when hovering
- Highcahrts sometimes loads but not always
- Xaxis should get aligned at (0,0) in highcharts
- Highcharts server side rendering draw a mysterious semi circle donut shape
- Highcharts hide empty bars of categories for multiples series
- Insert data into jquery highcharts fail
- Can we add Zoom In Out feature in highcharts
- Highcharts Scatter Plot - How to Fix Overlapping Data Labels?
- JavaScript charting library to handle shading area between two lines
- HighChart: add data series dynamically with dynamically added categories on yAxis