Skip to content

[charts] Default bar chart x-axis scale type to band #17519

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
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: 1 addition & 1 deletion bug-reproductions/x-charts/src/demo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default function Demo() {
return (
<Box sx={{ height: 520, width: '100%' }}>
<BarChart
xAxis={[{ scaleType: 'band', data: ['group A', 'group B', 'group C'] }]}
xAxis={[{ data: ['group A', 'group B', 'group C'] }]}
series={[
{ label: 'first', data: [4, 3, 5] },
{ label: 'second', data: [1, 6, 3] },
Expand Down
2 changes: 1 addition & 1 deletion docs/data/charts/animation/JSAnimationCustomization.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default function JSAnimationCustomization() {
<Stack>
<BarChart
key={key}
xAxis={[{ scaleType: 'band', data: ['A', 'B', 'C'] }]}
xAxis={[{ data: ['A', 'B', 'C'] }]}
series={[
{
type: 'bar',
Expand Down
2 changes: 1 addition & 1 deletion docs/data/charts/animation/JSAnimationCustomization.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default function JSAnimationCustomization() {
<Stack>
<BarChart
key={key}
xAxis={[{ scaleType: 'band', data: ['A', 'B', 'C'] }]}
xAxis={[{ data: ['A', 'B', 'C'] }]}
series={[
{
type: 'bar',
Expand Down
2 changes: 1 addition & 1 deletion docs/data/charts/animation/JSDefaultAnimation.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default function JSDefaultAnimation() {
<Stack>
<BarChart
key={key}
xAxis={[{ scaleType: 'band', data: ['A', 'B', 'C'] }]}
xAxis={[{ data: ['A', 'B', 'C'] }]}
series={[
{
type: 'bar',
Expand Down
2 changes: 1 addition & 1 deletion docs/data/charts/animation/JSDefaultAnimation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default function JSDefaultAnimation() {
<Stack>
<BarChart
key={key}
xAxis={[{ scaleType: 'band', data: ['A', 'B', 'C'] }]}
xAxis={[{ data: ['A', 'B', 'C'] }]}
series={[
{
type: 'bar',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default function ReactSpringAnimationCustomization() {
<Stack>
<BarChart
key={key}
xAxis={[{ scaleType: 'band', data: ['A', 'B', 'C'] }]}
xAxis={[{ data: ['A', 'B', 'C'] }]}
series={[
{
type: 'bar',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default function ReactSpringAnimationCustomization() {
<Stack>
<BarChart
key={key}
xAxis={[{ scaleType: 'band', data: ['A', 'B', 'C'] }]}
xAxis={[{ data: ['A', 'B', 'C'] }]}
series={[
{
type: 'bar',
Expand Down
1 change: 0 additions & 1 deletion docs/data/charts/axis/AxisTextCustomization.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export default function AxisTextCustomization() {
dataset={dataset}
xAxis={[
{
scaleType: 'band',
dataKey: 'month',
label: 'months',
height: 60,
Expand Down
1 change: 0 additions & 1 deletion docs/data/charts/axis/AxisTextCustomization.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export default function AxisTextCustomization() {
dataset={dataset}
xAxis={[
{
scaleType: 'band',
dataKey: 'month',
label: 'months',
height: 60,
Expand Down
2 changes: 1 addition & 1 deletion docs/data/charts/axis/GridDemo.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default function GridDemo() {
return (
<BarChart
dataset={dataset}
xAxis={[{ scaleType: 'band', dataKey: 'month' }]}
xAxis={[{ dataKey: 'month' }]}
series={[{ dataKey: 'seoul', label: 'Seoul rainfall', valueFormatter }]}
grid={{ horizontal: true }}
sx={{
Expand Down
2 changes: 1 addition & 1 deletion docs/data/charts/axis/GridDemo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default function GridDemo() {
return (
<BarChart
dataset={dataset}
xAxis={[{ scaleType: 'band', dataKey: 'month' }]}
xAxis={[{ dataKey: 'month' }]}
series={[{ dataKey: 'seoul', label: 'Seoul rainfall', valueFormatter }]}
grid={{ horizontal: true }}
sx={{
Expand Down
2 changes: 1 addition & 1 deletion docs/data/charts/axis/GridDemo.tsx.preview
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<BarChart
dataset={dataset}
xAxis={[{ scaleType: 'band', dataKey: 'month' }]}
xAxis={[{ dataKey: 'month' }]}
series={[{ dataKey: 'seoul', label: 'Seoul rainfall', valueFormatter }]}
grid={{ horizontal: true }}
sx={{
Expand Down
2 changes: 1 addition & 1 deletion docs/data/charts/axis/HidingAxis.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default function HidingAxis() {
return (
<BarChart
series={[{ data: [1, 2, 3, 2, 1] }]}
xAxis={[{ scaleType: 'band', data: ['A', 'B', 'C', 'D', 'E'] }]}
xAxis={[{ data: ['A', 'B', 'C', 'D', 'E'] }]}
yAxis={[{ position: 'none' }]}
height={300}
width={300}
Expand Down
2 changes: 1 addition & 1 deletion docs/data/charts/axis/HidingAxis.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default function HidingAxis() {
return (
<BarChart
series={[{ data: [1, 2, 3, 2, 1] }]}
xAxis={[{ scaleType: 'band', data: ['A', 'B', 'C', 'D', 'E'] }]}
xAxis={[{ data: ['A', 'B', 'C', 'D', 'E'] }]}
yAxis={[{ position: 'none' }]}
height={300}
width={300}
Expand Down
2 changes: 1 addition & 1 deletion docs/data/charts/axis/HidingAxis.tsx.preview
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<BarChart
series={[{ data: [1, 2, 3, 2, 1] }]}
xAxis={[{ scaleType: 'band', data: ['A', 'B', 'C', 'D', 'E'] }]}
xAxis={[{ data: ['A', 'B', 'C', 'D', 'E'] }]}
yAxis={[{ position: 'none' }]}
height={300}
width={300}
Expand Down
2 changes: 1 addition & 1 deletion docs/data/charts/bar-demo/BarChartStackedBySign.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default function BarChartStackedBySign() {
{ data: pData, label: 'pv', id: 'pvId', stack: 'stack1' },
{ data: uData, label: 'uv', id: 'uvId', stack: 'stack1' },
]}
xAxis={[{ data: xLabels, scaleType: 'band' }]}
xAxis={[{ data: xLabels }]}
yAxis={[{ width: 60 }]}
/>
);
Expand Down
2 changes: 1 addition & 1 deletion docs/data/charts/bar-demo/BarChartStackedBySign.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default function BarChartStackedBySign() {
{ data: pData, label: 'pv', id: 'pvId', stack: 'stack1' },
{ data: uData, label: 'uv', id: 'uvId', stack: 'stack1' },
]}
xAxis={[{ data: xLabels, scaleType: 'band' }]}
xAxis={[{ data: xLabels }]}
yAxis={[{ width: 60 }]}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
{ data: pData, label: 'pv', id: 'pvId', stack: 'stack1' },
{ data: uData, label: 'uv', id: 'uvId', stack: 'stack1' },
]}
xAxis={[{ data: xLabels, scaleType: 'band' }]}
xAxis={[{ data: xLabels }]}
yAxis={[{ width: 60 }]}
/>
2 changes: 1 addition & 1 deletion docs/data/charts/bar-demo/BiaxialBarChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default function BiaxialBarChart() {
yAxisId: 'rightAxisId',
},
]}
xAxis={[{ data: xLabels, scaleType: 'band' }]}
xAxis={[{ data: xLabels }]}
yAxis={[
{ id: 'leftAxisId', width: 50 },
{ id: 'rightAxisId', position: 'right' },
Expand Down
2 changes: 1 addition & 1 deletion docs/data/charts/bar-demo/BiaxialBarChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default function BiaxialBarChart() {
yAxisId: 'rightAxisId',
},
]}
xAxis={[{ data: xLabels, scaleType: 'band' }]}
xAxis={[{ data: xLabels }]}
yAxis={[
{ id: 'leftAxisId', width: 50 },
{ id: 'rightAxisId', position: 'right' },
Expand Down
2 changes: 1 addition & 1 deletion docs/data/charts/bar-demo/MixedBarChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function MixedBarChart() {
{ data: amtData, label: 'amt' },
{ data: uData, label: 'uv', stack: 'stack1' },
]}
xAxis={[{ data: xLabels, scaleType: 'band' }]}
xAxis={[{ data: xLabels }]}
yAxis={[{ width: 50 }]}
/>
);
Expand Down
2 changes: 1 addition & 1 deletion docs/data/charts/bar-demo/MixedBarChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function MixedBarChart() {
{ data: amtData, label: 'amt' },
{ data: uData, label: 'uv', stack: 'stack1' },
]}
xAxis={[{ data: xLabels, scaleType: 'band' }]}
xAxis={[{ data: xLabels }]}
yAxis={[{ width: 50 }]}
/>
);
Expand Down
2 changes: 1 addition & 1 deletion docs/data/charts/bar-demo/MixedBarChart.tsx.preview
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
{ data: amtData, label: 'amt' },
{ data: uData, label: 'uv', stack: 'stack1' },
]}
xAxis={[{ data: xLabels, scaleType: 'band' }]}
xAxis={[{ data: xLabels }]}
yAxis={[{ width: 50 }]}
/>
17 changes: 3 additions & 14 deletions docs/data/charts/bar-demo/PositiveAndNegativeBarChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,10 @@ export default function PositiveAndNegativeBarChart() {
<BarChart
height={300}
series={[
{
data: pData,
label: 'pv',
},
{
data: uData,
label: 'uv',
},
]}
xAxis={[
{
data: xLabels,
scaleType: 'band',
},
{ data: pData, label: 'pv' },
{ data: uData, label: 'uv' },
]}
xAxis={[{ data: xLabels }]}
yAxis={[{ width: 60, max: 10000 }]}
/>
);
Expand Down
17 changes: 3 additions & 14 deletions docs/data/charts/bar-demo/PositiveAndNegativeBarChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,10 @@ export default function PositiveAndNegativeBarChart() {
<BarChart
height={300}
series={[
{
data: pData,
label: 'pv',
},
{
data: uData,
label: 'uv',
},
]}
xAxis={[
{
data: xLabels,
scaleType: 'band',
},
{ data: pData, label: 'pv' },
{ data: uData, label: 'uv' },
]}
xAxis={[{ data: xLabels }]}
yAxis={[{ width: 60, max: 10000 }]}
/>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<BarChart
height={300}
series={[
{ data: pData, label: 'pv' },
{ data: uData, label: 'uv' },
]}
xAxis={[{ data: xLabels }]}
yAxis={[{ width: 60, max: 10000 }]}
/>
2 changes: 1 addition & 1 deletion docs/data/charts/bar-demo/SimpleBarChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default function SimpleBarChart() {
{ data: pData, label: 'pv', id: 'pvId' },
{ data: uData, label: 'uv', id: 'uvId' },
]}
xAxis={[{ data: xLabels, scaleType: 'band' }]}
xAxis={[{ data: xLabels }]}
yAxis={[{ width: 50 }]}
/>
);
Expand Down
2 changes: 1 addition & 1 deletion docs/data/charts/bar-demo/SimpleBarChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default function SimpleBarChart() {
{ data: pData, label: 'pv', id: 'pvId' },
{ data: uData, label: 'uv', id: 'uvId' },
]}
xAxis={[{ data: xLabels, scaleType: 'band' }]}
xAxis={[{ data: xLabels }]}
yAxis={[{ width: 50 }]}
/>
);
Expand Down
2 changes: 1 addition & 1 deletion docs/data/charts/bar-demo/SimpleBarChart.tsx.preview
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
{ data: pData, label: 'pv', id: 'pvId' },
{ data: uData, label: 'uv', id: 'uvId' },
]}
xAxis={[{ data: xLabels, scaleType: 'band' }]}
xAxis={[{ data: xLabels }]}
yAxis={[{ width: 50 }]}
/>
2 changes: 1 addition & 1 deletion docs/data/charts/bar-demo/StackedBarChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default function StackedBarChart() {
{ data: pData, label: 'pv', id: 'pvId', stack: 'total' },
{ data: uData, label: 'uv', id: 'uvId', stack: 'total' },
]}
xAxis={[{ data: xLabels, scaleType: 'band' }]}
xAxis={[{ data: xLabels }]}
yAxis={[{ width: 50 }]}
/>
);
Expand Down
2 changes: 1 addition & 1 deletion docs/data/charts/bar-demo/StackedBarChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default function StackedBarChart() {
{ data: pData, label: 'pv', id: 'pvId', stack: 'total' },
{ data: uData, label: 'uv', id: 'uvId', stack: 'total' },
]}
xAxis={[{ data: xLabels, scaleType: 'band' }]}
xAxis={[{ data: xLabels }]}
yAxis={[{ width: 50 }]}
/>
);
Expand Down
2 changes: 1 addition & 1 deletion docs/data/charts/bar-demo/StackedBarChart.tsx.preview
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
{ data: pData, label: 'pv', id: 'pvId', stack: 'total' },
{ data: uData, label: 'uv', id: 'uvId', stack: 'total' },
]}
xAxis={[{ data: xLabels, scaleType: 'band' }]}
xAxis={[{ data: xLabels }]}
yAxis={[{ width: 50 }]}
/>
2 changes: 1 addition & 1 deletion docs/data/charts/bars/BarClick.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const barChartsParams = {
},
},
],
xAxis: [{ data: ['0', '3', '6', '9', '12'], scaleType: 'band', id: 'axis1' }],
xAxis: [{ data: ['0', '3', '6', '9', '12'], id: 'axis1' }],
height: 400,
};

Expand Down
2 changes: 1 addition & 1 deletion docs/data/charts/bars/BarClick.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const barChartsParams = {
},
},
],
xAxis: [{ data: ['0', '3', '6', '9', '12'], scaleType: 'band', id: 'axis1' }],
xAxis: [{ data: ['0', '3', '6', '9', '12'], id: 'axis1' }],
height: 400,
} as const;

Expand Down
1 change: 0 additions & 1 deletion docs/data/charts/bars/BarGap.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export default function BarGap() {
height={300}
xAxis={[
{
scaleType: 'band',
dataKey: 'year',
categoryGapRatio: props.categoryGapRatio,
barGapRatio: props.barGapRatio,
Expand Down
1 change: 0 additions & 1 deletion docs/data/charts/bars/BarGap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export default function BarGap() {
height={300}
xAxis={[
{
scaleType: 'band',
dataKey: 'year',
categoryGapRatio: props.categoryGapRatio,
barGapRatio: props.barGapRatio,
Expand Down
2 changes: 1 addition & 1 deletion docs/data/charts/bars/BarLabel.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { BarChart } from '@mui/x-charts/BarChart';
export default function BarLabel() {
return (
<BarChart
xAxis={[{ scaleType: 'band', data: ['group A', 'group B', 'group C'] }]}
xAxis={[{ data: ['group A', 'group B', 'group C'] }]}
series={[{ data: [4, 3, 5] }, { data: [1, 6, 3] }, { data: [2, 5, 6] }]}
height={300}
barLabel="value"
Expand Down
2 changes: 1 addition & 1 deletion docs/data/charts/bars/BarLabel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { BarChart } from '@mui/x-charts/BarChart';
export default function BarLabel() {
return (
<BarChart
xAxis={[{ scaleType: 'band', data: ['group A', 'group B', 'group C'] }]}
xAxis={[{ data: ['group A', 'group B', 'group C'] }]}
series={[{ data: [4, 3, 5] }, { data: [1, 6, 3] }, { data: [2, 5, 6] }]}
height={300}
barLabel="value"
Expand Down
2 changes: 1 addition & 1 deletion docs/data/charts/bars/BarLabel.tsx.preview
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<BarChart
xAxis={[{ scaleType: 'band', data: ['group A', 'group B', 'group C'] }]}
xAxis={[{ data: ['group A', 'group B', 'group C'] }]}
series={[{ data: [4, 3, 5] }, { data: [1, 6, 3] }, { data: [2, 5, 6] }]}
height={300}
barLabel="value"
Expand Down
2 changes: 1 addition & 1 deletion docs/data/charts/bars/BarsDataset.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default function BarsDataset() {
return (
<BarChart
dataset={dataset}
xAxis={[{ scaleType: 'band', dataKey: 'month' }]}
xAxis={[{ dataKey: 'month' }]}
series={[
{ dataKey: 'london', label: 'London', valueFormatter },
{ dataKey: 'paris', label: 'Paris', valueFormatter },
Expand Down
2 changes: 1 addition & 1 deletion docs/data/charts/bars/BarsDataset.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default function BarsDataset() {
return (
<BarChart
dataset={dataset}
xAxis={[{ scaleType: 'band', dataKey: 'month' }]}
xAxis={[{ dataKey: 'month' }]}
series={[
{ dataKey: 'london', label: 'London', valueFormatter },
{ dataKey: 'paris', label: 'Paris', valueFormatter },
Expand Down
Loading