forked from mui/mui-x
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[charts] Allow zoom on Y axis and add zoom options to configure zoomi…
…ng behaviour (mui#13726) Signed-off-by: Jose C Quintas Jr <juniorquintas@gmail.com> Co-authored-by: Alexandre Fauquette <45398769+alexfauquette@users.noreply.github.com>
- Loading branch information
1 parent
a2e3423
commit aab47d1
Showing
38 changed files
with
867 additions
and
257 deletions.
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
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
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 |
---|---|---|
@@ -1,15 +1,12 @@ | ||
<BarChartPro | ||
width={600} | ||
height={300} | ||
zoom | ||
series={[ | ||
xAxis={[ | ||
{ | ||
label: 'Series A', | ||
data: data.map((v) => v.y1), | ||
}, | ||
{ | ||
label: 'Series B', | ||
data: data.map((v) => v.y2), | ||
scaleType: 'band', | ||
data: data.map((v, i) => i), | ||
zoom: true, | ||
}, | ||
]} | ||
series={series} | ||
/> |
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
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
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 |
---|---|---|
@@ -1,15 +1,12 @@ | ||
<LineChartPro | ||
width={600} | ||
height={300} | ||
zoom | ||
series={[ | ||
xAxis={[ | ||
{ | ||
label: 'Series A', | ||
data: data.map((v) => v.y1), | ||
}, | ||
{ | ||
label: 'Series B', | ||
data: data.map((v) => v.y2), | ||
zoom: true, | ||
scaleType: 'point', | ||
data: data.map((v, i) => i), | ||
}, | ||
]} | ||
series={series} | ||
/> |
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,151 @@ | ||
import * as React from 'react'; | ||
import { BarChartPro } from '@mui/x-charts-pro/BarChartPro'; | ||
import ChartsUsageDemo from 'docsx/src/modules/components/ChartsUsageDemo'; | ||
|
||
const knobs = [ | ||
{ | ||
propName: 'panning', | ||
knob: 'switch', | ||
defaultValue: true, | ||
}, | ||
{ | ||
propName: 'minStart', | ||
knob: 'number', | ||
defaultValue: 0, | ||
step: 1, | ||
min: 0, | ||
max: 50, | ||
}, | ||
{ | ||
propName: 'maxEnd', | ||
knob: 'number', | ||
defaultValue: 100, | ||
step: 1, | ||
min: 50, | ||
max: 100, | ||
}, | ||
{ | ||
propName: 'minSpan', | ||
knob: 'number', | ||
defaultValue: 10, | ||
step: 1, | ||
min: 0, | ||
max: 100, | ||
}, | ||
{ | ||
propName: 'maxSpan', | ||
knob: 'number', | ||
defaultValue: 100, | ||
step: 1, | ||
min: 0, | ||
max: 100, | ||
}, | ||
{ | ||
propName: 'step', | ||
knob: 'number', | ||
defaultValue: 5, | ||
step: 1, | ||
min: 1, | ||
max: 100, | ||
}, | ||
]; | ||
|
||
export default function ZoomOptionsNoSnap() { | ||
return ( | ||
<ChartsUsageDemo | ||
componentName="Zoom Options demo" | ||
data={knobs} | ||
renderDemo={(props) => ( | ||
<div style={{ width: '100%', margin: 4 }}> | ||
<BarChartPro | ||
height={300} | ||
xAxis={[ | ||
{ | ||
scaleType: 'band', | ||
data: data.map((v, i) => i), | ||
zoom: props, | ||
}, | ||
]} | ||
series={series} | ||
/> | ||
</div> | ||
)} | ||
getCode={({ props }) => { | ||
return [ | ||
`import { BarChart } from '@mui/x-charts/BarChart';`, | ||
'', | ||
`<BarChart`, | ||
` // ...`, | ||
` xAxis={[`, | ||
` {`, | ||
` // ...`, | ||
` zoom: {`, | ||
` minStart: ${props.minStart},`, | ||
` maxEnd: ${props.maxEnd},`, | ||
` minSpan: ${props.minSpan},`, | ||
` maxSpan: ${props.maxSpan},`, | ||
` step: ${props.step},`, | ||
` panning: ${props.panning},`, | ||
` }`, | ||
` }`, | ||
` ]}`, | ||
'/>', | ||
].join('\n'); | ||
}} | ||
/> | ||
); | ||
} | ||
|
||
const data = [ | ||
{ | ||
y1: 443.28, | ||
y2: 153.9, | ||
}, | ||
{ | ||
y1: 110.5, | ||
y2: 217.8, | ||
}, | ||
{ | ||
y1: 175.23, | ||
y2: 286.32, | ||
}, | ||
{ | ||
y1: 195.97, | ||
y2: 325.12, | ||
}, | ||
{ | ||
y1: 351.77, | ||
y2: 144.58, | ||
}, | ||
{ | ||
y1: 43.253, | ||
y2: 146.51, | ||
}, | ||
{ | ||
y1: 376.34, | ||
y2: 309.69, | ||
}, | ||
{ | ||
y1: 31.514, | ||
y2: 236.38, | ||
}, | ||
{ | ||
y1: 231.31, | ||
y2: 440.72, | ||
}, | ||
{ | ||
y1: 108.04, | ||
y2: 20.29, | ||
}, | ||
]; | ||
|
||
const series = [ | ||
{ | ||
label: 'Series A', | ||
data: data.map((v) => v.y1), | ||
}, | ||
{ | ||
label: 'Series B', | ||
data: data.map((v) => v.y2), | ||
}, | ||
]; |
Oops, something went wrong.