Skip to content

Commit e2d0477

Browse files
committed
feat: add some bar chart examples
1 parent bbbbac0 commit e2d0477

File tree

1 file changed

+67
-1
lines changed

1 file changed

+67
-1
lines changed

stories/bar.stories.tsx

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BarChart } from '@fanciers/echarts-react';
1+
import { BarChart, Tooltip } from '@fanciers/echarts-react';
22
import type { Meta, StoryObj } from '@storybook/react';
33

44
const meta = {
@@ -30,3 +30,69 @@ export const BarSimple: Story = {
3030
);
3131
},
3232
};
33+
34+
export const BarTickAlign: Story = {
35+
name: 'Axis Align with Tick',
36+
render() {
37+
return (
38+
<BarChart
39+
style={{ width: 480, height: 300 }}
40+
grid={{ left: '3%', right: '4%', bottom: '3%', containLabel: true }}
41+
xAxis={[
42+
{
43+
type: 'category',
44+
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
45+
axisTick: { alignWithLabel: true },
46+
},
47+
]}
48+
yAxis={[{ type: 'value' }]}
49+
series={[{ name: 'Direct', type: 'bar', barWidth: '60%', data: [10, 52, 200, 334, 390, 330, 220] }]}
50+
>
51+
<Tooltip tooltip={{ trigger: 'axis', axisPointer: { type: 'shadow' } }} />
52+
</BarChart>
53+
);
54+
},
55+
};
56+
57+
export const BarBackground: Story = {
58+
name: 'Bar with Background',
59+
render() {
60+
return (
61+
<BarChart
62+
style={{ width: 480, height: 300 }}
63+
xAxis={{ type: 'category', data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] }}
64+
yAxis={{ type: 'value' }}
65+
series={[
66+
{
67+
data: [120, 200, 150, 80, 70, 110, 130],
68+
type: 'bar',
69+
showBackground: true,
70+
backgroundStyle: { color: 'rgba(180, 180, 180, 0.2)' },
71+
},
72+
]}
73+
/>
74+
);
75+
},
76+
};
77+
78+
export const BarDataColor: Story = {
79+
name: 'Set Style of Single Bar',
80+
render() {
81+
return (
82+
<BarChart
83+
style={{ width: 480, height: 300 }}
84+
xAxis={{
85+
type: 'category',
86+
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
87+
}}
88+
yAxis={{ type: 'value' }}
89+
series={[
90+
{
91+
type: 'bar',
92+
data: [120, { value: 200, itemStyle: { color: '#505372' } }, 150, 80, 70, 110, 130],
93+
},
94+
]}
95+
/>
96+
);
97+
},
98+
};

0 commit comments

Comments
 (0)