Skip to content

cache values and patterns in set_convert for rangebreaked axis #5659

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

Merged
merged 2 commits into from
Jun 23, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions src/plots/cartesian/set_convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -600,16 +600,29 @@ module.exports = function setConvert(ax, fullLayout) {
var rangebreaksIn = ax.rangebreaks || [];
var bnds, b0, b1, vb, vDate;


if(!rangebreaksIn._cachedPatterns) {
rangebreaksIn._cachedPatterns = rangebreaksIn.map(function(brk) {
return brk.enabled && brk.bounds ? Lib.simpleMap(brk.bounds, brk.pattern ?
cleanNumber :
ax.d2c // case of pattern: ''
) : null;
});
}
if(!rangebreaksIn._cachedValues) {
rangebreaksIn._cachedValues = rangebreaksIn.map(function(brk) {
return brk.enabled && brk.values ? Lib.simpleMap(brk.values, ax.d2c).sort(Lib.sorterAsc) : null;
});
}


for(var i = 0; i < rangebreaksIn.length; i++) {
var brk = rangebreaksIn[i];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would cache against each brk group, instead of the rangebreaks array as whole, lets you get rid of the nulls and puts the cached values immediately adjacent to the raw values.


if(brk.enabled) {
if(brk.bounds) {
var pattern = brk.pattern;
bnds = Lib.simpleMap(brk.bounds, pattern ?
cleanNumber :
ax.d2c // case of pattern: ''
);
bnds = rangebreaksIn._cachedPatterns[i];
b0 = bnds[0];
b1 = bnds[1];

Expand Down Expand Up @@ -653,7 +666,7 @@ module.exports = function setConvert(ax, fullLayout) {

if(vb >= b0 && vb < b1) return BADNUM;
} else {
var vals = Lib.simpleMap(brk.values, ax.d2c).sort(Lib.sorterAsc);
var vals = rangebreaksIn._cachedValues[i];
for(var j = 0; j < vals.length; j++) {
b0 = vals[j];
b1 = b0 + brk.dvalue;
Expand Down