-
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(dimension): auto padding (#5046)
- Loading branch information
Showing
48 changed files
with
1,196 additions
and
61 deletions.
There are no files selected for viewing
Binary file added
BIN
+22.5 KB
__tests__/integration/snapshots/static/alphabetIntervalAutoPadding.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
+15.1 KB
__tests__/integration/snapshots/static/alphabetIntervalAutoPaddingCustom.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
+18.1 KB
__tests__/integration/snapshots/static/alphabetIntervalAutoPaddingD3Format.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.1 KB
__tests__/integration/snapshots/static/alphabetIntervalAutoPaddingMaxRatio.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
+16 KB
__tests__/integration/snapshots/static/alphabetIntervalAutoPaddingNoTitle.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
+22.3 KB
__tests__/integration/snapshots/static/alphabetIntervalAutoPaddingPosition.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
+24.1 KB
__tests__/integration/snapshots/static/alphabetIntervalAutoPaddingStyle.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
+14.7 KB
__tests__/integration/snapshots/static/browserLineAreaTrendingAutoPadding.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
+290 KB
__tests__/integration/snapshots/static/flarePointCirclePackCustomAutoPadding.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
+25.8 KB
__tests__/integration/snapshots/static/gdpIntervalFlexAutoPaddingRotate.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
+80.4 KB
...integration/snapshots/static/indicesLineChartScaleRelationsAutoPaddingRound.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
+35.7 KB
__tests__/integration/snapshots/static/marketIntervalMarimekkoAutoPaddingFlex.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
+5.73 KB
__tests__/integration/snapshots/static/mockPointLogTicksAutoPaddingTickCount.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
+22.1 KB
...s__/integration/snapshots/static/ordersLineMissingFieldAutoPaddingUndefined.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.9 KB
...sts__/integration/snapshots/static/peoplePointStackedAutoPaddingNumberLabel.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
+19.4 KB
...ation/snapshots/static/populationIntervalDivergingAutoPaddingUndefinedTitle.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
+273 KB
__tests__/integration/snapshots/static/tranLineMultiAxesAutoPaddingTickMethod.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
+147 KB
...integration/snapshots/static/vaccinesCellScaleRelationAutoPaddingTickFilter.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
+46.9 KB
__tests__/integration/snapshots/static/weatherLineMultiAxesAutoPadding.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
67 changes: 67 additions & 0 deletions
67
__tests__/plots/static/alphabet-interval-auto-padding-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,67 @@ | ||
import { Rect, Text } from '@antv/g'; | ||
import { G2Spec } from '../../../src'; | ||
|
||
export function alphabetIntervalAutoPaddingCustom(): G2Spec { | ||
return { | ||
type: 'interval', | ||
padding: 'auto', | ||
transform: [{ type: 'sortX', by: 'y', reverse: true }], | ||
data: { | ||
type: 'fetch', | ||
value: 'data/alphabet.csv', | ||
}, | ||
encode: { | ||
x: 'letter', | ||
y: 'frequency', | ||
color: 'steelblue', | ||
}, | ||
axis: { | ||
y: { | ||
labelFormatter: (d) => { | ||
const width = 60; | ||
const height = 15; | ||
const rect = new Rect({ | ||
style: { x: -width, y: -height / 2, height, width, fill: 'red' }, | ||
}); | ||
const text = new Text({ | ||
style: { | ||
x: width / 2, | ||
text: d + '', | ||
fontSize: 12, | ||
textBaseline: 'top', | ||
textAlign: 'center', | ||
}, | ||
}); | ||
rect.appendChild(text); | ||
return rect; | ||
}, | ||
}, | ||
x: { | ||
labelFormatter: (d) => { | ||
const width = 60; | ||
const height = 15; | ||
const rect = new Rect({ | ||
style: { x: 0, y: 0, height, width, fill: 'red' }, | ||
}); | ||
const text = new Text({ | ||
style: { | ||
x: width / 2, | ||
text: d + '', | ||
fontSize: 12, | ||
textBaseline: 'top', | ||
textAlign: 'center', | ||
}, | ||
}); | ||
rect.appendChild(text); | ||
return rect; | ||
}, | ||
}, | ||
}, | ||
viewStyle: { | ||
viewFill: '#4e79a7', | ||
plotFill: '#f28e2c', | ||
mainFill: '#e15759', | ||
contentFill: '#76b7b2', | ||
}, | ||
}; | ||
} |
27 changes: 27 additions & 0 deletions
27
__tests__/plots/static/alphabet-interval-auto-padding-d3-format.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,27 @@ | ||
import { G2Spec } from '../../../src'; | ||
|
||
export function alphabetIntervalAutoPaddingD3Format(): G2Spec { | ||
return { | ||
type: 'interval', | ||
padding: 'auto', | ||
transform: [{ type: 'sortX', by: 'y', reverse: true }], | ||
data: { | ||
type: 'fetch', | ||
value: 'data/alphabet.csv', | ||
}, | ||
encode: { | ||
x: 'letter', | ||
y: 'frequency', | ||
color: 'steelblue', | ||
}, | ||
axis: { | ||
y: { labelFormatter: '.0%' }, | ||
}, | ||
viewStyle: { | ||
viewFill: '#4e79a7', | ||
plotFill: '#f28e2c', | ||
mainFill: '#e15759', | ||
contentFill: '#76b7b2', | ||
}, | ||
}; | ||
} |
40 changes: 40 additions & 0 deletions
40
__tests__/plots/static/alphabet-interval-auto-padding-max-ratio.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,40 @@ | ||
import { G2Spec } from '../../../src'; | ||
|
||
function appendZero(count) { | ||
return Array.from({ length: count }, () => 0).join(''); | ||
} | ||
|
||
export function alphabetIntervalAutoPaddingMaxRatio(): G2Spec { | ||
return { | ||
type: 'interval', | ||
padding: 'auto', | ||
margin: 50, | ||
inset: 10, | ||
transform: [{ type: 'sortX', by: 'y', reverse: true }], | ||
data: { | ||
type: 'fetch', | ||
value: 'data/alphabet.csv', | ||
}, | ||
encode: { | ||
x: 'letter', | ||
y: 'frequency', | ||
color: 'steelblue', | ||
}, | ||
axis: { | ||
y: [ | ||
{ labelFormatter: (d) => d + appendZero(40) }, | ||
{ labelFormatter: (d) => appendZero(40) + d, position: 'right' }, | ||
], | ||
x: [ | ||
{ labelFormatter: (d) => appendZero(40) + d }, | ||
{ labelFormatter: (d) => d + appendZero(40), position: 'top' }, | ||
], | ||
}, | ||
viewStyle: { | ||
viewFill: '#4e79a7', | ||
plotFill: '#f28e2c', | ||
mainFill: '#e15759', | ||
contentFill: '#76b7b2', | ||
}, | ||
}; | ||
} |
28 changes: 28 additions & 0 deletions
28
__tests__/plots/static/alphabet-interval-auto-padding-no-title.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,28 @@ | ||
import { G2Spec } from '../../../src'; | ||
|
||
export function alphabetIntervalAutoPaddingNoTitle(): G2Spec { | ||
return { | ||
type: 'interval', | ||
padding: 'auto', | ||
transform: [{ type: 'sortX', by: 'y', reverse: true }], | ||
data: { | ||
type: 'fetch', | ||
value: 'data/alphabet.csv', | ||
}, | ||
encode: { | ||
x: 'letter', | ||
y: 'frequency', | ||
color: 'steelblue', | ||
}, | ||
axis: { | ||
y: { title: false }, | ||
x: { title: false }, | ||
}, | ||
viewStyle: { | ||
viewFill: '#4e79a7', | ||
plotFill: '#f28e2c', | ||
mainFill: '#e15759', | ||
contentFill: '#76b7b2', | ||
}, | ||
}; | ||
} |
28 changes: 28 additions & 0 deletions
28
__tests__/plots/static/alphabet-interval-auto-padding-position.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,28 @@ | ||
import { G2Spec } from '../../../src'; | ||
|
||
export function alphabetIntervalAutoPaddingPosition(): G2Spec { | ||
return { | ||
type: 'interval', | ||
padding: 'auto', | ||
transform: [{ type: 'sortX', by: 'y', reverse: true }], | ||
data: { | ||
type: 'fetch', | ||
value: 'data/alphabet.csv', | ||
}, | ||
encode: { | ||
x: 'letter', | ||
y: 'frequency', | ||
color: 'steelblue', | ||
}, | ||
axis: { | ||
y: { labelFormatter: (d) => d + '0000', position: 'right' }, | ||
x: { labelFormatter: (d) => d + '0000', position: 'top' }, | ||
}, | ||
viewStyle: { | ||
viewFill: '#4e79a7', | ||
plotFill: '#f28e2c', | ||
mainFill: '#e15759', | ||
contentFill: '#76b7b2', | ||
}, | ||
}; | ||
} |
34 changes: 34 additions & 0 deletions
34
__tests__/plots/static/alphabet-interval-auto-padding-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,34 @@ | ||
import { G2Spec } from '../../../src'; | ||
|
||
export function alphabetIntervalAutoPaddingStyle(): G2Spec { | ||
return { | ||
type: 'interval', | ||
padding: 'auto', | ||
transform: [{ type: 'sortX', by: 'y', reverse: true }], | ||
data: { | ||
type: 'fetch', | ||
value: 'data/alphabet.csv', | ||
}, | ||
encode: { | ||
x: 'letter', | ||
y: 'frequency', | ||
color: 'steelblue', | ||
}, | ||
axis: { | ||
y: { | ||
labelFormatter: (d) => d + '0000', | ||
style: { | ||
labelFontSize: (_, i) => 10 + i, | ||
labelFill: 'steelblue', | ||
}, | ||
}, | ||
x: { labelFormatter: (d) => d + '0000', style: { labelFontSize: 20 } }, | ||
}, | ||
viewStyle: { | ||
viewFill: '#4e79a7', | ||
plotFill: '#f28e2c', | ||
mainFill: '#e15759', | ||
contentFill: '#76b7b2', | ||
}, | ||
}; | ||
} |
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,28 @@ | ||
import { G2Spec } from '../../../src'; | ||
|
||
export function alphabetIntervalAutoPadding(): G2Spec { | ||
return { | ||
type: 'interval', | ||
padding: 'auto', | ||
transform: [{ type: 'sortX', by: 'y', reverse: true }], | ||
data: { | ||
type: 'fetch', | ||
value: 'data/alphabet.csv', | ||
}, | ||
encode: { | ||
x: 'letter', | ||
y: 'frequency', | ||
color: 'steelblue', | ||
}, | ||
axis: { | ||
y: { labelFormatter: (d) => d + '0000' }, | ||
x: { labelFormatter: (d) => d + '0000' }, | ||
}, | ||
viewStyle: { | ||
viewFill: '#4e79a7', | ||
plotFill: '#f28e2c', | ||
mainFill: '#e15759', | ||
contentFill: '#76b7b2', | ||
}, | ||
}; | ||
} |
46 changes: 46 additions & 0 deletions
46
__tests__/plots/static/browser-line-area-trending-auto-padding.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,46 @@ | ||
import { G2Spec } from '../../../src'; | ||
import { browser } from '../../data/browser'; | ||
|
||
export function browserLineAreaTrendingAutoPadding(): G2Spec { | ||
return { | ||
type: 'view', | ||
data: browser, | ||
padding: 'auto', | ||
style: { | ||
viewFill: '#4e79a7', | ||
plotFill: '#f28e2c', | ||
mainFill: '#e15759', | ||
contentFill: '#76b7b2', | ||
}, | ||
children: [ | ||
{ | ||
type: 'line', | ||
encode: { | ||
x: 'name', | ||
y: 'value', | ||
shape: 'hv', | ||
}, | ||
scale: { | ||
y: { domain: [0, 50] }, | ||
}, | ||
style: { | ||
opacity: 0.5, | ||
}, | ||
}, | ||
{ | ||
type: 'area', | ||
encode: { | ||
x: 'name', | ||
y: 'value', | ||
shape: 'hv', | ||
}, | ||
scale: { | ||
y: { domain: [0, 50] }, | ||
}, | ||
style: { | ||
opacity: 0.5, | ||
}, | ||
}, | ||
], | ||
}; | ||
} |
43 changes: 43 additions & 0 deletions
43
__tests__/plots/static/flare-point-circle-pack-custom-auto-padding.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,43 @@ | ||
import { interpolateHcl } from 'd3-interpolate'; | ||
import { G2Spec } from '../../../src'; | ||
|
||
export async function flarePointCirclePackCustomAutoPadding(): Promise<G2Spec> { | ||
return { | ||
type: 'view', | ||
padding: 'auto', | ||
width: 1000, | ||
height: 1000, | ||
style: { | ||
viewFill: '#4e79a7', | ||
plotFill: '#f28e2c', | ||
mainFill: '#e15759', | ||
contentFill: '#76b7b2', | ||
}, | ||
children: [ | ||
{ | ||
type: 'pack', | ||
layout: { padding: 5 }, | ||
data: { | ||
type: 'fetch', | ||
value: 'data/flare.json', | ||
}, | ||
encode: { | ||
value: 'value', | ||
color: 'depth', | ||
}, | ||
legend: { color: false }, | ||
scale: { | ||
color: { | ||
domain: [0, 5], | ||
range: ['hsl(152,80%,80%)', 'hsl(228,30%,40%)'], | ||
interpolate: interpolateHcl, | ||
}, | ||
}, | ||
style: { | ||
labelText: (d) => | ||
d.r >= 10 && d.height === 0 ? `${d.data.name}` : '', | ||
}, | ||
}, | ||
], | ||
}; | ||
} |
31 changes: 31 additions & 0 deletions
31
__tests__/plots/static/gdp-interval-flex-auto-padding-rotate.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,31 @@ | ||
import { G2Spec } from '../../../src'; | ||
|
||
export function gdpIntervalFlexAutoPaddingRotate(): G2Spec { | ||
return { | ||
type: 'interval', | ||
width: 1000, | ||
padding: 'auto', | ||
data: { | ||
type: 'fetch', | ||
value: 'data/gdp.csv', | ||
}, | ||
transform: [{ type: 'flexX', field: 'gdp' }], | ||
legend: { color: false }, | ||
encode: { | ||
x: 'country', | ||
y: 'value', | ||
color: 'country', | ||
}, | ||
axis: { | ||
x: { | ||
style: { labelTransform: 'rotate(90)' }, | ||
}, | ||
}, | ||
viewStyle: { | ||
viewFill: '#4e79a7', | ||
plotFill: '#f28e2c', | ||
mainFill: '#e15759', | ||
contentFill: '#76b7b2', | ||
}, | ||
}; | ||
} |
Oops, something went wrong.