|
| 1 | +import { action } from '@storybook/addon-actions'; |
| 2 | +import { boolean } from '@storybook/addon-knobs'; |
| 3 | +import React from 'react'; |
| 4 | +import { ScatterChart } from '@ui5/webcomponents-react-charts/lib/ScatterChart'; |
| 5 | +import { scatterColorDataSet, scatterComplexDataSet } from '../../resources/DemoProps'; |
| 6 | + |
| 7 | +export default { |
| 8 | + title: 'Charts / ScatterChart', |
| 9 | + component: ScatterChart |
| 10 | +}; |
| 11 | + |
| 12 | +export const renderStory = () => ( |
| 13 | + <ScatterChart |
| 14 | + loading={boolean('loading', false)} |
| 15 | + noLegend={boolean('noLegend', false)} |
| 16 | + noAnimation={boolean('noAnimation', false)} |
| 17 | + onDataPointClick={action('onDataPointClick')} |
| 18 | + onLegendClick={action('onLegendClick')} |
| 19 | + dataset={scatterComplexDataSet} |
| 20 | + style={{ width: '100%' }} |
| 21 | + measures={[ |
| 22 | + { |
| 23 | + accessor: 'users', |
| 24 | + label: 'Users', |
| 25 | + axis: 'x' |
| 26 | + }, |
| 27 | + { |
| 28 | + accessor: 'sessions', |
| 29 | + label: 'Sessions', |
| 30 | + formatter: (val) => `${val}k`, |
| 31 | + axis: 'y' |
| 32 | + }, |
| 33 | + { |
| 34 | + accessor: 'volume', |
| 35 | + axis: 'z' |
| 36 | + } |
| 37 | + ]} |
| 38 | + /> |
| 39 | +); |
| 40 | + |
| 41 | +renderStory.story = { |
| 42 | + name: 'Default' |
| 43 | +}; |
| 44 | + |
| 45 | +export const renderStoryWithCustomColor = () => ( |
| 46 | + <ScatterChart |
| 47 | + loading={boolean('loading', false)} |
| 48 | + noLegend={boolean('noLegend', false)} |
| 49 | + noAnimation={boolean('noAnimation', false)} |
| 50 | + onDataPointClick={action('onDataPointClick')} |
| 51 | + dataset={scatterColorDataSet} |
| 52 | + style={{ width: '100%' }} |
| 53 | + measures={[ |
| 54 | + { |
| 55 | + accessor: 'users', |
| 56 | + label: 'Users', |
| 57 | + axis: 'x' |
| 58 | + }, |
| 59 | + { |
| 60 | + accessor: 'sessions', |
| 61 | + label: 'Sessions', |
| 62 | + axis: 'y' |
| 63 | + }, |
| 64 | + { |
| 65 | + accessor: 'volume', |
| 66 | + axis: 'z' |
| 67 | + } |
| 68 | + ]} |
| 69 | + /> |
| 70 | +); |
| 71 | + |
| 72 | +renderStoryWithCustomColor.story = { |
| 73 | + name: 'With custom color' |
| 74 | +}; |
| 75 | + |
| 76 | +export const loadingPlaceholder = () => <ScatterChart style={{ width: '100%' }} measures={[]} />; |
| 77 | + |
| 78 | +loadingPlaceholder.story = { |
| 79 | + name: 'Loading placeholder' |
| 80 | +}; |
0 commit comments