Skip to content

Commit 3764da3

Browse files
committed
Minor cleanup and remove calcPriority
1 parent 8f17dd6 commit 3764da3

File tree

5 files changed

+41
-83
lines changed

5 files changed

+41
-83
lines changed

src/lib/carpet.js

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/plots/gl3d/layout/axis_attributes.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,7 @@ var extendFlat = require('../../../lib/extend').extendFlat;
1414

1515

1616
module.exports = {
17-
visible: {
18-
valType: 'boolean',
19-
role: 'info',
20-
description: [
21-
'A single toggle to hide the axis while preserving interaction like dragging.',
22-
'Default is true when a cheater plot is present on the axis, otherwise',
23-
'false'
24-
].join(' ')
25-
},
17+
visible: axesAttrs.visible,
2618
showspikes: {
2719
valType: 'boolean',
2820
role: 'info',

src/plots/plots.js

Lines changed: 14 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1962,34 +1962,7 @@ plots.doCalcdata = function(gd, traces) {
19621962
fullData = gd._fullData,
19631963
fullLayout = gd._fullLayout;
19641964

1965-
var trace, _module, i, j, index;
1966-
1967-
// Look up priorities. The carpet trace is currently
1968-
var priority;
1969-
var prioritizedFullDataLookup = [];
1970-
var hasPriorities = false;
1971-
for(i = 0; i < fullData.length; i++) {
1972-
trace = fullData[i];
1973-
_module = trace._module;
1974-
1975-
// Get the priority from the module definition, otherwise default to zero:
1976-
priority = (_module && _module.calcPriority) ? _module.calcPriority : 0;
1977-
1978-
// Note if a non-zero priority was found so that we only need to sort if
1979-
// there's anything to sort:
1980-
hasPriorities = hasPriorities || priority;
1981-
1982-
prioritizedFullDataLookup.push({index: i, priority: priority});
1983-
}
1984-
1985-
// Sort by priority descending so that higher priority is computed first. If they share the same priority
1986-
// (which has already been default to zero), then they will be compared by trace index so that the original
1987-
// order is preserved within priority groups:
1988-
if(hasPriorities) {
1989-
prioritizedFullDataLookup.sort(function(a, b) {
1990-
return (b.priority - a.priority) || (a.index - b.index);
1991-
});
1992-
}
1965+
var trace, _module, i, j;
19931966

19941967
var hasCategoryAxis = false;
19951968

@@ -2018,6 +1991,13 @@ plots.doCalcdata = function(gd, traces) {
20181991
// to be filled in later by ax.d2c
20191992
for(i = 0; i < axList.length; i++) {
20201993
axList[i]._categories = axList[i]._initialCategories.slice();
1994+
1995+
// Build the lookup map for initialized categories
1996+
axList[i]._categoriesMap = {};
1997+
for(j = 0; j < axList[i]._categories.length; j++) {
1998+
axList[i]._categoriesMap[axList[i]._categories[j]] = j;
1999+
}
2000+
20212001
if(axList[i].type === 'category') hasCategoryAxis = true;
20222002
}
20232003

@@ -2034,9 +2014,7 @@ plots.doCalcdata = function(gd, traces) {
20342014

20352015
// transform loop
20362016
for(i = 0; i < fullData.length; i++) {
2037-
index = prioritizedFullDataLookup[i].index;
2038-
2039-
trace = fullData[index];
2017+
trace = fullData[i];
20402018

20412019
if(trace.visible === true && trace.transforms) {
20422020
_module = trace._module;
@@ -2064,15 +2042,16 @@ plots.doCalcdata = function(gd, traces) {
20642042
axList[i]._min = [];
20652043
axList[i]._max = [];
20662044
axList[i]._categories = [];
2045+
// Reset the look up map
2046+
axList[i]._categoriesMap = {};
20672047
}
20682048
}
20692049

20702050
// 'regular' loop
2071-
for(i = 0; i < prioritizedFullDataLookup.length; i++) {
2072-
index = prioritizedFullDataLookup[i].index;
2051+
for(i = 0; i < fullData.length; i++) {
20732052
var cd = [];
20742053

2075-
trace = fullData[index];
2054+
trace = fullData[i];
20762055

20772056
if(trace.visible === true) {
20782057
_module = trace._module;
@@ -2093,7 +2072,7 @@ plots.doCalcdata = function(gd, traces) {
20932072
if(!cd[0].t) cd[0].t = {};
20942073
cd[0].trace = trace;
20952074

2096-
calcdata[index] = cd;
2075+
calcdata[i] = cd;
20972076
}
20982077

20992078
// To handle the case of components using category names as coordinates, we

src/traces/carpet/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ Carpet.supplyDefaults = require('./defaults');
1616
Carpet.plot = require('./plot');
1717
Carpet.calc = require('./calc');
1818
Carpet.animatable = true;
19-
Carpet.calcPriority = 1;
20-
Carpet.defaultPriority = 1;
2119

2220
Carpet.moduleType = 'trace';
2321
Carpet.name = 'carpet';

test/image/mocks/cheater_contour.json

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,5 @@
11
{
22
"data": [
3-
{
4-
"carpet":"c",
5-
"a":[0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3],
6-
"b":[4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6],
7-
"y":[1, 1.4, 1.6, 1.75, 2, 2.5, 2.7, 2.75, 3, 3.5, 3.7, 3.75],
8-
"x":[2, 3, 4, 5, 2.2, 3.1, 4.1, 5.1, 1.5, 2.5, 3.5, 4.5],
9-
"type":"carpet",
10-
"aaxis":{
11-
"tickprefix":"a = ",
12-
"smoothing":0,
13-
"minorgridcount":9,
14-
"type":"linear"
15-
},
16-
"baxis":{
17-
"tickprefix":"b = ",
18-
"smoothing":0,
19-
"minorgridcount":9,
20-
"type":"linear"
21-
},
22-
"xaxis":"x",
23-
"yaxis":"y"
24-
},
253
{
264
"carpet":"c",
275
"type":"contourcarpet",
@@ -46,26 +24,26 @@
4624
"yaxis":"y"
4725
},
4826
{
49-
"carpet":"c2",
27+
"carpet":"c",
5028
"a":[0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3],
5129
"b":[4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6],
5230
"y":[1, 1.4, 1.6, 1.75, 2, 2.5, 2.7, 2.75, 3, 3.5, 3.7, 3.75],
5331
"x":[2, 3, 4, 5, 2.2, 3.1, 4.1, 5.1, 1.5, 2.5, 3.5, 4.5],
5432
"type":"carpet",
5533
"aaxis":{
5634
"tickprefix":"a = ",
57-
"smoothing":1,
35+
"smoothing":0,
5836
"minorgridcount":9,
5937
"type":"linear"
6038
},
6139
"baxis":{
6240
"tickprefix":"b = ",
63-
"smoothing":1,
41+
"smoothing":0,
6442
"minorgridcount":9,
6543
"type":"linear"
6644
},
6745
"xaxis":"x",
68-
"yaxis":"y2"
46+
"yaxis":"y"
6947
},
7048
{
7149
"carpet":"c2",
@@ -91,6 +69,28 @@
9169
"zmin":1,
9270
"zmax":15.21,
9371
"zauto":true
72+
},
73+
{
74+
"carpet":"c2",
75+
"a":[0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3],
76+
"b":[4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6],
77+
"y":[1, 1.4, 1.6, 1.75, 2, 2.5, 2.7, 2.75, 3, 3.5, 3.7, 3.75],
78+
"x":[2, 3, 4, 5, 2.2, 3.1, 4.1, 5.1, 1.5, 2.5, 3.5, 4.5],
79+
"type":"carpet",
80+
"aaxis":{
81+
"tickprefix":"a = ",
82+
"smoothing":1,
83+
"minorgridcount":9,
84+
"type":"linear"
85+
},
86+
"baxis":{
87+
"tickprefix":"b = ",
88+
"smoothing":1,
89+
"minorgridcount":9,
90+
"type":"linear"
91+
},
92+
"xaxis":"x",
93+
"yaxis":"y2"
9494
}
9595
],
9696
"layout": {

0 commit comments

Comments
 (0)