Skip to content

Commit db8bde0

Browse files
authored
docs: add Charts subpage for React usage (#3397)
1 parent 50f4d22 commit db8bde0

File tree

5 files changed

+142
-0
lines changed

5 files changed

+142
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
title: Usage with React
3+
description: Examples of using Charts with React
4+
order: 10
5+
---
6+
7+
8+
= Usage with React
9+
10+
The sections that follow provide examples of certain Chart types with React.
11+
12+
== Column Chart
13+
14+
[.example]
15+
--
16+
[source,tsx]
17+
----
18+
include::{root}/frontend/demo/component/charts/react/charts-column.tsx[render,tags=snippet,indent=0,group=React]
19+
----
20+
--
21+
22+
23+
== Area Chart
24+
25+
[.example]
26+
--
27+
[source,tsx]
28+
----
29+
include::{root}/frontend/demo/component/charts/react/charts-area.tsx[render,tags=snippet,indent=0,group=React]
30+
----
31+
--
32+
33+
34+
== Pie Chart
35+
36+
[.example]
37+
--
38+
[source,tsx]
39+
----
40+
include::{root}/frontend/demo/component/charts/react/charts-pie.tsx[render,tags=snippet,indent=0,group=React]
41+
----
42+
--
43+
44+
== Polar Chart
45+
46+
[.example]
47+
--
48+
[source,tsx]
49+
----
50+
include::{root}/frontend/demo/component/charts/react/charts-polar.tsx[render,tags=snippet,indent=0,group=React]
51+
----
52+
--
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { reactExample } from 'Frontend/demo/react-example'; // hidden-source-line
2+
import React from 'react';
3+
import { Chart } from '@vaadin/react-components-pro/Chart.js';
4+
import { ChartSeries } from '@vaadin/react-components-pro/ChartSeries.js';
5+
6+
function Example() {
7+
return (
8+
// tag::snippet[]
9+
<Chart
10+
type="area"
11+
title="Area Chart"
12+
stacking="normal"
13+
categories={'Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec'.split(',')}
14+
>
15+
<ChartSeries
16+
title="United States dollar"
17+
values={[135, 125, 89, 124, 105, 81, 111, 94, 95, 129, 98, 84]}
18+
/>
19+
<ChartSeries title="Euro" values={[62, 72, 89, 68, 94, 92, 110, 100, 109, 89, 86, 105]} />
20+
<ChartSeries title="Japanese yen" values={[30, 25, 32, 26, 15, 31, 24, 32, 21, 8, 12, 32]} />
21+
<ChartSeries
22+
title="Pound sterling"
23+
values={[32, 21, 8, 12, 32, 21, 12, 30, 25, 19, 26, 15]}
24+
/>
25+
</Chart>
26+
// end::snippet[]
27+
);
28+
}
29+
30+
export default reactExample(Example); // hidden-source-line
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { reactExample } from 'Frontend/demo/react-example'; // hidden-source-line
2+
import React from 'react';
3+
import { Chart } from '@vaadin/react-components-pro/Chart.js';
4+
import { ChartSeries } from '@vaadin/react-components-pro/ChartSeries.js';
5+
6+
function Example() {
7+
return (
8+
// tag::snippet[]
9+
<Chart title="Column Chart" type="column" categories={['Jan', 'Feb', 'Mar']}>
10+
<ChartSeries title="Tokyo" values={[49.9, 71.5, 106.4]} />
11+
<ChartSeries title="New York" values={[83.6, 78.8, 98.5]} />
12+
<ChartSeries title="London" values={[48.9, 38.8, 39.3]} />
13+
</Chart>
14+
// end::snippet[]
15+
);
16+
}
17+
18+
export default reactExample(Example); // hidden-source-line
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { reactExample } from 'Frontend/demo/react-example'; // hidden-source-line
2+
import React from 'react';
3+
import { Chart } from '@vaadin/react-components-pro/Chart.js';
4+
import { ChartSeries } from '@vaadin/react-components-pro/ChartSeries.js';
5+
6+
function Example() {
7+
return (
8+
// tag::snippet[]
9+
<Chart type="pie" title="Pie Chart" tooltip>
10+
<ChartSeries
11+
title="Brands"
12+
values={[
13+
{ name: 'Chrome', y: 38 },
14+
{ name: 'Firefox', y: 24 },
15+
{ name: 'Edge', y: 15, sliced: true, selected: true },
16+
{ name: 'Internet Explorer', y: 8 },
17+
]}
18+
/>
19+
</Chart>
20+
// end::snippet[]
21+
);
22+
}
23+
24+
export default reactExample(Example); // hidden-source-line
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { reactExample } from 'Frontend/demo/react-example'; // hidden-source-line
2+
import React from 'react';
3+
import { Chart } from '@vaadin/react-components-pro/Chart.js';
4+
import { ChartSeries } from '@vaadin/react-components-pro/ChartSeries.js';
5+
6+
function Example() {
7+
return (
8+
// tag::snippet[]
9+
<Chart polar title="Polar Chart">
10+
<ChartSeries type="column" title="Column" values={[8, 7, 6, 5, 4, 3, 2, 1]} />
11+
<ChartSeries type="line" title="Line" values={[1, 2, 3, 4, 5, 6, 7, 8]} />
12+
<ChartSeries type="area" title="Area" values={[1, 8, 2, 7, 3, 6, 4, 5]} />
13+
</Chart>
14+
// end::snippet[]
15+
);
16+
}
17+
18+
export default reactExample(Example); // hidden-source-line

0 commit comments

Comments
 (0)