-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[charts-pro] Add tapAndDrag
zoom gesture
#19727
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
Changes from 31 commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
705d8c2
initial tap and pan draft
JCQuintas 93d453c
rename
JCQuintas 655d76f
improves
JCQuintas 4afbcf4
add test
JCQuintas 9ac7adc
instruction
JCQuintas 9ee14b3
simplify
JCQuintas 1ee4f57
remove run
JCQuintas ab3f52a
fix tests
JCQuintas 04273f6
add behavioru
JCQuintas d48f320
use composed behavior
JCQuintas 88e78d5
fix
JCQuintas e832e52
proper names and fixes
JCQuintas b8f93d5
fix updating
JCQuintas 654b6cc
add docs
JCQuintas c38d394
scripts
JCQuintas 800958b
fix
JCQuintas 39202ee
titles
JCQuintas a307c1c
tests
JCQuintas 5fe74fa
Merge branch 'master' into tap-and-pan
JCQuintas 5439beb
fix tests
JCQuintas 9277f9d
Merge commit 'fd427c347301d5c0de5532dcf20d9680e4a919df' into tap-and-pan
JCQuintas 4e610e7
fixes
JCQuintas 91a9ca9
desc
JCQuintas 2f60355
remove margin
JCQuintas 678094c
fix touchAction
JCQuintas 21d1832
Merge commit 'ce0fddc3bfe994423437ebc58ba60dd1fc659e5d' into tap-and-pan
JCQuintas aae46a6
Merge branch 'master' into tap-and-pan
JCQuintas ad43a12
add fix and test case for deltaY issue
JCQuintas 2d0bbc7
fix ios issue
JCQuintas 3b8cbca
remove redundant style change
JCQuintas 83088fa
Merge branch 'master' into tap-and-pan
JCQuintas b7d138d
replace binding
JCQuintas d29af54
remove unused
JCQuintas 463800e
Merge branch 'master' into tap-and-pan
JCQuintas df4916a
fix ts node
JCQuintas fcf5386
func
JCQuintas 3ac336e
handle return outside
JCQuintas d45201a
decrease timeout
JCQuintas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
169 changes: 169 additions & 0 deletions
169
docs/data/charts/zoom-and-pan/ZoomAndPanInteractions.js
This file contains hidden or 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,169 @@ | ||
import * as React from 'react'; | ||
import { ScatterChartPro } from '@mui/x-charts-pro/ScatterChartPro'; | ||
import ChartsUsageDemo from 'docsx/src/modules/components/ChartsUsageDemo'; | ||
|
||
const knobs = { | ||
// Zoom interactions | ||
wheel: { | ||
displayName: 'Wheel', | ||
knob: 'switch', | ||
defaultValue: true, | ||
}, | ||
pinch: { | ||
displayName: 'Pinch', | ||
knob: 'switch', | ||
defaultValue: true, | ||
}, | ||
tapAndDrag: { | ||
displayName: 'Tap and drag', | ||
knob: 'switch', | ||
defaultValue: false, | ||
}, | ||
// Pan interactions | ||
drag: { | ||
displayName: 'Drag', | ||
knob: 'switch', | ||
defaultValue: true, | ||
}, | ||
}; | ||
|
||
export default function ZoomAndPanInteractions() { | ||
return ( | ||
<ChartsUsageDemo | ||
componentName="Zoom and Pan Interactions demo" | ||
data={knobs} | ||
renderDemo={(props) => { | ||
// Build zoom interactions array | ||
const zoomInteractions = []; | ||
if (props.wheel) { | ||
zoomInteractions.push('wheel'); | ||
} | ||
if (props.pinch) { | ||
zoomInteractions.push('pinch'); | ||
} | ||
if (props.tapAndDrag) { | ||
zoomInteractions.push('tapAndDrag'); | ||
} | ||
|
||
// Build pan interactions array | ||
const panInteractions = []; | ||
if (props.drag) { | ||
panInteractions.push('drag'); | ||
} | ||
|
||
const zoomInteractionConfig = { | ||
zoom: zoomInteractions, | ||
pan: panInteractions, | ||
}; | ||
|
||
return ( | ||
<div style={{ width: '100%' }}> | ||
<ScatterChartPro | ||
height={300} | ||
xAxis={[ | ||
{ | ||
data: data.map((v, i) => i), | ||
zoom: true, | ||
}, | ||
]} | ||
yAxis={[ | ||
{ | ||
zoom: true, | ||
width: 40, | ||
}, | ||
]} | ||
series={series} | ||
zoomInteractionConfig={zoomInteractionConfig} | ||
/> | ||
</div> | ||
); | ||
}} | ||
getCode={({ props }) => { | ||
// Build zoom interactions array for code generation | ||
const zoomInteractions = []; | ||
if (props.wheel) { | ||
zoomInteractions.push('wheel'); | ||
} | ||
if (props.pinch) { | ||
zoomInteractions.push('pinch'); | ||
} | ||
if (props.tapAndDrag) { | ||
zoomInteractions.push('tapAndDrag'); | ||
} | ||
|
||
// Build pan interactions array | ||
const panInteractions = []; | ||
if (props.drag) { | ||
panInteractions.push('drag'); | ||
} | ||
|
||
const zoomConfig = | ||
zoomInteractions.length > 0 | ||
? `["${zoomInteractions.join('", "')}"]` | ||
: '[]'; | ||
const panConfig = | ||
panInteractions.length > 0 ? `["${panInteractions.join('", "')}"]` : '[]'; | ||
|
||
return `import { ScatterChartPro } from '@mui/x-charts-pro/ScatterChartPro'; | ||
|
||
<ScatterChartPro | ||
// ... | ||
zoomInteractionConfig={{ | ||
zoom: ${zoomConfig}, | ||
pan: ${panConfig}, | ||
}} | ||
/>`; | ||
}} | ||
/> | ||
); | ||
} | ||
|
||
const data = [ | ||
{ | ||
x: 443, | ||
y: 153, | ||
}, | ||
{ | ||
x: 110, | ||
y: 217, | ||
}, | ||
{ | ||
x: 175, | ||
y: 286, | ||
}, | ||
{ | ||
x: 195, | ||
y: 325, | ||
}, | ||
{ | ||
x: 351, | ||
y: 144, | ||
}, | ||
{ | ||
x: 43, | ||
y: 146, | ||
}, | ||
{ | ||
x: 376, | ||
y: 309, | ||
}, | ||
{ | ||
x: 31, | ||
y: 236, | ||
}, | ||
{ | ||
x: 231, | ||
y: 440, | ||
}, | ||
{ | ||
x: 108, | ||
y: 20, | ||
}, | ||
]; | ||
|
||
const series = [ | ||
{ | ||
label: 'Series A', | ||
data, | ||
}, | ||
]; |
170 changes: 170 additions & 0 deletions
170
docs/data/charts/zoom-and-pan/ZoomAndPanInteractions.tsx
This file contains hidden or 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,170 @@ | ||
import * as React from 'react'; | ||
import { ScatterChartPro } from '@mui/x-charts-pro/ScatterChartPro'; | ||
import ChartsUsageDemo from 'docsx/src/modules/components/ChartsUsageDemo'; | ||
|
||
const knobs = { | ||
// Zoom interactions | ||
wheel: { | ||
displayName: 'Wheel', | ||
knob: 'switch', | ||
defaultValue: true, | ||
}, | ||
pinch: { | ||
displayName: 'Pinch', | ||
knob: 'switch', | ||
defaultValue: true, | ||
}, | ||
tapAndDrag: { | ||
displayName: 'Tap and drag', | ||
knob: 'switch', | ||
defaultValue: false, | ||
}, | ||
|
||
// Pan interactions | ||
drag: { | ||
displayName: 'Drag', | ||
knob: 'switch', | ||
defaultValue: true, | ||
}, | ||
} as const; | ||
|
||
export default function ZoomAndPanInteractions() { | ||
return ( | ||
<ChartsUsageDemo | ||
componentName="Zoom and Pan Interactions demo" | ||
data={knobs} | ||
renderDemo={(props) => { | ||
// Build zoom interactions array | ||
const zoomInteractions: any[] = []; | ||
if (props.wheel) { | ||
zoomInteractions.push('wheel'); | ||
} | ||
if (props.pinch) { | ||
zoomInteractions.push('pinch'); | ||
} | ||
if (props.tapAndDrag) { | ||
zoomInteractions.push('tapAndDrag'); | ||
} | ||
|
||
// Build pan interactions array | ||
const panInteractions: any[] = []; | ||
if (props.drag) { | ||
panInteractions.push('drag'); | ||
} | ||
|
||
const zoomInteractionConfig = { | ||
zoom: zoomInteractions, | ||
pan: panInteractions, | ||
}; | ||
|
||
return ( | ||
<div style={{ width: '100%' }}> | ||
<ScatterChartPro | ||
height={300} | ||
xAxis={[ | ||
{ | ||
data: data.map((v, i) => i), | ||
zoom: true, | ||
}, | ||
]} | ||
yAxis={[ | ||
{ | ||
zoom: true, | ||
width: 40, | ||
}, | ||
]} | ||
series={series} | ||
zoomInteractionConfig={zoomInteractionConfig} | ||
/> | ||
</div> | ||
); | ||
}} | ||
getCode={({ props }) => { | ||
// Build zoom interactions array for code generation | ||
const zoomInteractions: any[] = []; | ||
if (props.wheel) { | ||
zoomInteractions.push('wheel'); | ||
} | ||
if (props.pinch) { | ||
zoomInteractions.push('pinch'); | ||
} | ||
if (props.tapAndDrag) { | ||
zoomInteractions.push('tapAndDrag'); | ||
} | ||
|
||
// Build pan interactions array | ||
const panInteractions: any[] = []; | ||
if (props.drag) { | ||
panInteractions.push('drag'); | ||
} | ||
|
||
const zoomConfig = | ||
zoomInteractions.length > 0 | ||
? `["${zoomInteractions.join('", "')}"]` | ||
: '[]'; | ||
const panConfig = | ||
panInteractions.length > 0 ? `["${panInteractions.join('", "')}"]` : '[]'; | ||
|
||
return `import { ScatterChartPro } from '@mui/x-charts-pro/ScatterChartPro'; | ||
|
||
<ScatterChartPro | ||
// ... | ||
zoomInteractionConfig={{ | ||
zoom: ${zoomConfig}, | ||
pan: ${panConfig}, | ||
}} | ||
/>`; | ||
}} | ||
/> | ||
); | ||
} | ||
|
||
const data = [ | ||
{ | ||
x: 443, | ||
y: 153, | ||
}, | ||
{ | ||
x: 110, | ||
y: 217, | ||
}, | ||
{ | ||
x: 175, | ||
y: 286, | ||
}, | ||
{ | ||
x: 195, | ||
y: 325, | ||
}, | ||
{ | ||
x: 351, | ||
y: 144, | ||
}, | ||
{ | ||
x: 43, | ||
y: 146, | ||
}, | ||
{ | ||
x: 376, | ||
y: 309, | ||
}, | ||
{ | ||
x: 31, | ||
y: 236, | ||
}, | ||
{ | ||
x: 231, | ||
y: 440, | ||
}, | ||
{ | ||
x: 108, | ||
y: 20, | ||
}, | ||
]; | ||
|
||
const series = [ | ||
{ | ||
label: 'Series A', | ||
data, | ||
}, | ||
]; |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.