-
Notifications
You must be signed in to change notification settings - Fork 11.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support configurable update #4362
Changes from 1 commit
ae86fb9
270286d
0db97cc
bb6c771
fe2098d
5cb7b3f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -334,9 +334,17 @@ module.exports = function(Chart) { | |
this.tooltip.initialize(); | ||
}, | ||
|
||
update: function(animationDuration, lazy) { | ||
update: function(config) { | ||
var me = this; | ||
|
||
if (!config || typeof config !== 'object') { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should have a test, if possible, that verifies that backwards compatibility isn't broken. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can try that. Is there any other place other than |
||
// backwards compatibility | ||
config = { | ||
duration: config, | ||
lazy: arguments[1] | ||
}; | ||
} | ||
|
||
updateConfig(me); | ||
|
||
if (plugins.notify(me, 'beforeUpdate') === false) { | ||
|
@@ -368,11 +376,12 @@ module.exports = function(Chart) { | |
|
||
if (me._bufferedRender) { | ||
me._bufferedRequest = { | ||
lazy: lazy, | ||
duration: animationDuration | ||
duration: config.duration, | ||
easing: config.easing, | ||
lazy: config.lazy | ||
}; | ||
} else { | ||
me.render(animationDuration, lazy); | ||
me.render(config); | ||
} | ||
}, | ||
|
||
|
@@ -442,9 +451,20 @@ module.exports = function(Chart) { | |
plugins.notify(me, 'afterDatasetUpdate', [args]); | ||
}, | ||
|
||
render: function(duration, lazy) { | ||
render: function(config) { | ||
var me = this; | ||
|
||
if (!config || typeof config !== 'object') { | ||
// backwards compatibility | ||
config = { | ||
duration: config, | ||
lazy: arguments[1] | ||
}; | ||
} | ||
|
||
var duration = config.duration; | ||
var lazy = config.lazy; | ||
|
||
if (plugins.notify(me, 'beforeRender') === false) { | ||
return; | ||
} | ||
|
@@ -458,7 +478,7 @@ module.exports = function(Chart) { | |
if (animationOptions && ((typeof duration !== 'undefined' && duration !== 0) || (typeof duration === 'undefined' && animationOptions.duration !== 0))) { | ||
var animation = new Chart.Animation({ | ||
numSteps: (duration || animationOptions.duration) / 16.66, // 60 fps | ||
easing: animationOptions.easing, | ||
easing: config.easing || animationOptions.easing, | ||
|
||
render: function(chart, animationObject) { | ||
var easingFunction = helpers.easingEffects[animationObject.easing]; | ||
|
@@ -771,7 +791,7 @@ module.exports = function(Chart) { | |
var bufferedRequest = me._bufferedRequest; | ||
if (bufferedRequest) { | ||
// If we have an update that was triggered, we need to do a normal render | ||
me.render(bufferedRequest.duration, bufferedRequest.lazy); | ||
me.render(bufferedRequest); | ||
} else if (changed && !me.animating) { | ||
// If entering, leaving, or changing elements, animate the change via pivot | ||
me.stop(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would not write about it: it still works but people should not know about it.