-
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?
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2687 +/- ##
==========================================
+ Coverage 81.02% 81.03% +0.01%
==========================================
Files 59 59
Lines 4633 4636 +3
==========================================
+ Hits 3754 3757 +3
Misses 879 879
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #2687 +/- ##
==========================================
+ Coverage 81.02% 81.04% +0.01%
==========================================
Files 59 59
Lines 4633 4637 +4
==========================================
+ Hits 3754 3758 +4
Misses 879 879
Continue to review full report at Codecov.
|
b5183d6
to
0325fb6
Compare
}); | ||
|
||
// bypass if SVG not rendered yet | ||
if (!$$.svg) { |
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 👍
@@ -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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
I though about this when I tried to use this method for legendItemTextBox
too where reseting this cache here would be unnecessary.
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:
- The ones that are impacted by an update of data (added, removed targets, etc.)
- The ones that are impacted by an update of sizing (resize, update of CSS....)
This PR:
withoutRecompute
and always return cached version if existsaddToCache
andgetFromCache
instead of custom propertyresetCache
whenredraw
is called.This way we have more cache hits and the cache is dropped each time we want to redraw the chart (thinking of resize etc.) which should be, hopefully, sufficient.