Skip to content

Commit e9cf9ad

Browse files
sthenaultSylvain Thénault
andauthored
Add locale to Opts type (#412)
* Add locale to Opts type as available in echarts v5 * Add example of using Opts.locale to the demo website Co-authored-by: Sylvain Thénault <sylvain.thenault@lowatt.fr>
1 parent 787cee1 commit e9cf9ad

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

docs/examples/locale.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
title: Locale
3+
order: 8
4+
---
5+
6+
## Locale
7+
8+
```tsx
9+
import React from 'react';
10+
import ReactECharts from 'echarts-for-react';
11+
12+
import "echarts/i18n/langFR";
13+
14+
const Page: React.FC = () => {
15+
const option = {
16+
title: {
17+
text: 'ECharts 入门示例'
18+
},
19+
toolbox: {
20+
feature: {
21+
saveAsImage: {},
22+
dataZoom: {},
23+
restore: {}
24+
}
25+
},
26+
tooltip: {},
27+
legend: {
28+
data:['销量']
29+
},
30+
xAxis: {
31+
data: ['衬衫', '羊毛衫', '雪纺衫', '裤子', '高跟鞋', '袜子']
32+
},
33+
yAxis: {},
34+
series: [{
35+
name: '销量',
36+
type: 'line',
37+
data: [5, 20, 36, 10, 10, 20]
38+
}]
39+
};
40+
41+
return <ReactECharts
42+
option={option}
43+
style={{ height: 400 }}
44+
opts={{ locale: 'FR' }}
45+
/>;
46+
};
47+
48+
export default Page;
49+
```

src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export type Opts = {
99
readonly renderer?: 'canvas' | 'svg';
1010
readonly width?: number | null | undefined | 'auto';
1111
readonly height?: number | null | undefined | 'auto';
12+
readonly locale?: string;
1213
};
1314

1415
export type EChartsReactProps = {

0 commit comments

Comments
 (0)