Skip to content

fix(Charts - New): configurable animation and rendering improvements #501

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/charts/src/components/BarChart/BarChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ const BarChart: FC<BarChartProps> = forwardRef((props: BarChartProps, ref: Ref<a
loading,
dataset,
noLegend = false,
noAnimation = false,
onDataPointClick,
onLegendClick,
style,
Expand Down Expand Up @@ -224,6 +225,7 @@ const BarChart: FC<BarChartProps> = forwardRef((props: BarChartProps, ref: Ref<a
stroke={element.color ?? `var(--sapChart_OrderedColor_${(index % 11) + 1})`}
barSize={element.width}
onClick={onDataPointClickInternal}
isAnimationActive={noAnimation === false}
/>
);
})}
Expand Down
208 changes: 109 additions & 99 deletions packages/charts/src/components/BarChart/BarRechart.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ export const renderStory = () => {
return (
<BarChart
loading={boolean('loading', false)}
noLegend={boolean('noLegend', false)}
noAnimation={boolean('noAnimation', false)}
onDataPointClick={action('onDataPointClick')}
onLegendClick={action('onLegendClick')}
dataset={complexDataSet}
Expand Down Expand Up @@ -51,6 +53,9 @@ renderStory.story = {

export const renderStoryWithCustomColor = () => (
<BarChart
loading={boolean('loading', false)}
noLegend={boolean('noLegend', false)}
noAnimation={boolean('noAnimation', false)}
onDataPointClick={action('onDataPointClick')}
dimensions={[{ accessor: 'name' }]}
measures={[{ accessor: 'users', color: 'red' }]}
Expand All @@ -65,6 +70,9 @@ renderStoryWithCustomColor.story = {

export const withSecondaryDimension = () => (
<BarChart
loading={boolean('loading', false)}
noLegend={boolean('noLegend', false)}
noAnimation={boolean('noAnimation', false)}
onDataPointClick={action('onDataPointClick')}
dimensions={[{ accessor: 'name' }, { accessor: 'dimension' }]}
measures={[{ accessor: 'users', color: 'red' }]}
Expand All @@ -77,63 +85,65 @@ withSecondaryDimension.story = {
name: 'With secondary dimension'
};

export const renderLabelStory = () => {
return (
<BarChart
onDataPointClick={action('onDataPointClick')}
onLegendClick={action('onLegendClick')}
dimensions={[{ accessor: 'name' }]}
measures={[
{
accessor: 'users'
},
{
accessor: 'sessions'
},
{
accessor: 'volume'
}
]}
dataset={complexDataSet}
style={{ width: '95%', height: '40vh' }}
chartConfig={{
zoomingTool: true
}}
/>
);
};
export const renderLabelStory = () => (
<BarChart
loading={boolean('loading', false)}
noLegend={boolean('noLegend', false)}
noAnimation={boolean('noAnimation', false)}
onDataPointClick={action('onDataPointClick')}
onLegendClick={action('onLegendClick')}
dimensions={[{ accessor: 'name' }]}
measures={[
{
accessor: 'users'
},
{
accessor: 'sessions'
},
{
accessor: 'volume'
}
]}
dataset={complexDataSet}
style={{ width: '95%', height: '40vh' }}
chartConfig={{
zoomingTool: true
}}
/>
);

renderLabelStory.story = {
name: 'With data labels'
};

export const renderCustomDataLabelStory = () => {
return (
<BarChart
onDataPointClick={action('onDataPointClick')}
onLegendClick={action('onLegendClick')}
dataset={complexDataSet}
dimensions={[{ accessor: 'name', formatter: (element: string) => element.slice(0, 3) }]}
measures={[
{
accessor: 'users',
formatter: (element: number) => `${element / 10}`,
label: 'number of users'
},
{
accessor: 'sessions'
},
{
accessor: 'volume'
}
]}
style={{ width: '95%', height: '100vh' }}
chartConfig={{
zoomingTool: true
}}
/>
);
};
export const renderCustomDataLabelStory = () => (
<BarChart
loading={boolean('loading', false)}
noLegend={boolean('noLegend', false)}
noAnimation={boolean('noAnimation', false)}
onDataPointClick={action('onDataPointClick')}
onLegendClick={action('onLegendClick')}
dataset={complexDataSet}
dimensions={[{ accessor: 'name', formatter: (element: string) => element.slice(0, 3) }]}
measures={[
{
accessor: 'users',
formatter: (element: number) => `${element / 10}`,
label: 'number of users'
},
{
accessor: 'sessions'
},
{
accessor: 'volume'
}
]}
style={{ width: '95%', height: '100vh' }}
chartConfig={{
zoomingTool: true
}}
/>
);

renderCustomDataLabelStory.story = {
name: 'With formatter'
Expand All @@ -145,53 +155,53 @@ loadingPlaceholder.story = {
name: 'Loading placeholder'
};

export const withReferenceLineStory = () => {
return (
<BarChart
onDataPointClick={action('onDataPointClick')}
onLegendClick={action('onLegendClick')}
dataset={complexDataSet}
dimensions={[{ accessor: 'name' }]}
measures={[
{
accessor: 'users',
stackId: 'A'
},
{
accessor: 'sessions',
stackId: 'A'
},
{
accessor: 'volume'
}
]}
style={{
width: '95%',
height: '70vh',
'--sapChart_OrderedColor_1': '#0f828f',
'--sapChart_OrderedColor_2': '#5ac2ce',
'--sapChart_OrderedColor_3': '#03734d',
'--sapChart_OrderedColor_4': '#66c2a3',
'--sapChart_OrderedColor_5': '#3c6372',
'--sapChart_OrderedColor_6': '#adbcc3',
'--sapChart_OrderedColor_7': '#144b7f',
'--sapChart_OrderedColor_8': '#698caf',
'--sapChart_OrderedColor_9': '#d62f2f',
'--sapChart_OrderedColor_10': '#f8a6a6',
'--sapChart_OrderedColor_11': '#921473'
}}
noLegend={false}
loading
chartConfig={{
referenceLine: {
color: 'red',
label: 'MAX',
value: 650
}
}}
/>
);
};
export const withReferenceLineStory = () => (
<BarChart
loading={boolean('loading', false)}
noLegend={boolean('noLegend', false)}
noAnimation={boolean('noAnimation', false)}
onDataPointClick={action('onDataPointClick')}
onLegendClick={action('onLegendClick')}
dataset={complexDataSet}
dimensions={[{ accessor: 'name' }]}
measures={[
{
accessor: 'users',
stackId: 'A'
},
{
accessor: 'sessions',
stackId: 'A'
},
{
accessor: 'volume'
}
]}
style={{
width: '95%',
height: '70vh',
'--sapChart_OrderedColor_1': '#0f828f',
'--sapChart_OrderedColor_2': '#5ac2ce',
'--sapChart_OrderedColor_3': '#03734d',
'--sapChart_OrderedColor_4': '#66c2a3',
'--sapChart_OrderedColor_5': '#3c6372',
'--sapChart_OrderedColor_6': '#adbcc3',
'--sapChart_OrderedColor_7': '#144b7f',
'--sapChart_OrderedColor_8': '#698caf',
'--sapChart_OrderedColor_9': '#d62f2f',
'--sapChart_OrderedColor_10': '#f8a6a6',
'--sapChart_OrderedColor_11': '#921473'
}}
loading
chartConfig={{
referenceLine: {
color: 'red',
label: 'MAX',
value: 650
}
}}
/>
);

withReferenceLineStory.story = {
name: 'With reference line'
Expand Down
2 changes: 2 additions & 0 deletions packages/charts/src/components/ColumnChart/ColumnChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ const ColumnChart: FC<ColumnChartProps> = forwardRef((props: ColumnChartProps, r
loading,
dataset,
noLegend = false,
noAnimation = false,
onDataPointClick,
onLegendClick,
style,
Expand Down Expand Up @@ -235,6 +236,7 @@ const ColumnChart: FC<ColumnChartProps> = forwardRef((props: ColumnChartProps, r
stroke={element.color ?? `var(--sapChart_OrderedColor_${(index % 11) + 1})`}
barSize={element.width}
onClick={onDataPointClickInternal}
isAnimationActive={noAnimation === false}
/>
);
})}
Expand Down
Loading