Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c7e6875

Browse files
authored
Merge pull request plotly#1144 from plotly/locale-config-example
Add "change default locale" tutorial to JS configuration options
2 parents 6c56807 + ef0cb81 commit c7e6875

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
name: Change the Default Locale
3+
plot_url: https://codepen.io/plotly/embed/rqrgEQ/?height=600&theme-id=15263&default-tab=result
4+
language: plotly_js
5+
suite: configuration
6+
order: 7.5
7+
sitemap: false
8+
arrangement: horizontal
9+
markdown_content: |
10+
Load and register a non-default locale by adding `<script src="https://cdn.plot.ly/plotly-locale-YOUR-LOCALE-latest.js"></script>`
11+
to your HTML after the plotly.js tag and then reference the locale in the `config`. For Example, the codepen example below has
12+
`<script src="https://cdn.plot.ly/plotly-locale-fr-latest.js"></script>` in its HTML. For more information and a list of available locales, see
13+
[https://github.com/plotly/plotly.js/blob/master/dist/README.md#to-include-localization](https://github.com/plotly/plotly.js/blob/master/dist/README.md#to-include-localization)
14+
---
15+
var trace1 = {
16+
type: "scatter",
17+
mode: "lines",
18+
x: ['2018-01-01', '2018-08-31'],
19+
y: [10, 5],
20+
line: {color: '#17BECF'}
21+
};
22+
23+
var trace2 = {
24+
type: "scatter",
25+
mode: "lines",
26+
x: ['2018-01-01', '2018-08-31'],
27+
y: [3,7],
28+
line: {color: '#7F7F7F'}
29+
};
30+
31+
var data = [trace1,trace2];
32+
33+
var layout = {
34+
title: 'Custom Locale',
35+
};
36+
37+
var config = {locale: 'fr'};
38+
39+
Plotly.newPlot('myDiv', data, layout, config);
40+

0 commit comments

Comments
 (0)