-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
more cache hits for getMaxTickWidth #2687
base: master
Are you sure you want to change the base?
Changes from all commits
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 |
---|---|---|
|
@@ -138,12 +138,6 @@ ChartInternal.prototype.initParams = function() { | |
$$.legendItemWidth = 0; | ||
$$.legendItemHeight = 0; | ||
|
||
$$.currentMaxTickWidths = { | ||
x: 0, | ||
y: 0, | ||
y2: 0 | ||
}; | ||
|
||
$$.rotated_padding_left = 30; | ||
$$.rotated_padding_right = config.axis_rotated && !config.axis_x_show ? 0 : 30; | ||
$$.rotated_padding_top = 5; | ||
|
@@ -533,6 +527,9 @@ ChartInternal.prototype.redraw = function(options, transitions) { | |
durationForExit = withTransitionForExit ? duration : 0; | ||
durationForAxis = withTransitionForAxis ? duration : 0; | ||
|
||
// reset caches when we are re-drawing the chart | ||
$$.resetCache(); | ||
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 guess this resetting of cache might be inconvenient for some future use cases. How about resetting only some groups of caches by the key? $$.resetCache('MaxTickWidth') // => reset cache which has the key /^\$MaxTickWidth/ 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 though about this when I tried to use this method for I think there will be some kind of tradeoff between ease of use (aka: Forget to reset a cache here & there) & performance. I think there are 2 families of cached values:
|
||
|
||
transitions = transitions || $$.axis.generateTransitions(durationForAxis); | ||
|
||
// update legend and transform each g | ||
|
@@ -762,6 +759,8 @@ ChartInternal.prototype.updateAndRedraw = function(options) { | |
options.withUpdateOrgXDomain = getOption(options, "withUpdateOrgXDomain", true); | ||
options.withTransitionForExit = false; | ||
options.withTransitionForTransform = getOption(options, "withTransitionForTransform", options.withTransition); | ||
// clear any cache before we update sizes | ||
$$.resetCache(); | ||
// MEMO: this needs to be called before updateLegend and it means this ALWAYS needs to be called) | ||
$$.updateSizes(); | ||
// MEMO: called in updateLegend in redraw if withLegend | ||
|
@@ -1148,7 +1147,7 @@ ChartInternal.prototype.generateWait = function() { | |
if (!$$.isTabVisible()) { | ||
return; | ||
} | ||
|
||
var done = 0; | ||
transitionsToWait.forEach(function(t) { | ||
if (t.empty()) { | ||
|
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.
nice early return 👍