Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Persian Date #1226

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,54 @@ For extensive documentation, including getting started tutorials, as well
as class reference visit [amCharts 5 documentation website](https://www.amcharts.com/docs/v5).


#### Persian Date
If you want to use Persian date in your chart, you can use this code in your project.

```

import moment from "jalali-moment";
dateAxis
.get("renderer")
.labels.template.adapters.add("text", function (text, target) {
try {
if (target.dataItem) {
return moment(target.dataItem.get("value"))
.locale("fa")
.format("dddd-MMM");
}
} catch (err) {
return text;
}
});

let xTooltip = dateAxis.get("tooltip");
xTooltip.label.adapters.add("text", function (text, target) {
try {
if (text) {
return moment(text, "YYYY/MM/DD").format("jYYYY/jM/jD");
}
return text;
} catch (err) {
return text;
}
});


sbDateAxis
.get("renderer")
.labels.template.adapters.add("text", function (text, target) {
try {
if (target.dataItem) {
return moment(target.dataItem.get("value"))
.locale("fa")
.format("MMM YYYY");
}
} catch (err) {
return text;
}
});
```

### Pre-built binaries

* [NPM package](https://www.npmjs.com/package/@amcharts/amcharts5)
Expand Down
Loading