提交 780f7872 编写于 作者: L lang

Effect configuration

上级 67edaf12
...@@ -26,6 +26,16 @@ define(function (require) { ...@@ -26,6 +26,16 @@ define(function (require) {
// When to show the effect, option: 'render'|'emphasis' // When to show the effect, option: 'render'|'emphasis'
showEffectOn: 'render', showEffectOn: 'render',
// Period of effect
effectPeriod: 4000,
// Ripple effect config
rippleEffect: {
// Scale of ripple
scale: 2.5,
// Brush type can be fill or stroke
brushType: 'fill'
},
// Cartesian coordinate system // Cartesian coordinate system
xAxisIndex: 0, xAxisIndex: 0,
......
...@@ -44,13 +44,13 @@ define(function (require) { ...@@ -44,13 +44,13 @@ define(function (require) {
this.childAt(1).removeAll(); this.childAt(1).removeAll();
}; };
effectSymbolProto.startEffectAnimation = function () { effectSymbolProto.startEffectAnimation = function (period, brushType, rippleScale) {
var symbolType = this._symbolType; var symbolType = this._symbolType;
var color = this._color; var color = this._color;
var rippleGroup = this.childAt(1); var rippleGroup = this.childAt(1);
var randomOffset = -Math.random() * 5000; var randomOffset = -Math.random() * period;
for (var i = 0; i < EFFECT_RIPPLE_NUMBER; i++) { for (var i = 0; i < EFFECT_RIPPLE_NUMBER; i++) {
var ripplePath = symbolUtil.createSymbol( var ripplePath = symbolUtil.createSymbol(
...@@ -58,23 +58,24 @@ define(function (require) { ...@@ -58,23 +58,24 @@ define(function (require) {
); );
ripplePath.attr({ ripplePath.attr({
style: { style: {
stroke: null, stroke: brushType === 'stroke' ? color : null,
fill: color fill: brushType === 'fill' ? color : null,
strokeNoScale: true
}, },
z2: 99, z2: 99,
scale: [1, 1] scale: [1, 1]
}); });
var delay = -i / EFFECT_RIPPLE_NUMBER * 5000 + randomOffset; var delay = -i / EFFECT_RIPPLE_NUMBER * period + randomOffset;
// TODO Configurable period // TODO Configurable period
ripplePath.animate('', true) ripplePath.animate('', true)
.when(5000, { .when(period, {
scale: [3, 3] scale: [rippleScale, rippleScale]
}) })
.delay(delay) .delay(delay)
.start(); .start();
ripplePath.animateStyle(true) ripplePath.animateStyle(true)
.when(5000, { .when(period, {
opacity: 0 opacity: 0
}) })
.delay(delay) .delay(delay)
...@@ -109,6 +110,7 @@ define(function (require) { ...@@ -109,6 +110,7 @@ define(function (require) {
this.childAt(0).updateData(data, idx); this.childAt(0).updateData(data, idx);
var rippleGroup = this.childAt(1); var rippleGroup = this.childAt(1);
var itemModel = data.getItemModel(idx);
var symbolType = data.getItemVisual(idx, 'symbol'); var symbolType = data.getItemVisual(idx, 'symbol');
var symbolSize = normalizeSymbolSize(data.getItemVisual(idx, 'symbolSize')); var symbolSize = normalizeSymbolSize(data.getItemVisual(idx, 'symbolSize'));
var color = data.getItemVisual(idx, 'color'); var color = data.getItemVisual(idx, 'color');
...@@ -125,9 +127,13 @@ define(function (require) { ...@@ -125,9 +127,13 @@ define(function (require) {
this._color = color; this._color = color;
var showEffectOn = seriesModel.get('showEffectOn'); var showEffectOn = seriesModel.get('showEffectOn');
var rippleScale = itemModel.get('rippleEffect.scale');
var brushType = itemModel.get('rippleEffect.brushType');
var effectPeriod = itemModel.get('effectPeriod');
this.stopEffectAnimation(); this.stopEffectAnimation();
if (showEffectOn === 'render') { if (showEffectOn === 'render') {
this.startEffectAnimation(); this.startEffectAnimation(effectPeriod, brushType, rippleScale);
} }
var symbol = this.childAt(0); var symbol = this.childAt(0);
function onEmphasis() { function onEmphasis() {
......
...@@ -491,10 +491,12 @@ ...@@ -491,10 +491,12 @@
}, },
label: { label: {
normal: { normal: {
formatter: '{b}',
position: 'right',
show: false show: false
}, },
emphasis: { emphasis: {
show: false show: true
} }
}, },
itemStyle: { itemStyle: {
...@@ -514,6 +516,11 @@ ...@@ -514,6 +516,11 @@
return val[2] / 10; return val[2] / 10;
}, },
showEffectOn: 'render', showEffectOn: 'render',
rippleEffect: {
brushType: 'stroke'
},
hoverAnimation: true,
label: { label: {
normal: { normal: {
formatter: '{b}', formatter: '{b}',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册