How to use amchart with jalali calendar?

399 views Asked by At

I'm using amchart and I can't use the Jalali calendar because it doesn't support the non-Gregorian calendar.

I want to have Jalali date in date-Axis.

enter image description here

How I can change it?

2

There are 2 answers

0
Javad Shariati On BEST ANSWER

You can't change locale of datetime. but you can modify dateAxis by geting rendered text and change it by adapter.

for tooltip:

dateAxis.adapter.add("getTooltipText", function(text){
  return new Date(text).toLocaleDateString('fa-IR')
})

for label:

dateAxis.renderer.labels.template.adapter.add("text", function(text) {
  return  new Date(text).toLocaleDateString('fa-IR');
});
0
SalehMosavi On

for label I recommend to get text from 'target.dataItem' because some times text was shorted... like : "April"

dateAxis.renderer.labels.template.adapter.add("text", function (text, target, key) {
    if (text !== undefined) {
        return new Date(target.dataItem.values.value.value).toLocaleDateString('fa-IR');
    }
});