-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Limit Donut legend to 50% of chart width
- Loading branch information
Showing
9 changed files
with
211 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ | |
width: 100%; | ||
border-collapse: separate; | ||
border-spacing: 0 10px; | ||
table-layout: fixed; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 112 additions & 0 deletions
112
packages/polaris-viz/src/components/DonutChart/stories/DonutChart.chromatic.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
import {storiesOf} from '@storybook/react'; | ||
import type {PropCombinations} from '../../../chromatic/types'; | ||
|
||
import { | ||
addWithPropsCombinations, | ||
renderCombinationSections, | ||
} from '../../../chromatic'; | ||
import {DonutChart} from '../'; | ||
import type {DonutChartProps} from '../DonutChart'; | ||
import {DEFAULT_DATA} from './data'; | ||
|
||
const stories = storiesOf('Chromatic/Components', module).addParameters({ | ||
docs: {page: null}, | ||
chromatic: {disableSnapshot: false}, | ||
}); | ||
|
||
const DEFAULT_PROPS: PropCombinations<DonutChartProps> = { | ||
data: [DEFAULT_DATA], | ||
comparisonMetric: [ | ||
{ | ||
metric: '6%', | ||
trend: 'positive', | ||
accessibilityLabel: 'trending up 6%', | ||
}, | ||
], | ||
legendPosition: ['left'], | ||
isAnimated: [false], | ||
}; | ||
|
||
const CHART_SIZE = {style: {width: 500, height: 300}}; | ||
|
||
const combinations = renderCombinationSections([ | ||
[ | ||
'Data', | ||
addWithPropsCombinations<DonutChartProps>( | ||
DonutChart, | ||
{ | ||
...DEFAULT_PROPS, | ||
}, | ||
CHART_SIZE, | ||
), | ||
], | ||
[ | ||
'Legend Position', | ||
addWithPropsCombinations( | ||
DonutChart, | ||
{ | ||
...DEFAULT_PROPS, | ||
legendPosition: [ | ||
'top-left', | ||
'top-right', | ||
'bottom-left', | ||
'bottom-right', | ||
'top', | ||
'right', | ||
'bottom', | ||
'left', | ||
], | ||
}, | ||
CHART_SIZE, | ||
), | ||
], | ||
[ | ||
'Truncated Legends', | ||
addWithPropsCombinations( | ||
DonutChart, | ||
{ | ||
...DEFAULT_PROPS, | ||
data: [ | ||
[ | ||
{ | ||
name: 'This is a long name that will get truncated', | ||
data: [{key: 'april - march', value: 50000}], | ||
metadata: { | ||
trend: { | ||
value: '5%', | ||
}, | ||
}, | ||
}, | ||
{ | ||
name: 'This is another long name that will get truncated', | ||
data: [{key: 'april - march', value: 250000}], | ||
metadata: { | ||
trend: { | ||
value: '50%', | ||
direction: 'downward', | ||
trend: 'negative', | ||
}, | ||
}, | ||
}, | ||
{ | ||
name: 'This is the last long name that will get truncated', | ||
data: [{key: 'april - march', value: 10000}], | ||
metadata: { | ||
trend: { | ||
value: '100%', | ||
direction: 'upward', | ||
trend: 'positive', | ||
}, | ||
}, | ||
}, | ||
], | ||
], | ||
legendPosition: ['left', 'right'], | ||
showLegendValues: [true, false], | ||
}, | ||
CHART_SIZE, | ||
), | ||
], | ||
]); | ||
|
||
stories.add('DonutChart', combinations); |
51 changes: 51 additions & 0 deletions
51
packages/polaris-viz/src/components/DonutChart/stories/TruncatedLegends.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import type {Story} from '@storybook/react'; | ||
|
||
export {META as default} from './meta'; | ||
|
||
import type {DonutChartProps} from '../../DonutChart'; | ||
|
||
import {DEFAULT_PROPS, Template} from './data'; | ||
|
||
export const TruncatedLegends: Story<DonutChartProps> = Template.bind({}); | ||
|
||
TruncatedLegends.args = { | ||
...DEFAULT_PROPS, | ||
showLegendValues: true, | ||
legendPosition: 'right', | ||
legendFullWidth: false, | ||
labelFormatter: (value) => `$${value}`, | ||
isAnimated: false, | ||
data: [ | ||
{ | ||
name: 'This is a long name that will get truncated', | ||
data: [{key: 'april - march', value: 50000}], | ||
metadata: { | ||
trend: { | ||
value: '5%', | ||
}, | ||
}, | ||
}, | ||
{ | ||
name: 'This is another long name that will get truncated', | ||
data: [{key: 'april - march', value: 250000}], | ||
metadata: { | ||
trend: { | ||
value: '50%', | ||
direction: 'downward', | ||
trend: 'negative', | ||
}, | ||
}, | ||
}, | ||
{ | ||
name: 'This is the last long name that will get truncated', | ||
data: [{key: 'april - march', value: 10000}], | ||
metadata: { | ||
trend: { | ||
value: '100%', | ||
direction: 'upward', | ||
trend: 'positive', | ||
}, | ||
}, | ||
}, | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters