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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With