Skip to content

Commit 2dcff89

Browse files
authored
Update examples, Storybook no longer WIP (#320)
1 parent fec8ae0 commit 2dcff89

File tree

6 files changed

+19
-251
lines changed

6 files changed

+19
-251
lines changed

src/docs/exampleComponents/Customized/CustomizedCrossContent.js

Lines changed: 0 additions & 113 deletions
This file was deleted.

src/docs/exampleComponents/Customized/CustomizedRectangleContent.js

Lines changed: 0 additions & 114 deletions
This file was deleted.

src/docs/exampleComponents/Customized/index.js

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/docs/exampleComponents/Legend/LegendEffectOpacity.js

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,22 +47,26 @@ const data = [
4747
];
4848

4949
const Example = () => {
50-
const [opacity, setOpacity] = React.useState({
51-
uv: 1,
52-
pv: 1,
53-
});
50+
const [hoveringDataKey, setHoveringDataKey] = React.useState(null);
5451

55-
const handleMouseEnter = (o) => {
56-
const { dataKey } = o;
52+
let pvOpacity = 1;
53+
let uvOpacity = 1;
5754

58-
setOpacity((op) => ({ ...op, [dataKey]: 0.5 }));
59-
};
55+
if (hoveringDataKey === 'uv') {
56+
pvOpacity = 0.5;
57+
}
6058

61-
const handleMouseLeave = (o) => {
62-
const { dataKey } = o;
59+
if (hoveringDataKey === 'pv') {
60+
uvOpacity = 0.5;
61+
}
6362

64-
setOpacity((op) => ({ ...op, [dataKey]: 1 }));
65-
};
63+
const handleMouseEnter = (payload/*: LegendPayload */) => {
64+
setHoveringDataKey(payload.dataKey);
65+
}
66+
67+
const handleMouseLeave = () => {
68+
setHoveringDataKey(null);
69+
}
6670

6771
return (
6872
<div style={{ width: '100%' }}>
@@ -83,8 +87,8 @@ const Example = () => {
8387
<YAxis />
8488
<Tooltip />
8589
<Legend onMouseEnter={handleMouseEnter} onMouseLeave={handleMouseLeave} />
86-
<Line type="monotone" dataKey="pv" strokeOpacity={opacity.pv} stroke="#8884d8" activeDot={{ r: 8 }} />
87-
<Line type="monotone" dataKey="uv" strokeOpacity={opacity.uv} stroke="#82ca9d" />
90+
<Line type="monotone" dataKey="pv" strokeOpacity={pvOpacity} stroke="#8884d8" activeDot={{ r: 8 }} />
91+
<Line type="monotone" dataKey="uv" strokeOpacity={uvOpacity} stroke="#82ca9d" />
8892
</LineChart>
8993
</ResponsiveContainer>
9094
<p className="notes">Tips: Hover the legend !</p>

src/docs/exampleComponents/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import TreeMapExamples from './TreeMap';
1010
import TooltipExamples from './Tooltip';
1111
import LegendExamples from './Legend';
1212
import ResponsiveContainerExamples from './ResponsiveContainer';
13-
import CustomizedExamples from './Customized';
1413

1514
export default {
1615
LineChart: { examples: LineChartExamples, order: 1 },
@@ -25,5 +24,4 @@ export default {
2524
Tooltip: { examples: TooltipExamples, order: 9 },
2625
Legend: { examples: LegendExamples, order: 10 },
2726
ResponsiveContainer: { examples: ResponsiveContainerExamples, order: 11 },
28-
Customized: { examples: CustomizedExamples, order: 12 },
2927
};

src/locale/en-US.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const map = {
3434
api: 'API',
3535
examples: 'Examples',
3636
blog: 'Blog',
37-
storybook: 'Storybook (WIP)',
37+
storybook: 'Storybook',
3838
contract: 'Contact us by',
3939
},
4040
guide: {

0 commit comments

Comments
 (0)