amcharts / amcharts3

JavaScript Charts V3
Other
395 stars 129 forks source link

Working on persian date type #181

Closed sayjeyhi closed 6 years ago

sayjeyhi commented 6 years ago

Hi there , I am working on amChart.js to make support of persian date type(Jalali) I did some trick and now we can use amCharts wtih persian date format , but the source of amcharts free version is minified , could we have not minified version of amcharts ? Even we can contribute the completed code after it works.

Thanks.

amcharts commented 6 years ago

New comment from Zendesk by Anthony Piris on ticket 34032. (replying here will automatically notify amCharts support agent)

Hi there,

Only OEM license holders have access to the unminified source. The free version is always minified. We appreciate the offer, however we don't accept patches. This repo is for distribution only.

Note that rather than modifiying the sources directly, you can leverage the labelFunction and categoryBalloonFunction to format your dates to the desired format using a library such as persian date:

  chartCursor: {
    categoryBalloonFunction: function(dateObj) {
      return persianDate(dateObj).format("MMM DD, YYYY");
    }
  },

  categoryAxis: {
    parseDates: true,
    labelFunction: function(dateText, dateObj, categoryAxis, period) {
      var labelText;
      var pDate = persianDate(dateObj);
      switch (period) {
        case "YYYY":
          labelText = pDate.format("YYYY");
          break;
        case "MM":
          labelText = pDate.format("MMM YYYY");
          break;
        default:
          labelText = pDate.format("MMM DD");
          break;
      }

      return labelText;
    }
  },

Demo: https://codepen.io/team/amcharts/pen/5896cb1a271c08bdd2ddcc5f2cb5d68c?editors=0010

Another approach you can take is to create a new lang file based on the formats in the amcharts/lang folder so that the chart can do most of the legwork without using a label function and external library. The only limitation is that you can't format numbers like the persian date library.

I hope this helps.

Best,

Anthony Piris amCharts

sayjeyhi commented 6 years ago

Great , thanks alot . Ofcourse I created an AmCharts.jalali.js version and it was working with UTC dateTime format , but this will be so better than that , and we will use this instead .

amcharts commented 6 years ago

New comment from Zendesk by Anthony Piris on ticket 34032. (replying here will automatically notify amCharts support agent)

You're welcome.

Also my apologies for the broken persian date docs link. The correct docs URL is http://babakhani.github.io/PersianWebToolkit/doc/persian-date/ and the repo is at https://github.com/babakhani/persianDate.

Best,

Anthony Piris amCharts