简体   繁体   中英

How to use amchart with jalali calendar?

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.

在此处输入图像描述

How I can change it?

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');
});

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');
    }
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM