-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move 0 value labels to left when all value are negative
- Loading branch information
Showing
3 changed files
with
73 additions
and
1 deletion.
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
71 changes: 71 additions & 0 deletions
71
...ages/polaris-viz/src/components/SimpleBarChart/stories/playground/AllNegative.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,71 @@ | ||
import type {Story} from '@storybook/react'; | ||
|
||
import {SimpleBarChart, SimpleBarChartProps} from '../../../../components'; | ||
import {META} from '../meta'; | ||
import type {SimpleBarChartDataSeries} from '../../types'; | ||
import { | ||
DEFAULT_THEME_NAME, | ||
PolarisVizProvider, | ||
} from '@shopify/polaris-viz-core'; | ||
|
||
export default { | ||
...META, | ||
title: `${META.title}/Playground`, | ||
}; | ||
|
||
const DATA: SimpleBarChartDataSeries[] = [ | ||
{ | ||
name: '', | ||
data: [ | ||
{key: 'One', value: 0}, | ||
{key: 'Two', value: 0}, | ||
{key: 'Three', value: -22.1}, | ||
{key: 'Four', value: 0}, | ||
{key: 'Five', value: -17.5}, | ||
], | ||
metadata: { | ||
trends: { | ||
'0': {}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
name: '', | ||
data: [ | ||
{key: 'One', value: 0}, | ||
{key: 'Two', value: 0}, | ||
{key: 'Three', value: 0}, | ||
{key: 'Four', value: 0}, | ||
{key: 'Five', value: 0}, | ||
], | ||
}, | ||
]; | ||
|
||
const Template: Story<SimpleBarChartProps> = () => { | ||
const svgStyle = ` | ||
svg { | ||
background: rgba(0, 255, 0, 0.1); | ||
} | ||
`; | ||
|
||
return ( | ||
<div style={{height: 600, width: 800}}> | ||
<style>{svgStyle}</style> | ||
<PolarisVizProvider | ||
animated={{} as any} | ||
themes={{ | ||
[DEFAULT_THEME_NAME]: { | ||
chartContainer: { | ||
backgroundColor: 'rgba(255, 0, 0, 0.1)', | ||
padding: '20px', | ||
}, | ||
}, | ||
}} | ||
> | ||
<SimpleBarChart data={DATA} showLegend={false} /> | ||
</PolarisVizProvider> | ||
</div> | ||
); | ||
}; | ||
|
||
export const AllNegative = Template.bind({}); |
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