Skip to content

Commit 73467c9

Browse files
committedJan 1, 2022
feat(chord): update stories
1 parent 90210e4 commit 73467c9

File tree

3 files changed

+21
-12
lines changed

3 files changed

+21
-12
lines changed
 

‎packages/chord/stories/chord.stories.js ‎packages/chord/stories/chord.stories.tsx

+16-9
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
import { storiesOf } from '@storybook/react'
22
import { generateChordData } from '@nivo/generators'
33
import { TableTooltip, BasicTooltip, Chip } from '@nivo/tooltip'
4-
import { Chord } from '../src'
4+
// @ts-ignore
5+
import { Chord, ArcDatum, ArcTooltipComponentProps, RibbonTooltipComponentProps } from '../src'
6+
7+
const generateData = (size: number) => {
8+
const { matrix, keys } = generateChordData({ size })
9+
10+
return { data: matrix, keys }
11+
}
512

613
const commonProperties = {
714
width: 900,
815
height: 500,
916
margin: { top: 60, right: 80, bottom: 60, left: 80 },
10-
...generateChordData({ size: 7 }),
17+
...generateData(7),
1118
xPadding: 0.2,
1219
}
1320

@@ -17,9 +24,9 @@ stories.add('default', () => <Chord {...commonProperties} />)
1724

1825
stories.add('radial labels', () => <Chord {...commonProperties} labelRotation={-90} />)
1926

20-
const customLabel = d => `${d.id} [${d.value}]`
27+
const customLabel = (arc: Omit<ArcDatum, 'label' | 'color'>) => `${arc.id} [${arc.value}]`
2128
stories.add('custom labels text', () => (
22-
<Chord {...commonProperties} {...generateChordData({ size: 5 })} label={customLabel} />
29+
<Chord {...commonProperties} {...generateData(5)} label={customLabel} />
2330
))
2431

2532
stories.add('angle padding', () => (
@@ -43,7 +50,7 @@ stories.add('alternative colors', () => (
4350
stories.add('putting labels inside arcs', () => (
4451
<Chord
4552
{...commonProperties}
46-
{...generateChordData({ size: 5 })}
53+
{...generateData(5)}
4754
padAngle={0.02}
4855
innerRadiusRatio={0.8}
4956
innerRadiusOffset={0.02}
@@ -55,7 +62,7 @@ stories.add('putting labels inside arcs', () => (
5562
stories.add('with formatted values', () => (
5663
<Chord
5764
{...commonProperties}
58-
{...generateChordData({ size: 5 })}
65+
{...generateData(5)}
5966
valueFormat={value =>
6067
`${Number(value).toLocaleString('ru-RU', {
6168
minimumFractionDigits: 2,
@@ -64,7 +71,7 @@ stories.add('with formatted values', () => (
6471
/>
6572
))
6673

67-
const ArcTooltip = ({ arc }) => (
74+
const ArcTooltip = ({ arc }: ArcTooltipComponentProps) => (
6875
<BasicTooltip
6976
id={`Custom arc tooltip, ${arc.label}`}
7077
value={arc.formattedValue}
@@ -73,7 +80,7 @@ const ArcTooltip = ({ arc }) => (
7380
/>
7481
)
7582

76-
const RibbonTooltip = ({ ribbon }) => (
83+
const RibbonTooltip = ({ ribbon }: RibbonTooltipComponentProps) => (
7784
<TableTooltip
7885
rows={[
7986
[
@@ -95,7 +102,7 @@ const RibbonTooltip = ({ ribbon }) => (
95102
stories.add('custom tooltips', () => (
96103
<Chord
97104
{...commonProperties}
98-
{...generateChordData({ size: 5 })}
105+
{...generateData(5)}
99106
arcTooltip={ArcTooltip}
100107
ribbonTooltip={RibbonTooltip}
101108
/>

‎website/src/data/components/chord/meta.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ Chord:
1212
- relational
1313
- svg
1414
- isomorphic
15-
stories: []
15+
stories:
16+
- label: Custom arc & ribbon tooltip
17+
link: chord--custom-tooltips
1618
description: |
1719
Chord diagram, uses [d3-chord](https://github.com/d3/d3-chord),
1820
see [this demo](https://observablehq.com/@d3/chord-diagram).

‎website/src/data/config.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
export default {
22
// local
33
// nivoApiUrl: 'http://localhost:3030/nivo',
4-
storybookUrl: 'http://localhost:6006/',
4+
// storybookUrl: 'http://localhost:6006/',
55

66
// production
77
nivoApiUrl: 'https://nivo-api.herokuapp.com/nivo',
8-
// storybookUrl: 'https://nivo.rocks/storybook/',
8+
storybookUrl: 'https://nivo.rocks/storybook/',
99
}

0 commit comments

Comments
 (0)
Please sign in to comment.