Skip to content
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