Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2071acb

Browse filesBrowse files
committed
camelCase histogram.calc
1 parent 89093ad commit 2071acb
Copy full SHA for 2071acb

File tree

Expand file treeCollapse file tree

1 file changed

+58
-58
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+58
-58
lines changed

‎src/traces/histogram/calc.js

Copy file name to clipboardExpand all lines: src/traces/histogram/calc.js
+58-58Lines changed: 58 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -32,67 +32,67 @@ module.exports = function calc(gd, trace) {
3232
var size = [];
3333
var pa = Axes.getFromId(gd, trace.orientation === 'h' ?
3434
(trace.yaxis || 'y') : (trace.xaxis || 'x'));
35-
var maindata = trace.orientation === 'h' ? 'y' : 'x';
36-
var counterdata = {x: 'y', y: 'x'}[maindata];
37-
var calendar = trace[maindata + 'calendar'];
35+
var mainData = trace.orientation === 'h' ? 'y' : 'x';
36+
var counterData = {x: 'y', y: 'x'}[mainData];
37+
var calendar = trace[mainData + 'calendar'];
3838
var cumulativeSpec = trace.cumulative;
3939
var i;
4040

41-
cleanBins(trace, pa, maindata);
41+
cleanBins(trace, pa, mainData);
4242

43-
var binsAndPos = calcAllAutoBins(gd, trace, pa, maindata);
44-
var binspec = binsAndPos[0];
43+
var binsAndPos = calcAllAutoBins(gd, trace, pa, mainData);
44+
var binSpec = binsAndPos[0];
4545
var pos0 = binsAndPos[1];
4646

47-
var nonuniformBins = typeof binspec.size === 'string';
48-
var bins = nonuniformBins ? [] : binspec;
47+
var nonuniformBins = typeof binSpec.size === 'string';
48+
var bins = nonuniformBins ? [] : binSpec;
4949
// make the empty bin array
5050
var inc = [];
5151
var counts = [];
5252
var total = 0;
5353
var norm = trace.histnorm;
5454
var func = trace.histfunc;
55-
var densitynorm = norm.indexOf('density') !== -1;
56-
var i2, binend, n;
55+
var densityNorm = norm.indexOf('density') !== -1;
56+
var i2, binEnd, n;
5757

58-
if(cumulativeSpec.enabled && densitynorm) {
58+
if(cumulativeSpec.enabled && densityNorm) {
5959
// we treat "cumulative" like it means "integral" if you use a density norm,
6060
// which in the end means it's the same as without "density"
6161
norm = norm.replace(/ ?density$/, '');
62-
densitynorm = false;
62+
densityNorm = false;
6363
}
6464

65-
var extremefunc = func === 'max' || func === 'min';
66-
var sizeinit = extremefunc ? null : 0;
67-
var binfunc = binFunctions.count;
68-
var normfunc = normFunctions[norm];
69-
var doavg = false;
65+
var extremeFunc = func === 'max' || func === 'min';
66+
var sizeInit = extremeFunc ? null : 0;
67+
var binFunc = binFunctions.count;
68+
var normFunc = normFunctions[norm];
69+
var isAvg = false;
7070
var pr2c = function(v) { return pa.r2c(v, 0, calendar); };
7171
var rawCounterData;
7272

73-
if(Array.isArray(trace[counterdata]) && func !== 'count') {
74-
rawCounterData = trace[counterdata];
75-
doavg = func === 'avg';
76-
binfunc = binFunctions[func];
73+
if(Array.isArray(trace[counterData]) && func !== 'count') {
74+
rawCounterData = trace[counterData];
75+
isAvg = func === 'avg';
76+
binFunc = binFunctions[func];
7777
}
7878

7979
// create the bins (and any extra arrays needed)
8080
// assume more than 1e6 bins is an error, so we don't crash the browser
81-
i = pr2c(binspec.start);
81+
i = pr2c(binSpec.start);
8282

8383
// decrease end a little in case of rounding errors
84-
binend = pr2c(binspec.end) + (i - Axes.tickIncrement(i, binspec.size, false, calendar)) / 1e6;
84+
binEnd = pr2c(binSpec.end) + (i - Axes.tickIncrement(i, binSpec.size, false, calendar)) / 1e6;
8585

86-
while(i < binend && pos.length < 1e6) {
87-
i2 = Axes.tickIncrement(i, binspec.size, false, calendar);
86+
while(i < binEnd && pos.length < 1e6) {
87+
i2 = Axes.tickIncrement(i, binSpec.size, false, calendar);
8888
pos.push((i + i2) / 2);
89-
size.push(sizeinit);
89+
size.push(sizeInit);
9090
// nonuniform bins (like months) we need to search,
9191
// rather than straight calculate the bin we're in
9292
if(nonuniformBins) bins.push(i);
9393
// nonuniform bins also need nonuniform normalization factors
94-
if(densitynorm) inc.push(1 / (i2 - i));
95-
if(doavg) counts.push(0);
94+
if(densityNorm) inc.push(1 / (i2 - i));
95+
if(isAvg) counts.push(0);
9696
// break to avoid infinite loops
9797
if(i2 <= i) break;
9898
i = i2;
@@ -112,30 +112,30 @@ module.exports = function calc(gd, trace) {
112112
// bin the data
113113
for(i = 0; i < pos0.length; i++) {
114114
n = Lib.findBin(pos0[i], bins);
115-
if(n >= 0 && n < nMax) total += binfunc(n, i, size, rawCounterData, counts);
115+
if(n >= 0 && n < nMax) total += binFunc(n, i, size, rawCounterData, counts);
116116
}
117117

118118
// average and/or normalize the data, if needed
119-
if(doavg) total = doAvg(size, counts);
120-
if(normfunc) normfunc(size, total, inc);
119+
if(isAvg) total = doAvg(size, counts);
120+
if(normFunc) normFunc(size, total, inc);
121121

122122
// after all normalization etc, now we can accumulate if desired
123123
if(cumulativeSpec.enabled) cdf(size, cumulativeSpec.direction, cumulativeSpec.currentbin);
124124

125125

126-
var serieslen = Math.min(pos.length, size.length);
126+
var seriesLen = Math.min(pos.length, size.length);
127127
var cd = [];
128128
var firstNonzero = 0;
129-
var lastNonzero = serieslen - 1;
129+
var lastNonzero = seriesLen - 1;
130130

131131
// look for empty bins at the ends to remove, so autoscale omits them
132-
for(i = 0; i < serieslen; i++) {
132+
for(i = 0; i < seriesLen; i++) {
133133
if(size[i]) {
134134
firstNonzero = i;
135135
break;
136136
}
137137
}
138-
for(i = serieslen - 1; i > firstNonzero; i--) {
138+
for(i = seriesLen - 1; i > firstNonzero; i--) {
139139
if(size[i]) {
140140
lastNonzero = i;
141141
break;
@@ -161,8 +161,8 @@ module.exports = function calc(gd, trace) {
161161
* smallest bins of any of the auto values for all histograms grouped/stacked
162162
* together.
163163
*/
164-
function calcAllAutoBins(gd, trace, pa, maindata) {
165-
var binAttr = maindata + 'bins';
164+
function calcAllAutoBins(gd, trace, pa, mainData) {
165+
var binAttr = mainData + 'bins';
166166
var i, tracei, calendar, firstManual, pos0;
167167

168168
// all but the first trace in this group has already been marked finished
@@ -179,30 +179,30 @@ function calcAllAutoBins(gd, trace, pa, maindata) {
179179
var minStart = Infinity;
180180
var maxEnd = -Infinity;
181181

182-
var autoBinAttr = 'autobin' + maindata;
182+
var autoBinAttr = 'autobin' + mainData;
183183

184184
for(i = 0; i < traceGroup.length; i++) {
185185
tracei = traceGroup[i];
186186

187187
// stash pos0 on the trace so we don't need to duplicate this
188188
// in the main body of calc
189-
pos0 = tracei._pos0 = pa.makeCalcdata(tracei, maindata);
190-
var binspec = tracei[binAttr];
189+
pos0 = tracei._pos0 = pa.makeCalcdata(tracei, mainData);
190+
var binSpec = tracei[binAttr];
191191

192-
if((tracei[autoBinAttr]) || !binspec ||
193-
binspec.start === null || binspec.end === null) {
194-
calendar = tracei[maindata + 'calendar'];
192+
if((tracei[autoBinAttr]) || !binSpec ||
193+
binSpec.start === null || binSpec.end === null) {
194+
calendar = tracei[mainData + 'calendar'];
195195
var cumulativeSpec = tracei.cumulative;
196196

197-
binspec = Axes.autoBin(pos0, pa, tracei['nbins' + maindata], false, calendar);
197+
binSpec = Axes.autoBin(pos0, pa, tracei['nbins' + mainData], false, calendar);
198198

199199
// adjust for CDF edge cases
200200
if(cumulativeSpec.enabled && (cumulativeSpec.currentbin !== 'include')) {
201201
if(cumulativeSpec.direction === 'decreasing') {
202-
minStart = Math.min(minStart, pa.r2c(binspec.start, 0, calendar) - binspec.size);
202+
minStart = Math.min(minStart, pa.r2c(binSpec.start, 0, calendar) - binSpec.size);
203203
}
204204
else {
205-
maxEnd = Math.max(maxEnd, pa.r2c(binspec.end, 0, calendar) + binspec.size);
205+
maxEnd = Math.max(maxEnd, pa.r2c(binSpec.end, 0, calendar) + binSpec.size);
206206
}
207207
}
208208

@@ -211,14 +211,14 @@ function calcAllAutoBins(gd, trace, pa, maindata) {
211211
autoBinnedTraces.push(tracei);
212212
}
213213
else if(!firstManual) {
214-
// Remember the first manually set binspec. We'll try to be extra
214+
// Remember the first manually set binSpec. We'll try to be extra
215215
// accommodating of this one, so other bins line up with these
216216
// if there's more than one manual bin set and they're mutually inconsistent,
217217
// then there's not much we can do...
218218
firstManual = {
219-
size: binspec.size,
220-
start: pa.r2c(binspec.start, 0, calendar),
221-
end: pa.r2c(binspec.end, 0, calendar)
219+
size: binSpec.size,
220+
start: pa.r2c(binSpec.start, 0, calendar),
221+
end: pa.r2c(binSpec.end, 0, calendar)
222222
};
223223
}
224224

@@ -227,9 +227,9 @@ function calcAllAutoBins(gd, trace, pa, maindata) {
227227
// But manually binned traces won't be adjusted, even if the auto values
228228
// are inconsistent with the manual ones (or the manual ones are inconsistent
229229
// with each other).
230-
minSize = getMinSize(minSize, binspec.size);
231-
minStart = Math.min(minStart, pa.r2c(binspec.start, 0, calendar));
232-
maxEnd = Math.max(maxEnd, pa.r2c(binspec.end, 0, calendar));
230+
minSize = getMinSize(minSize, binSpec.size);
231+
minStart = Math.min(minStart, pa.r2c(binSpec.start, 0, calendar));
232+
maxEnd = Math.max(maxEnd, pa.r2c(binSpec.end, 0, calendar));
233233

234234
// add the flag that lets us abort autobin on later traces
235235
if(i) trace._autoBinFinished = 1;
@@ -253,7 +253,7 @@ function calcAllAutoBins(gd, trace, pa, maindata) {
253253
// now go back to the autobinned traces and update their bin specs with the final values
254254
for(i = 0; i < autoBinnedTraces.length; i++) {
255255
tracei = autoBinnedTraces[i];
256-
calendar = tracei[maindata + 'calendar'];
256+
calendar = tracei[mainData + 'calendar'];
257257

258258
tracei._input[binAttr] = tracei[binAttr] = {
259259
start: pa.c2r(minStart, 0, calendar),
@@ -323,7 +323,7 @@ function numericSize(size) {
323323
return Infinity;
324324
}
325325

326-
function cdf(size, direction, currentbin) {
326+
function cdf(size, direction, currentBin) {
327327
var i, vi, prevSum;
328328

329329
function firstHalfPoint(i) {
@@ -337,7 +337,7 @@ function cdf(size, direction, currentbin) {
337337
prevSum += vi;
338338
}
339339

340-
if(currentbin === 'half') {
340+
if(currentBin === 'half') {
341341

342342
if(direction === 'increasing') {
343343
firstHalfPoint(0);
@@ -358,7 +358,7 @@ function cdf(size, direction, currentbin) {
358358
}
359359

360360
// 'exclude' is identical to 'include' just shifted one bin over
361-
if(currentbin === 'exclude') {
361+
if(currentBin === 'exclude') {
362362
size.unshift(0);
363363
size.pop();
364364
}
@@ -368,7 +368,7 @@ function cdf(size, direction, currentbin) {
368368
size[i] += size[i + 1];
369369
}
370370

371-
if(currentbin === 'exclude') {
371+
if(currentBin === 'exclude') {
372372
size.push(0);
373373
size.shift();
374374
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.