Skip to content

Commit

Permalink
feat(legend): optimize (#5202)
Browse files Browse the repository at this point in the history
  • Loading branch information
pearmini authored Jun 17, 2023
1 parent 952f151 commit fbebfc5
Show file tree
Hide file tree
Showing 281 changed files with 1,147 additions and 182 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 __tests__/integration/snapshots/api/chart-auto-fit/step0.png
Binary file modified __tests__/integration/snapshots/api/chart-auto-fit/step1.png
Binary file modified __tests__/integration/snapshots/api/chartChangeSize.png
Binary file modified __tests__/integration/snapshots/api/chartChangeSizePolar.png
Binary file modified __tests__/integration/snapshots/api/chartHOMMark.png
Binary file modified __tests__/integration/snapshots/api/chartOptionsChangeData.png
Binary file modified __tests__/integration/snapshots/api/chartOptionsCompositeMark.png
Binary file modified __tests__/integration/snapshots/api/chartRender.png
Binary file modified __tests__/integration/snapshots/api/markChangeData.png
Binary file modified __tests__/integration/snapshots/api/registerDataTransform.png
Binary file modified __tests__/integration/snapshots/api/registerShape.png
Binary file modified __tests__/integration/snapshots/api/viewFacetCircle.png
Binary file modified __tests__/integration/snapshots/static/alphabetIntervalFunnel.png
Binary file modified __tests__/integration/snapshots/static/alphabetIntervalPyramid.png
Binary file modified __tests__/integration/snapshots/static/athletesRectBin.png
Binary file modified __tests__/integration/snapshots/static/athletesRectBinX.png
Binary file modified __tests__/integration/snapshots/static/barleyLineTrail.png
Binary file modified __tests__/integration/snapshots/static/barleyPointFacetRectCol.png
Binary file modified __tests__/integration/snapshots/static/bodyPointScatterPlot.png
Binary file modified __tests__/integration/snapshots/static/cars2PointJitterY.png
Binary file modified __tests__/integration/snapshots/static/cars3LineRadar.png
Binary file modified __tests__/integration/snapshots/static/commitsPointGrouped.png
Binary file modified __tests__/integration/snapshots/static/disastersPointBubble.png
Binary file modified __tests__/integration/snapshots/static/fuelLineEncodePropagate.png
Binary file modified __tests__/integration/snapshots/static/haleChoroplethWorld.png
Binary file modified __tests__/integration/snapshots/static/housePricePointShapes.png
Binary file modified __tests__/integration/snapshots/static/irisPointShapes.png
Binary file modified __tests__/integration/snapshots/static/irisPointShapesDefaults.png
Binary file modified __tests__/integration/snapshots/static/marketIntervalMarimekko.png
Binary file modified __tests__/integration/snapshots/static/mockAxisY.png
Binary file modified __tests__/integration/snapshots/static/monthIntervalFacetCircle.png
Binary file modified __tests__/integration/snapshots/static/monthIntervalFacetRect.png
Binary file modified __tests__/integration/snapshots/static/moviesPointBin.png
Binary file modified __tests__/integration/snapshots/static/moviesRectBin.png
Binary file modified __tests__/integration/snapshots/static/moviesRectBinOpacity.png
Binary file modified __tests__/integration/snapshots/static/ordersLineMissingField.png
Binary file modified __tests__/integration/snapshots/static/penguinsBoxPlotGrouped.png
Binary file modified __tests__/integration/snapshots/static/penguinsPointFacetRect.png
Binary file modified __tests__/integration/snapshots/static/peoplePointStacked.png
Binary file modified __tests__/integration/snapshots/static/salaryHeatmapScaleLinear.png
Binary file modified __tests__/integration/snapshots/static/scoreByItemAreaRadar.png
Binary file modified __tests__/integration/snapshots/static/scoreByItemAreaRadarSize.png
Binary file modified __tests__/integration/snapshots/static/sepalBoxSimpleBox.png
Binary file modified __tests__/integration/snapshots/static/settleWeatherCellGrouped.png
Binary file modified __tests__/integration/snapshots/static/soldHOMMultiple.png
Binary file modified __tests__/integration/snapshots/static/soldIntervalCustomShape.png
Binary file modified __tests__/integration/snapshots/static/speciesDensityBasic.png
Binary file modified __tests__/integration/snapshots/static/speciesViolinBasic.png
Binary file modified __tests__/integration/snapshots/static/speciesViolinBasicPolar.png
Binary file modified __tests__/integration/snapshots/static/stateAgesIntervalGrouped.png
Binary file modified __tests__/integration/snapshots/static/stateAgesIntervalStacked.png
Binary file modified __tests__/integration/snapshots/static/stateAgesPointDotPlot.png
Binary file modified __tests__/integration/snapshots/static/stocksLineAggregateLabel.png
Binary file modified __tests__/integration/snapshots/static/stocksLineVarSize.png
Binary file modified __tests__/integration/snapshots/static/temperature1LineVarColor.png
Binary file modified __tests__/integration/snapshots/static/titanic2PointPack.png
Binary file modified __tests__/integration/snapshots/static/titanicPointPack.png
Binary file modified __tests__/integration/snapshots/static/titanicPointPackNested.png
Binary file modified __tests__/integration/snapshots/static/unemploymentChoropleth.png
Binary file modified __tests__/integration/snapshots/static/vennBasic.png
Binary file modified __tests__/integration/snapshots/static/vennHollow.png
Binary file modified __tests__/integration/snapshots/static/weatherLineMultiSlider.png
1 change: 1 addition & 0 deletions __tests__/plots/static/athletes-rect-bin-legend-style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { G2Spec } from '../../../src';
export function athletesRectBinLegendStyle(): G2Spec {
return {
type: 'rect',
padding: 'auto',
data: {
type: 'fetch',
value: 'data/athletes.csv',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { G2Spec } from '../../../src';
export function bodyPointScatterPlotSizeOpacity(): G2Spec {
return {
type: 'point',
padding: 'auto',
data: {
type: 'fetch',
value: 'data/body.json',
Expand Down
1 change: 1 addition & 0 deletions __tests__/plots/static/body-point-scatter-plot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { G2Spec } from '../../../src';
export function bodyPointScatterPlot(): G2Spec {
return {
type: 'point',
padding: 'auto',
data: {
type: 'fetch',
value: 'data/body.json',
Expand Down
41 changes: 41 additions & 0 deletions __tests__/plots/static/commits-point-grouped-legend-flex-center.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { G2Spec } from '../../../src';

export function commitsPointGroupedLegendFlexCenter(): 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' }, { type: 'sortY' }],
scale: {
y: { type: 'point' },
x: { tickCount: 24 },
color: { palette: 'rdBu' },
},
axis: {
x: { title: 'time (hours)' },
y: { title: 'time (day)', grid: true },
},
legend: {
color: { layout: { justifyContent: 'center' } },
},
viewStyle: {
viewFill: '#4e79a7',
plotFill: '#f28e2c',
mainFill: '#e15759',
contentFill: '#76b7b2',
},
};
}
41 changes: 41 additions & 0 deletions __tests__/plots/static/commits-point-grouped-legend-flex-right.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { G2Spec } from '../../../src';

export function commitsPointGroupedLegendFlexRight(): 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' }, { type: 'sortY' }],
scale: {
y: { type: 'point' },
x: { tickCount: 24 },
color: { palette: 'rdBu' },
},
axis: {
x: { title: 'time (hours)' },
y: { title: 'time (day)', grid: true },
},
legend: {
color: { layout: { justifyContent: 'flex-end' } },
},
viewStyle: {
viewFill: '#4e79a7',
plotFill: '#f28e2c',
mainFill: '#e15759',
contentFill: '#76b7b2',
},
};
}
39 changes: 39 additions & 0 deletions __tests__/plots/static/commits-point-grouped-legend-independent.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { G2Spec } from '../../../src';

export function commitsPointGroupedLegendIndependent(): 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' }, { type: 'sortY' }],
scale: {
y: { type: 'point' },
x: { tickCount: 24 },
color: { palette: 'rdBu' },
},
axis: {
x: { title: 'time (hours)' },
y: { title: 'time (day)', grid: true },
},
legend: { color: { group: 'independent' } },
viewStyle: {
viewFill: '#4e79a7',
plotFill: '#f28e2c',
mainFill: '#e15759',
contentFill: '#76b7b2',
},
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { G2Spec } from '../../../src';

export function commitsPointGroupedLegendPositionBottom(): 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' }, { type: 'sortY' }],
scale: {
y: { type: 'point' },
x: { tickCount: 24 },
color: { palette: 'rdBu' },
},
axis: {
x: { title: 'time (hours)' },
y: { title: 'time (day)', grid: true },
},
legend: {
color: { position: 'bottom', group: 'independent' },
size: { position: 'bottom' },
},
viewStyle: {
viewFill: '#4e79a7',
plotFill: '#f28e2c',
mainFill: '#e15759',
contentFill: '#76b7b2',
},
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { G2Spec } from '../../../src';

export function commitsPointGroupedLegendPositionLeft(): 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' }, { type: 'sortY' }],
scale: {
y: { type: 'point' },
x: { tickCount: 24 },
color: { palette: 'rdBu' },
},
axis: {
x: { title: 'time (hours)' },
y: { title: 'time (day)', grid: true },
},
legend: {
color: { position: 'left' },
size: { position: 'left' },
},
viewStyle: {
viewFill: '#4e79a7',
plotFill: '#f28e2c',
mainFill: '#e15759',
contentFill: '#76b7b2',
},
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { G2Spec } from '../../../src';

export function commitsPointGroupedLegendPositionRightLength(): 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' }, { type: 'sortY' }],
scale: {
y: { type: 'point' },
x: { tickCount: 24 },
color: { palette: 'rdBu' },
},
axis: {
x: { title: 'time (hours)' },
y: { title: 'time (day)', grid: true },
},
legend: {
color: { position: 'right', length: 100 },
size: { position: 'right', length: 100 },
},
viewStyle: {
viewFill: '#4e79a7',
plotFill: '#f28e2c',
mainFill: '#e15759',
contentFill: '#76b7b2',
},
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { G2Spec } from '../../../src';

export function commitsPointGroupedLegendPositionRight(): 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' }, { type: 'sortY' }],
scale: {
y: { type: 'point' },
x: { tickCount: 24 },
color: { palette: 'rdBu' },
},
axis: {
x: { title: 'time (hours)' },
y: { title: 'time (day)', grid: true },
},
legend: {
color: { position: 'right' },
size: { position: 'right' },
},
viewStyle: {
viewFill: '#4e79a7',
plotFill: '#f28e2c',
mainFill: '#e15759',
contentFill: '#76b7b2',
},
};
}
32 changes: 18 additions & 14 deletions __tests__/plots/static/commits-point-grouped.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,34 @@ export function commitsPointGrouped(): G2Spec {
type: 'point',
height: 300,
inset: 10,
padding: 'auto',
frame: true,
data: {
type: 'fetch',
value: 'data/commits.csv',
},
axis: {
x: { title: 'time (hours)' },
y: { title: 'time (day)', grid: true },
},
legend: { size: false },
scale: {
y: { type: 'point' },
x: { tickCount: 24 },
color: {
palette: 'rdBu',
},
},
transform: [{ type: 'group', size: 'sum' }, { type: 'sortY' }],
encode: {
x: (d) => d.time.getUTCHours(),
y: (d) => d.time.getUTCDay(),
size: 'count',
shape: 'point',
color: 'count',
},
frame: true,
transform: [{ type: 'group', size: 'sum' }, { type: 'sortY' }],
scale: {
y: { type: 'point' },
x: { tickCount: 24 },
color: { palette: 'rdBu' },
},
axis: {
x: { title: 'time (hours)' },
y: { title: 'time (day)', grid: true },
},
// viewStyle: {
// viewFill: '#4e79a7',
// plotFill: '#f28e2c',
// mainFill: '#e15759',
// contentFill: '#76b7b2',
// },
};
}
Loading

0 comments on commit fbebfc5

Please sign in to comment.