Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Shamsi/Persian Date in D3 and DC.js

Tags:

d3.js

dc.js

How can i use Persian or Jalali or Shamsi Date in D3 or DC.js . for example if i have bar chart that X-axis contains date i want to sort the date based on Persian date that.

like image 450
MBehtemam Avatar asked Nov 11 '22 04:11

MBehtemam


1 Answers

I don't know anything about the topic in particular but do know the concepts. So I hope this helps, but I haven't tried it.

The underlying JavaScript time type is the number of milliseconds since Jan 1 1970 UTC (the "epoch". So the sorting and difference calculations are not specific to any calendar.

It is just the Date API and D3 that use the Gregorian calendar.

There are a number of libraries to convert Jalali/Shamsi to/from epoch time and JS Dates, just do a google search e.g. for "javascript jalali date".

Build your data set by converting Jalali dates to javascript dates, and specify the format for your axis using axis.tickFormat, using the converter in the other direction.

like image 189
Gordon Avatar answered Dec 06 '22 03:12

Gordon