Skip to content

Commit

Permalink
Restructure parameterization and fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
ayjayt committed Jan 9, 2024
1 parent ecffc49 commit 3089c4a
Show file tree
Hide file tree
Showing 3 changed files with 370 additions and 349 deletions.
10 changes: 5 additions & 5 deletions src/plot_api/plot_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -2945,11 +2945,11 @@ function getDiffFlags(oldContainer, newContainer, outerparts, opts) {
// so newContainer won't have them.
if((key === 'tick0' || key === 'dtick') && outerparts[0] !== 'geo') {
var tickMode = newContainer.tickmode;
if(tickMode === 'auto'
|| tickMode === 'array'
|| tickMode === 'domain array'
|| tickMode === 'full domain'
|| !tickMode) continue;
if(tickMode === 'auto' ||
tickMode === 'array' ||
tickMode === 'domain array' ||
tickMode === 'full domain' ||
!tickMode) continue;
}
// FIXME: Similarly for axis ranges for 3D
// contourcarpet doesn't HAVE zmin/zmax, they're just auto-added. It needs them.
Expand Down
29 changes: 14 additions & 15 deletions src/plots/cartesian/axes.js
Original file line number Diff line number Diff line change
Expand Up @@ -683,9 +683,9 @@ axes.prepTicks = function(ax, opts) {
}

if(!(ax.minor &&
(ax.minor.tickmode !== 'array'
&& ax.minor.tickmode !== 'domain array'
&& ax.minor.tickmode !== 'full domain'))) {
(ax.minor.tickmode !== 'array' &&
ax.minor.tickmode !== 'domain array' &&
ax.minor.tickmode !== 'full domain'))) {
// add a couple of extra digits for filling in ticks when we
// have explicit tickvals without tick text
if(ax.tickmode === 'array' || ax.tickmode === 'domain array' || ax.tickmode === 'full domain') nt *= 100;
Expand Down Expand Up @@ -952,25 +952,24 @@ axes.calcTicks = function calcTicks(ax, opts) {
axes.prepTicks(mockAx, opts);
}

if(mockAx.tickmode === 'full domain'){
if(mockAx.tickmode === 'full domain') {
var nt = mockAx.nticks; // does mockAx have nitkcs?
if(nt === undefined) nt = 0;
var tickVals = [];
if (nt == 0) {
if(nt === 0) {
// pass
} else if (nt == 1) {
} else if(nt === 1) {
tickVals = [0];
} else if (nt == 2) {
} else if(nt === 2) {
tickVals = [0, 1];
} else {
var increment = 1/(nt-1); // (nt-2) + 1
var increment = 1 / (nt - 1); // (nt-2) + 1
tickVals.push(0);
for (let i = 0; i < nt-2; i++) {
tickVals.push((i+1)*increment);
for(var tickIndex = 0; tickIndex < nt - 2; tickIndex++) {
tickVals.push((tickIndex + 1) * increment);
}
tickVals.push(1);
}
if (major) {
if(major) {
Lib.nestedProperty(ax, 'tickvals').set(tickVals);
} else {
Lib.nestedProperty(ax.minor, 'tickvals').set(tickVals);
Expand All @@ -980,7 +979,7 @@ axes.calcTicks = function calcTicks(ax, opts) {
// original comment:
// now that we've figured out the auto values for formatting
// in case we're missing some ticktext, we can break out for array ticks
if(mockAx.tickmode === 'array' || mockAx.tickmode === 'domain array' || mockAx.tickmode === 'full domain' ) {
if(mockAx.tickmode === 'array' || mockAx.tickmode === 'domain array' || mockAx.tickmode === 'full domain') {
// Mapping proportions to array:
if(mockAx.tickmode === 'domain array' || mockAx.tickmode === 'full domain') {
var width = (maxRange - minRange);
Expand Down Expand Up @@ -1278,12 +1277,12 @@ axes.calcTicks = function calcTicks(ax, opts) {
// Reset tickvals back to domain array
if(tickFractionalVals._isSet) {
delete tickFractionalVals._isSet;
if (ax.tickmode === 'full domain') tickFractionalVals = [];
if(ax.tickmode === 'full domain') tickFractionalVals = [];
Lib.nestedProperty(ax, 'tickvals').set(tickFractionalVals);
}
if(minorTickFractionalVals._isSet) {
delete tickFractionalVals._isSet;
if (ax.minor.tickmode === 'full domain') tickFractionalVals = [];
if(ax.minor.tickmode === 'full domain') tickFractionalVals = [];
Lib.nestedProperty(ax.minor, 'tickvals').set(minorTickFractionalVals);
}

Expand Down
Loading

0 comments on commit 3089c4a

Please sign in to comment.