Skip to content
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

fix: columnchart disappearance columns issue #74

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ exports[`ColumnChart renders a column chart 1`] = `
class="ez-bar"
data-testid="ez-bar"
fill="red"
height="0"
height="200"
width="125"
x="31.25"
y="400"
y="200"
>
</rect>
<rect
Expand All @@ -40,10 +40,10 @@ exports[`ColumnChart renders a column chart 1`] = `
class="ez-bar"
data-testid="ez-bar"
fill="green"
height="200"
height="300"
width="125"
x="343.75"
y="200"
y="100"
>
</rect>
</g>
Expand Down Expand Up @@ -146,7 +146,7 @@ exports[`ColumnChart renders a column chart 1`] = `
transform="translate(0, 0) rotate(-90 0 0)"
x="-9"
>
50
0
</text>
</g>
<g
Expand All @@ -166,7 +166,7 @@ exports[`ColumnChart renders a column chart 1`] = `
transform="translate(0, 0) rotate(-90 0 0)"
x="-9"
>
55
10
</text>
</g>
<g
Expand All @@ -186,7 +186,7 @@ exports[`ColumnChart renders a column chart 1`] = `
transform="translate(0, 0) rotate(-90 0 0)"
x="-9"
>
60
20
</text>
</g>
<g
Expand All @@ -206,7 +206,7 @@ exports[`ColumnChart renders a column chart 1`] = `
transform="translate(0, 0) rotate(-90 0 0)"
x="-9"
>
65
30
</text>
</g>
<g
Expand All @@ -226,7 +226,7 @@ exports[`ColumnChart renders a column chart 1`] = `
transform="translate(0, 0) rotate(-90 0 0)"
x="-9"
>
70
40
</text>
</g>
<g
Expand All @@ -246,7 +246,7 @@ exports[`ColumnChart renders a column chart 1`] = `
transform="translate(0, 0) rotate(-90 0 0)"
x="-9"
>
75
50
</text>
</g>
<g
Expand All @@ -266,7 +266,7 @@ exports[`ColumnChart renders a column chart 1`] = `
transform="translate(0, 0) rotate(-90 0 0)"
x="-9"
>
80
60
</text>
</g>
<g
Expand All @@ -286,7 +286,7 @@ exports[`ColumnChart renders a column chart 1`] = `
transform="translate(0, 0) rotate(-90 0 0)"
x="-9"
>
85
70
</text>
</g>
<g
Expand All @@ -306,7 +306,7 @@ exports[`ColumnChart renders a column chart 1`] = `
transform="translate(0, 0) rotate(-90 0 0)"
x="-9"
>
90
80
</text>
</g>
<g
Expand All @@ -326,7 +326,7 @@ exports[`ColumnChart renders a column chart 1`] = `
transform="translate(0, 0) rotate(-90 0 0)"
x="-9"
>
95
90
</text>
</g>
<g
Expand Down
7 changes: 3 additions & 4 deletions packages/ez-react/src/recipes/column/ColumnChart.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ const LineColumnTemplate: Story<LineColumnChartProps> = (args) => {
);
};

// By passing using the Args format for exported stories, you can control the props for a component for reuse in a test
// https://storybook.js.org/docs/react/workflows/unit-testing
// By passing using the Args format for exported stories,
// you can control the props for a component for reuse in a test
// https://storybook.js.org/docs/vue/workflows/unit-testing
export const Default = DefaultTemplate.bind({});

const defaultArguments = {
Expand All @@ -50,7 +51,6 @@ const defaultArguments = {
yAxis: {
domainKey: 'value',
title: 'Count',
nice: 2,
},
data: rawData,
};
Expand All @@ -73,7 +73,6 @@ const lineColumnArguments = {
yLineAxis: {
domainKey: 'v',
title: 'Value',
nice: 2,
},
};

Expand Down
7 changes: 6 additions & 1 deletion packages/ez-react/src/recipes/column/ColumnChart.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { FC, SVGAttributes } from 'react';
import { ScaleBand, ScaleLinear } from 'eazychart-core/src';
import { getDomainByKeys, ScaleBand, ScaleLinear } from 'eazychart-core/src';
import {
AnimationOptions,
AxisConfig,
Expand Down Expand Up @@ -74,6 +74,10 @@ export const ColumnChart: FC<ColumnChartProps> = ({
xAxis.domainKey,
colors
);
const [, yAxisDomainMaxValue] = getDomainByKeys(
[yAxis.domainKey],
activeData
);

return (
<Chart
Expand All @@ -99,6 +103,7 @@ export const ColumnChart: FC<ColumnChartProps> = ({
direction: Direction.VERTICAL,
domainKey: yAxis.domainKey,
nice: yAxis.nice || 0,
domain: [0, yAxisDomainMaxValue],
},
}}
>
Expand Down
9 changes: 1 addition & 8 deletions packages/ez-vue/src/recipes/column/ColumnChart.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { Meta, Story } from '@storybook/vue';
import { baseChartArgTypes, ChartWrapper } from '@/lib/storybook-utils';
import {
animationOptions, colors, padding, rawData,
} from 'eazychart-dev/storybook/data';
import { colors, rawData } from 'eazychart-dev/storybook/data';
import ColumnChart from './ColumnChart';
import LineColumnChart from './LineColumnChart';

Expand Down Expand Up @@ -53,11 +51,7 @@ const defaultArguments = {
yAxis: {
domainKey: 'value',
title: 'Count',
nice: 2,
},
padding,
animationOptions,
isRTL: false,
data: rawData,
};

Expand All @@ -79,7 +73,6 @@ const lineColumnArguments = {
yLineAxis: {
domainKey: 'v',
title: 'Value',
nice: 2,
},
};

Expand Down
5 changes: 4 additions & 1 deletion packages/ez-vue/src/recipes/column/ColumnChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
Dimensions,
} from 'eazychart-core/src/types';
import { Prop } from 'vue-property-decorator';
import { ScaleBand, ScaleLinear } from 'eazychart-core/src';
import { getDomainByKeys, ScaleBand, ScaleLinear } from 'eazychart-core/src';
import Chart from '@/components/Chart';
import Axis from '@/components/scales/Axis';
import Legend from '@/components/addons/legend/Legend';
Expand Down Expand Up @@ -155,6 +155,8 @@ export default class ColumnChart extends mixins(ToggleDatumMixin) {
Tooltip: $scopedSlots.Tooltip,
};

const [, yAxisDomainMaxValue] = getDomainByKeys([yAxis.domainKey], activeData);

return (
<Chart
dimensions={dimensions}
Expand All @@ -178,6 +180,7 @@ export default class ColumnChart extends mixins(ToggleDatumMixin) {
direction: Direction.VERTICAL,
domainKey: yAxis.domainKey,
nice: yAxis.nice || 0,
domain: [0, yAxisDomainMaxValue],
},
}}
>
Expand Down