-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(brush): support resize and custom
- Loading branch information
Showing
40 changed files
with
664 additions
and
44 deletions.
There are no files selected for viewing
Binary file modified
BIN
-1 KB
(99%)
...tegration/snapshots/interaction/indices-line-chart-facet-brush-shared/step0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+72.5 KB
.../integration/snapshots/interaction/penguins-point-brush-handle-custom/step0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+70.5 KB
.../integration/snapshots/interaction/penguins-point-brush-handle-custom/step1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+71.5 KB
...integration/snapshots/interaction/penguins-point-brush-handle-custom/step10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+69.4 KB
...integration/snapshots/interaction/penguins-point-brush-handle-custom/step11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+71.2 KB
.../integration/snapshots/interaction/penguins-point-brush-handle-custom/step2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+72 KB
.../integration/snapshots/interaction/penguins-point-brush-handle-custom/step3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+73.2 KB
.../integration/snapshots/interaction/penguins-point-brush-handle-custom/step4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+70.7 KB
.../integration/snapshots/interaction/penguins-point-brush-handle-custom/step5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+70.5 KB
.../integration/snapshots/interaction/penguins-point-brush-handle-custom/step6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+69.6 KB
.../integration/snapshots/interaction/penguins-point-brush-handle-custom/step7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+70.3 KB
.../integration/snapshots/interaction/penguins-point-brush-handle-custom/step8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+76 KB
.../integration/snapshots/interaction/penguins-point-brush-handle-custom/step9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+70.5 KB
..._/integration/snapshots/interaction/penguins-point-brush-handle-style/step0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-6 Bytes
(100%)
__tests__/integration/snapshots/interaction/penguins-point-brush-reverse/step0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-7 Bytes
(100%)
__tests__/integration/snapshots/interaction/penguins-point-brush-reverse/step1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+69.8 KB
__tests__/integration/snapshots/interaction/penguins-point-brush/step10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+70.3 KB
__tests__/integration/snapshots/interaction/penguins-point-brush/step11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+73.3 KB
__tests__/integration/snapshots/interaction/penguins-point-brush/step4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+71.1 KB
__tests__/integration/snapshots/interaction/penguins-point-brush/step5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+70 KB
__tests__/integration/snapshots/interaction/penguins-point-brush/step6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+71.3 KB
__tests__/integration/snapshots/interaction/penguins-point-brush/step7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+70.3 KB
__tests__/integration/snapshots/interaction/penguins-point-brush/step8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+73.5 KB
__tests__/integration/snapshots/interaction/penguins-point-brush/step9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
102 changes: 102 additions & 0 deletions
102
__tests__/plots/interaction/penguins-point-brush-handle-custom.ts
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,102 @@ | ||
import { G2Spec, PLOT_CLASS_NAME } from '../../../src'; | ||
import { brush, brushSteps } from './penguins-point-brush'; | ||
|
||
function createPathRender(path) { | ||
return (group, options, document) => { | ||
if (!group.handle) { | ||
const path = document.createElement('path'); | ||
group.handle = path; | ||
group.appendChild(group.handle); | ||
} | ||
const { handle } = group; | ||
const { width, height, ...rest } = options; | ||
if (width === undefined || height === undefined) return handle; | ||
handle.style.d = path(width, height); | ||
handle.attr(rest); | ||
return handle; | ||
}; | ||
} | ||
|
||
export function penguinsPointBrushHandleCustom(): G2Spec { | ||
return { | ||
type: 'point', | ||
data: { | ||
type: 'fetch', | ||
value: 'data/penguins.csv', | ||
}, | ||
encode: { | ||
color: 'species', | ||
x: 'culmen_length_mm', | ||
y: 'culmen_depth_mm', | ||
}, | ||
state: { | ||
inactive: { stroke: 'gray', opacity: 0.5 }, | ||
}, | ||
interaction: { | ||
brushHighlight: { | ||
maskHandleSize: 30, | ||
maskHandleNRender: createPathRender( | ||
(width, height) => | ||
`M0,${height / 2}L${width / 2},${-height / 2}L${width},${ | ||
height / 2 | ||
},Z`, | ||
), | ||
maskHandleERender: createPathRender( | ||
(width, height) => | ||
`M${width / 2},0L${(width * 3) / 2},${height / 2}L${ | ||
width / 2 | ||
},${height},Z`, | ||
), | ||
maskHandleSRender: createPathRender( | ||
(width, height) => | ||
`M0,${height / 2}L${width / 2},${(height / 2) * 3}L${width},${ | ||
height / 2 | ||
},Z`, | ||
), | ||
maskHandleWRender: createPathRender( | ||
(width, height) => | ||
`M${width / 2},0L${-width},${height / 2}L${width / 2},${height},Z`, | ||
), | ||
maskHandleNWRender: createPathRender( | ||
(width, height) => | ||
`M0,0L${width},${height / 2}L${width / 2},${height},Z`, | ||
), | ||
maskHandleNERender: createPathRender( | ||
(width, height) => | ||
`M0,${height / 2}L${width},0L${width / 2},${height},Z`, | ||
), | ||
maskHandleSERender: createPathRender( | ||
(width, height) => | ||
`M${width / 2},0L${width},${height}L0,${height / 2},Z`, | ||
), | ||
maskHandleSWRender: createPathRender( | ||
(width, height) => | ||
`M${width / 2},0L${width},${height / 2}L0,${height},Z`, | ||
), | ||
maskHandleNFill: 'blue', | ||
maskHandleEFill: 'red', | ||
maskHandleSFill: 'green', | ||
maskHandleWFill: 'yellow', | ||
maskHandleNWFill: 'black', | ||
maskHandleNEFill: 'steelblue', | ||
maskHandleSEFill: 'pink', | ||
maskHandleSWFill: 'orange', | ||
}, | ||
}, | ||
}; | ||
} | ||
|
||
penguinsPointBrushHandleCustom.steps = ({ canvas }) => { | ||
const { document } = canvas; | ||
const plot = document.getElementsByClassName(PLOT_CLASS_NAME)[0]; | ||
|
||
return [ | ||
{ | ||
changeState: () => { | ||
brush(plot, 100, 100, 200, 200); | ||
}, | ||
}, | ||
]; | ||
}; | ||
|
||
penguinsPointBrushHandleCustom.steps = brushSteps; |
44 changes: 44 additions & 0 deletions
44
__tests__/plots/interaction/penguins-point-brush-handle-style.ts
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,44 @@ | ||
import { G2Spec, PLOT_CLASS_NAME } from '../../../src'; | ||
import { brush } from './penguins-point-brush'; | ||
|
||
export function penguinsPointBrushHandleStyle(): G2Spec { | ||
return { | ||
type: 'point', | ||
data: { | ||
type: 'fetch', | ||
value: 'data/penguins.csv', | ||
}, | ||
encode: { | ||
color: 'species', | ||
x: 'culmen_length_mm', | ||
y: 'culmen_depth_mm', | ||
}, | ||
state: { | ||
inactive: { stroke: 'gray', opacity: 0.5 }, | ||
}, | ||
interaction: { | ||
brushHighlight: { | ||
maskHandleNFill: 'blue', | ||
maskHandleEFill: 'red', | ||
maskHandleSFill: 'green', | ||
maskHandleWFill: 'yellow', | ||
maskHandleNWFill: 'black', | ||
maskHandleNEFill: 'steelblue', | ||
maskHandleSEFill: 'pink', | ||
maskHandleSWFill: 'orange', | ||
}, | ||
}, | ||
}; | ||
} | ||
|
||
penguinsPointBrushHandleStyle.steps = ({ canvas }) => { | ||
const { document } = canvas; | ||
const plot = document.getElementsByClassName(PLOT_CLASS_NAME)[0]; | ||
return [ | ||
{ | ||
changeState: () => { | ||
brush(plot, 100, 100, 200, 200); | ||
}, | ||
}, | ||
]; | ||
}; |
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
Oops, something went wrong.