Skip to content

Commit

Permalink
feat(mark): group animation options (#4695)
Browse files Browse the repository at this point in the history
  • Loading branch information
pearmini authored and Aarebecca committed Mar 1, 2023
1 parent eb22f92 commit 9c437c7
Show file tree
Hide file tree
Showing 60 changed files with 147 additions and 140 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function alphabetIntervalNonAnimateEnter(): G2Spec {
color: 'steelblue',
},
animate: {
enterType: null,
enter: false,
},
};
}
Expand Down
4 changes: 3 additions & 1 deletion __tests__/plots/animation/alphabet-interval-scale-in-y.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ export function alphabetIntervalScaleInY(): G2Spec {
color: 'steelblue',
},
animate: {
enterDuration: 1000,
enter: {
duration: 1000,
},
},
};
}
Expand Down
4 changes: 3 additions & 1 deletion __tests__/plots/animation/deaths-rose-stack-enter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ export function deathsRoseStackEnter(): G2Spec {
},
legend: { color: { layout: { justifyContent: 'flex-start' } } },
animate: {
enterType: 'waveIn',
enter: {
type: 'waveIn',
},
},
};
}
Expand Down
6 changes: 4 additions & 2 deletions __tests__/plots/animation/doughnut-purchases-line-path-in.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ export function doughnutPurchasesLinePathIn(): G2Spec {
gradientColor: 'start',
},
animate: {
enterType: 'pathIn',
enterDuration: 3000,
enter: {
type: 'pathIn',
duration: 3000,
},
},
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ export function fruitsIntervalStackEnterColorX(): G2Spec {
enterDuration: 1000,
},
animate: {
enterDuration: 600,
enter: {
duration: 600,
},
},
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ export function fruitsIntervalStackEnterColor(): G2Spec {
enterDuration: 1000,
},
animate: {
enterDuration: 900,
enter: {
duration: 900,
},
},
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ export function fruitsIntervalStackEnterDefaults(): G2Spec {
enterDuration: 1000,
},
animate: {
enterDuration: 1000,
enter: {
duration: 1000,
},
},
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ export function fruitsIntervalStackEnterXColor(): G2Spec {
enterDuration: 1000,
},
animate: {
enterDuration: 900,
enter: {
duration: 900,
},
},
};
}
Expand Down
4 changes: 3 additions & 1 deletion __tests__/plots/animation/os-area-stack-enter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ export function osAreaStackEnter(): G2Spec {
shape: 'smooth',
},
animate: {
enterType: 'growInX',
enter: {
type: 'growInX',
},
},
};
}
Expand Down
8 changes: 6 additions & 2 deletions __tests__/plots/animation/polio-point-stack-enter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ export function polioPointStackEnter(): G2Spec {
fill: '#666',
},
animate: {
enterDelay: 5000,
enter: {
delay: 5000,
},
},
},
{
Expand All @@ -70,7 +72,9 @@ export function polioPointStackEnter(): G2Spec {
dy: 30,
},
animate: {
enterDelay: 5400,
enter: {
delay: 5400,
},
},
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export async function populationIntervalRoseKeyframe(): Promise<G2Spec> {
startAngle: -Math.PI / 2,
},
transform: [{ type: 'groupX', y: 'sum' }],
animate: { enterType: 'waveIn' },
animate: { enter: { type: 'waveIn' } },
scale: { y: { type: 'sqrt' } },
encode: { x: 'year', y: 'people' },
axis: {
Expand All @@ -38,7 +38,7 @@ export async function populationIntervalRoseKeyframe(): Promise<G2Spec> {
},
coordinate: { type: 'polar', outerRadius: 0.85, startAngle: 0 },
transform: [{ type: 'groupX', y: 'sum' }],
animate: { enterType: 'waveIn' },
animate: { enter: { type: 'waveIn' } },
scale: { y: { type: 'sqrt' } },
encode: { x: 'year', y: 'people' },
axis: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export function population2015IntervalWaveInRadius(): G2Spec {
radius: 10,
},
animate: {
enterType: 'waveIn',
enter: { type: 'waveIn' },
},
},
],
Expand Down
2 changes: 1 addition & 1 deletion __tests__/plots/animation/profit-interval-range.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export async function profitIntervalRange(): Promise<G2Spec> {
data: [{ y: [0, 2000000] }],
encode: { y: 'y' },
animate: {
enterType: 'fadeIn',
enter: { type: 'fadeIn' },
},
},
],
Expand Down
4 changes: 2 additions & 2 deletions __tests__/plots/animation/sold-interval-pie-keyframe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function soldIntervalPieKeyframe(): G2Spec {
},
],
animate: {
enterType: 'waveIn',
enter: { type: 'waveIn' },
},
},
{
Expand All @@ -42,7 +42,7 @@ export function soldIntervalPieKeyframe(): G2Spec {
},
],
animate: {
enterType: 'waveIn',
enter: { type: 'waveIn' },
},
},
],
Expand Down
4 changes: 2 additions & 2 deletions __tests__/plots/animation/stocks-keyframe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const facetLine = (data) => ({
frame: false,
scale: { y: { zero: true, tickCount: 3 } },
animate: {
enterType: 'pathIn',
enter: { type: 'pathIn' },
},
},
],
Expand Down Expand Up @@ -59,7 +59,7 @@ const facetArea = (data) => ({
},
scale: { y: { facet: false, zero: true, tickCount: 3 } },
animate: {
exitType: 'fadeOut',
exit: { type: 'fadeOut' },
},
},
],
Expand Down
6 changes: 4 additions & 2 deletions __tests__/plots/static/population2015-interval-pie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ export function population2015IntervalPie(): G2Spec {
},
],
animate: {
enterType: 'waveIn',
enterDuration: 1000,
enter: {
type: 'waveIn',
duration: 1000,
},
},
};
}
Expand Down
4 changes: 2 additions & 2 deletions __tests__/unit/api/mark.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function setOptions(node) {
.scale('x', { domain: [0, 1] })
.transform({ type: 'stackY' })
.style('stroke', 'black')
.animate('enterType', 'scaleInX')
.animate('enter', { type: 'scaleInX' })
.attr('facet', true)
.attr('key', 'mark')
.attr('class', 'mark')
Expand Down Expand Up @@ -77,7 +77,7 @@ function getOptions() {
scale: { x: { domain: [0, 1] } },
transform: [{ type: 'stackY' }],
style: { stroke: 'black' },
animate: { enterType: 'scaleInX' },
animate: { enter: { type: 'scaleInX' } },
axis: { x: { tickCount: 10 } },
legend: { y: { title: 'hello' } },
slider: { x: {} },
Expand Down
2 changes: 1 addition & 1 deletion site/docs/api/animation/fadeIn.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ order: 1
chart
.interval()
/* ... */
.animate('enterType', 'fadeIn');
.animate('enter', { type: 'fadeIn' });
```
2 changes: 1 addition & 1 deletion site/docs/api/animation/fadeOut.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ order: 1
chart
.interval()
/* ... */
.animate('exitType', 'fadeOut');
.animate('exit', { type: 'fadeOut' });
```
2 changes: 1 addition & 1 deletion site/docs/api/animation/growInX.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ order: 1
chart
.interval()
/* ... */
.animate('enterType', 'growInX');
.animate('enter', { type: 'growInX' });
```
2 changes: 1 addition & 1 deletion site/docs/api/animation/growInY.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ order: 1
chart
.interval()
/* ... */
.animate('enterType', 'growInY');
.animate('enter', { type: 'growInY' });
```
2 changes: 1 addition & 1 deletion site/docs/api/animation/morphing.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ order: 1
chart
.area()
/* ... */
.animate('enterType', 'morphing');
.animate('enter', { type: 'morphing' });
```
2 changes: 1 addition & 1 deletion site/docs/api/animation/pathIn.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ order: 1
chart
.line()
/* ... */
.animate('enterType', 'pathIn');
.animate('enter', { type: 'pathIn' });
```
2 changes: 1 addition & 1 deletion site/docs/api/animation/scaleInX.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ order: 1
chart
.interval()
/* ... */
.animate('enterType', 'scaleInX');
.animate('enter', { type: 'scaleInX' });
```
2 changes: 1 addition & 1 deletion site/docs/api/animation/scaleInY.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ order: 1
chart
.interval()
/* ... */
.animate('enterType', 'scaleInY');
.animate('enter', { type: 'scaleInY' });
```
2 changes: 1 addition & 1 deletion site/docs/api/animation/scaleOutX.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ order: 1
chart
.interval()
/* ... */
.animate('exitType', 'scaleOutX');
.animate('exit', { type: 'scaleOutX' });
```
2 changes: 1 addition & 1 deletion site/docs/api/animation/scaleOutY.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ order: 1
chart
.interval()
/* ... */
.animate('exitType', 'scaleOutY');
.animate('exit', { type: 'scaleOutY' });
```
2 changes: 1 addition & 1 deletion site/docs/api/animation/waveIn.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ order: 1
chart
.interval()
/* ... */
.animate('enterType', 'waveIn');
.animate('enter', { type: 'waveIn' });
```
2 changes: 1 addition & 1 deletion site/docs/api/animation/zoomIn.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ order: 1
chart
.interval()
/* ... */
.animate('enterType', 'zoomIn');
.animate('enter', { type: 'zoomIn' });
```
2 changes: 1 addition & 1 deletion site/docs/api/animation/zoomOut.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ order: 1
chart
.interval()
/* ... */
.animate('exitType', 'zoomOut');
.animate('exit', { type: 'zoomOut' });
```
6 changes: 4 additions & 2 deletions site/docs/manual/animation.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ chart
.encode('x', 'genre')
.encode('y', 'sold')
.encode('color', 'genre')
.animate('enterType', 'scaleInY') // 指定入场动画的类型
.animate('enterDuration', 1000); // 指定入场动画的执行时间
.animate('enter', {
type: 'scaleInY', // 指定入场动画的类型
duration: 1000, // 指定入场动画的执行时间
});
```

## 动画编码
Expand Down
2 changes: 1 addition & 1 deletion site/docs/manual/more/use-in-framework.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function renderBarChart(container) {
.encode('x', 'genre') // 编码 x 通道
.encode('y', 'sold') // 编码 y 通道
.encode('key', 'genre') // 指定 key
.animate('updateDuration', 300); // 指定更新动画的时间
.animate('update', { duration: 300 }); // 指定更新动画的时间

// 渲染可视化
chart.render();
Expand Down
6 changes: 2 additions & 4 deletions site/examples/animation/general/demo/fade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ chart
.encode('x', 'genre')
.encode('y', 'sold')
.encode('color', 'genre')
.animate('enterType', 'fadeIn')
.animate('enterDuration', 1000)
.animate('exitType', 'fadeOut')
.animate('exitDuration', 2000);
.animate('enter', { type: 'fadeIn', duration: 1000 })
.animate('exit', { type: 'fadeOut', duration: 2000 });

chart.render();
3 changes: 1 addition & 2 deletions site/examples/animation/general/demo/path-in.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ chart
})
.encode('x', 'date')
.encode('y', 'close')
.animate('enterType', 'pathIn')
.animate('enterDuration', 1000);
.animate('enter', { type: 'pathIn', duration: 1000 });

chart.render();
6 changes: 2 additions & 4 deletions site/examples/animation/general/demo/scale-x.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ chart
.encode('x', 'genre')
.encode('y', 'sold')
.encode('color', 'genre')
.animate('enterType', 'scaleInX')
.animate('enterDuration', 1000)
.animate('exitType', 'scaleOutX')
.animate('exitDuration', 2000);
.animate('enter', { type: 'scaleInX', duration: 1000 })
.animate('exit', { type: 'scaleOutX', duration: 2000 });

chart.render();
6 changes: 2 additions & 4 deletions site/examples/animation/general/demo/scale-y.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ chart
.encode('x', 'genre')
.encode('y', 'sold')
.encode('color', 'genre')
.animate('enterType', 'scaleInY')
.animate('enterDuration', 1000)
.animate('exitType', 'scaleOutY')
.animate('exitDuration', 2000);
.animate('enter', { type: 'scaleInY', duration: 1000 })
.animate('exit', { type: 'scaleOutY', duration: 2000 });

chart.render();
3 changes: 1 addition & 2 deletions site/examples/animation/general/demo/wave-in.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ chart
.transform({ type: 'stackY' })
.encode('color', 'genre')
.encode('y', 'sold')
.animate('enterType', 'waveIn')
.animate('enterDuration', 1000);
.animate('enter', { type: 'waveIn', duration: 1000 });

chart.render();
3 changes: 1 addition & 2 deletions site/examples/animation/general/demo/zoom-in.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ chart
.scale('y', { domain: [65, 90] })
.style('fillOpacity', 0.3)
.style('lineWidth', 1)
.animate('enterType', 'zoomIn')
.animate('enterDuration', 1000);
.animate('enter', { type: 'zoomIn', duration: 1000 });

chart.render();
Loading

0 comments on commit 9c437c7

Please sign in to comment.