-
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(interaction): support continuous legend filter (#5356)
- Loading branch information
Showing
46 changed files
with
228 additions
and
80 deletions.
There are no files selected for viewing
Binary file added
BIN
+23.6 KB
__tests__/integration/snapshots/interaction/commits-point-legend-filter/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
+109 Bytes
(100%)
...__/integration/snapshots/interaction/settle-weather-cell-brush-filter/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
+109 Bytes
(100%)
...__/integration/snapshots/interaction/settle-weather-cell-brush-filter/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
+20.2 KB
__tests__/integration/snapshots/interaction/settle-weather-legend-filter/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
+21.6 KB
__tests__/integration/snapshots/interaction/settle-weather-legend-filter/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 modified
BIN
+34 Bytes
(100%)
__tests__/integration/snapshots/interaction/unemployment-choropleth/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
+426 Bytes
(100%)
__tests__/integration/snapshots/static/aaplLineMissingDataTrial.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
+148 Bytes
(100%)
__tests__/integration/snapshots/static/barleyLineTrail.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
+242 Bytes
(100%)
__tests__/integration/snapshots/static/bodyPointScatterPlot.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
+213 Bytes
(100%)
__tests__/integration/snapshots/static/bodyPointScatterPlotOpacity.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
+236 Bytes
(100%)
__tests__/integration/snapshots/static/bodyPointScatterPlotSizeOpacity.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
+52 Bytes
(100%)
__tests__/integration/snapshots/static/cars3LineParallelHorizontal.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
+957 Bytes
(100%)
__tests__/integration/snapshots/static/cars3LineRadar.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
+721 Bytes
(100%)
__tests__/integration/snapshots/static/commitsPointGrouped.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
+55 Bytes
(100%)
__tests__/integration/snapshots/static/commitsPointGroupedConstant.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
+1.13 KB
(100%)
__tests__/integration/snapshots/static/commitsPointGroupedLegendFlexCenter.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
+1.12 KB
(100%)
__tests__/integration/snapshots/static/commitsPointGroupedLegendFlexRight.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
+740 Bytes
(100%)
__tests__/integration/snapshots/static/commitsPointGroupedLegendIndependent.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
+758 Bytes
(100%)
__tests__/integration/snapshots/static/commitsPointGroupedLegendPositionBottom.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
+239 Bytes
(100%)
__tests__/integration/snapshots/static/commitsPointGroupedLegendPositionLeft.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
+223 Bytes
(100%)
__tests__/integration/snapshots/static/commitsPointGroupedLegendPositionRight.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
-698 Bytes
(99%)
..._/integration/snapshots/static/commitsPointGroupedLegendPositionRightLength.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
-4 Bytes
(100%)
__tests__/integration/snapshots/static/countriesBubbleLegendSize.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
+23 Bytes
(100%)
__tests__/integration/snapshots/static/disastersPointBubble.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
+112 Bytes
(100%)
__tests__/integration/snapshots/static/disastersPointBubbleLegendRight.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
+101 Bytes
(100%)
__tests__/integration/snapshots/static/haleChoroplethWorld.png
Oops, something went wrong.
Binary file modified
BIN
+331 Bytes
(100%)
__tests__/integration/snapshots/static/moviesPointBin.png
Oops, something went wrong.
Oops, something went wrong.
Binary file modified
BIN
-36 Bytes
(100%)
__tests__/integration/snapshots/static/moviesRectBinOpacity.png
Oops, something went wrong.
Binary file modified
BIN
-5 Bytes
(100%)
__tests__/integration/snapshots/static/question8IntervalRadialGradientColor.png
Oops, something went wrong.
Binary file modified
BIN
+87 Bytes
(100%)
__tests__/integration/snapshots/static/salaryHeatmapScaleLinear.png
Oops, something went wrong.
Binary file modified
BIN
-95 Bytes
(100%)
__tests__/integration/snapshots/static/settleWeatherCellGrouped.png
Oops, something went wrong.
Binary file modified
BIN
+105 Bytes
(100%)
__tests__/integration/snapshots/static/settleWeatherCellLineXY.png
Oops, something went wrong.
Binary file modified
BIN
+304 Bytes
(100%)
__tests__/integration/snapshots/static/stocksLineSeriesGradient.png
Oops, something went wrong.
Binary file modified
BIN
+31 Bytes
(100%)
__tests__/integration/snapshots/static/unemploymentChoropleth.png
Oops, something went wrong.
Binary file modified
BIN
-734 Bytes
(100%)
__tests__/integration/snapshots/static/vaccinesCellScaleRelation.png
Oops, something went wrong.
Binary file modified
BIN
-1.11 KB
(99%)
...integration/snapshots/static/vaccinesCellScaleRelationAutoPaddingTickFilter.png
Oops, something went wrong.
54 changes: 54 additions & 0 deletions
54
__tests__/plots/interaction/commits-point-legend-filter.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,54 @@ | ||
import { G2Spec } from '../../../src'; | ||
import { CONTINUOUS_LEGEND_CLASS_NAME } from '../../../src/interaction/legendFilter'; | ||
|
||
export function commitsPointLegendFilter(): G2Spec { | ||
return { | ||
type: 'point', | ||
height: 300, | ||
inset: 10, | ||
padding: 'auto', | ||
frame: true, | ||
data: { | ||
type: 'fetch', | ||
value: 'data/commits.csv', | ||
}, | ||
encode: { | ||
x: (d) => d.time.getUTCHours(), | ||
y: (d) => d.time.getUTCDay(), | ||
size: 'count', | ||
shape: 'point', | ||
color: 'count', | ||
}, | ||
transform: [ | ||
{ type: 'group', size: 'sum', color: 'sum' }, | ||
{ type: 'sortY' }, | ||
], | ||
scale: { | ||
y: { type: 'point' }, | ||
x: { tickCount: 24 }, | ||
color: { palette: 'rdBu' }, | ||
}, | ||
axis: { | ||
x: { title: 'time (hours)' }, | ||
y: { title: 'time (day)', grid: true }, | ||
}, | ||
}; | ||
} | ||
|
||
export function dispatchValueChange(legend, values) { | ||
legend.setSelection(...values); | ||
} | ||
|
||
commitsPointLegendFilter.steps = ({ canvas }) => { | ||
const { document } = canvas; | ||
const [legend] = document.getElementsByClassName( | ||
CONTINUOUS_LEGEND_CLASS_NAME, | ||
); | ||
return [ | ||
{ | ||
changeState: () => { | ||
dispatchValueChange(legend, [20, 60]); | ||
}, | ||
}, | ||
]; | ||
}; |
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
45 changes: 45 additions & 0 deletions
45
__tests__/plots/interaction/seattle-weather-legend-filter.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,45 @@ | ||
import { G2Spec } from '../../../src'; | ||
import { CONTINUOUS_LEGEND_CLASS_NAME } from '../../../src/interaction/legendFilter'; | ||
import { dispatchValueChange } from './commits-point-legend-filter'; | ||
|
||
export function settleWeatherLegendFilter(): G2Spec { | ||
return { | ||
type: 'cell', | ||
height: 330, | ||
data: { | ||
type: 'fetch', | ||
value: 'data/seattle-weather.csv', | ||
}, | ||
encode: { | ||
x: (d) => new Date(d.date).getUTCDate(), | ||
y: (d) => new Date(d.date).getUTCMonth(), | ||
color: 'temp_max', | ||
}, | ||
transform: [{ type: 'group', color: 'max' }], | ||
scale: { | ||
x: { compare: (a, b) => +a - +b }, | ||
y: { compare: (a, b) => +a - +b }, | ||
}, | ||
legend: { color: { layout: { justifyContent: 'flex-start' } } }, | ||
style: { inset: 0.5 }, | ||
}; | ||
} | ||
|
||
settleWeatherLegendFilter.steps = ({ canvas }) => { | ||
const { document } = canvas; | ||
const [legend] = document.getElementsByClassName( | ||
CONTINUOUS_LEGEND_CLASS_NAME, | ||
); | ||
return [ | ||
{ | ||
changeState: () => { | ||
dispatchValueChange(legend, [10, 30]); | ||
}, | ||
}, | ||
{ | ||
changeState: () => { | ||
dispatchValueChange(legend, [5, 36.4]); | ||
}, | ||
}, | ||
]; | ||
}; |
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
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
Oops, something went wrong.