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

Add tickmode "proportional" #6827

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

Open
wants to merge 38 commits into
base: master
Choose a base branch
Loading
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
e7a2ffa
Add/calc tickmode "proportional" in `cartesian/`
ayjayt Dec 26, 2023
6d48a3b
Fix bug by which tickvals forever expands
ayjayt Dec 26, 2023
00e884a
Make tickmode proportional calculate reversed axes
ayjayt Dec 26, 2023
931199e
Use lib.simpleMap(); Refactor var names.
ayjayt Dec 26, 2023
fced9ce
Add log math to tickmode proportional
ayjayt Dec 26, 2023
b2abf08
Remove console debug messages
ayjayt Dec 26, 2023
910163e
Add description in layout_attributes.js
ayjayt Dec 26, 2023
e21af96
Fix linter errors
ayjayt Dec 26, 2023
ddfaad7
update plot-scheme diff
ayjayt Dec 26, 2023
d42dd73
Restore proportional array later in loop:
ayjayt Dec 27, 2023
5d7b1b9
Remove _isSet flag from tickVals before resetting
ayjayt Dec 28, 2023
db1f82e
Add parameterized tests:
ayjayt Dec 28, 2023
a2ac023
Fix tests to pass if #6828 is addressed
ayjayt Dec 28, 2023
1fedfc7
Clean up commenting/address lint errors.
ayjayt Dec 28, 2023
e8f2052
Fix a bit more lint
ayjayt Dec 28, 2023
c3f590d
Merge branch 'master' into pikul-proportional-ticks
ayjayt Jan 2, 2024
7e93370
Change tickmode 'proportional' to 'domain array'
ayjayt Jan 3, 2024
afba178
Add tickmode 'full domain'
ayjayt Jan 3, 2024
aca7a92
Set default so `full domain` doesn't set to `auto`
ayjayt Jan 3, 2024
195dfa5
Fix various errata/typos
ayjayt Jan 3, 2024
a788ccc
Add test for full-domain
ayjayt Jan 3, 2024
ecffc49
Merge branch 'master' into pikul-proportional-ticks
ayjayt Jan 4, 2024
3089c4a
Restructure parameterization and fix linting
ayjayt Jan 9, 2024
99d336a
Intermediate commit w/ partial work- new strat:
ayjayt Jan 12, 2024
4476d38
Merge branch 'master' into pikul-proportional-ticks
ayjayt Jan 12, 2024
3502d49
Revert branch to equal master
ayjayt Jan 12, 2024
09ebcfc
Lint and refactor
ayjayt Jan 12, 2024
3fe254b
Merge branch 'pikul-proportional-ticks-old' into pikul-proportional-t…
ayjayt Jan 12, 2024
eb82723
Revert completely to old tick algo
ayjayt Jan 12, 2024
fe6f8d0
update git-scheme diff
ayjayt Jan 12, 2024
b3956a0
Merge branch 'master' into pikul-proportional-ticks
ayjayt Jan 24, 2024
7176049
Remove category test in prep for disallowing
ayjayt Jan 25, 2024
15387ed
Refactor as to not override ax.tickvals:
ayjayt Jan 25, 2024
2ab0b41
Rework some if-then to golf mode (?:)
ayjayt Jan 25, 2024
f1a4db8
Lint
ayjayt Jan 25, 2024
ee17af2
Make 'auto' to function as 'array' when [] present
ayjayt Jan 25, 2024
93e4bb8
Refix incorrect patch ee17af22f393c
ayjayt Jan 25, 2024
61efdef
Merge branch 'master' into pikul-proportional-ticks
ayjayt Feb 9, 2024
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
Prev Previous commit
Next Next commit
Add tickmode 'full domain'
  • Loading branch information
ayjayt committed Jan 3, 2024
commit afba178df70ee72bd995bfa107b6bb9a07a6e9c4
6 changes: 5 additions & 1 deletion 6 src/plot_api/plot_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -2945,7 +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) 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
42 changes: 35 additions & 7 deletions 42 src/plots/cartesian/axes.js
Original file line number Diff line number Diff line change
Expand Up @@ -682,10 +682,13 @@ axes.prepTicks = function(ax, opts) {
if(ax._name === 'radialaxis') nt *= 2;
}

if(!(ax.minor && (ax.minor.tickmode !== 'array' && ax.minor.tickmode !== 'domain array'))) {
if(!(ax.minor &&
(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') nt *= 100;
if(ax.tickmode === 'array' || ax.tickmode === 'domain array' || ax.tickmode === 'full domain') nt *= 100;
}

ax._roughDTick = Math.abs(rng[1] - rng[0]) / nt;
Expand Down Expand Up @@ -948,14 +951,37 @@ axes.calcTicks = function calcTicks(ax, opts) {
} else {
axes.prepTicks(mockAx, opts);
}


if(mockAx.tickmode === 'full domain'){
nt = mockAx.nticks; // does mockAx have nitkcs?
var tickVals = [];
if (nt == 0) {
// pass
} else if (nt == 1) {
tickVals = [0];
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
tickVals = [0];
tickVals = [0.5];

If you just want one tick I'd put it in the middle. Not that it matters much, this is horrible whatever we choose since you can't tell the scale at all.

} else if (nt == 2) {
tickVals = [0, 1];
} else {
var increment = 1/(nt-2);
tickVals.push(0);
for (let i = 0; i < nt-2; i++) {
tickVals.push((i+1)*incremente);
}
tickVals.push(1);
}
if (major) {
Lib.nestedProperty(ax, 'tickvals').set(tickVals);
} else {
Lib.nestedProperty(ax.minor, 'tickvals').set(tickVals);
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should try to avoid altering real attribute values after the supplyDefaults step. But you can set an underscored attribute like _tickvals if you like, then you just need to look for that in arrayTicks (if you're in one of the domain tickmodes). That should avoid the need to reset it later too, I'd imagine.

Also kudos on figuring out nestedProperty - but it's overkill here since we know the attribute names, you can just do ax._tickvals = tickVals etc - or if you feel like code golf, (major ? ax : ax.minor)._tickvals = tickVals 😎

}
}
// tickmode 'domain array' is just 'array' but with a pre-calc step
// 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') {
if(mockAx.tickmode === 'array' || mockAx.tickmode === 'domain array' || mockAx.tickmode === 'full domain' ) {
// Mapping proportions to array:
if(mockAx.tickmode === 'domain array') {
if(mockAx.tickmode === 'domain array' || mockAx.tickmode === 'full domain') {
var width = (maxRange - minRange);
if(axrev) width *= -1;
var offset = !axrev ? minRange : maxRange;
Expand Down Expand Up @@ -1251,10 +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 = [];
Lib.nestedProperty(ax, 'tickvals').set(tickFractionalVals);
}
if(minorTickFractionalVals._isSet) {
delete tickFractionalVals._isSet;
if (ax.minor.tickmode === 'full domain') tickFractionalVals = [];
Lib.nestedProperty(ax.minor, 'tickvals').set(minorTickFractionalVals);
}

Expand Down Expand Up @@ -1662,7 +1690,7 @@ axes.tickFirst = function(ax, opts) {
// more precision for hovertext
axes.tickText = function(ax, x, hover, noSuffixPrefix) {
var out = tickTextObj(ax, x);
var arrayMode = (ax.tickmode === 'array' || ax.tickmode === 'domain array');
var arrayMode = (ax.tickmode === 'array' || ax.tickmode === 'domain array' || ax.tickmode === 'full domain');
var extraPrecision = hover || arrayMode;
var axType = ax.type;
// TODO multicategory, if we allow ticktext / tickvals
Expand Down Expand Up @@ -3378,7 +3406,7 @@ axes.drawGrid = function(gd, ax, opts) {

var counterAx = opts.counterAxis;
if(counterAx && axes.shouldShowZeroLine(gd, ax, counterAx)) {
var isArrayMode = (ax.tickmode === 'array' || ax.tickmode === 'domain array');
var isArrayMode = (ax.tickmode === 'array' || ax.tickmode === 'domain array' || ax.tickmode === 'full domain');
for(var i = 0; i < majorVals.length; i++) {
var xi = majorVals[i].x;
if(isArrayMode ? !xi : (Math.abs(xi) < ax.dtick / 100)) {
Expand Down
6 changes: 5 additions & 1 deletion 6 src/plots/cartesian/layout_attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var DAY_OF_WEEK = constants.WEEKDAY_PATTERN;

var minorTickmode = {
valType: 'enumerated',
values: ['auto', 'linear', 'array', 'domain array'],
values: ['auto', 'linear', 'array', 'domain array', 'full domain'],
editType: 'ticks',
impliedEdits: {tick0: undefined, dtick: undefined},
description: [
Expand All @@ -26,6 +26,10 @@ var minorTickmode = {
'If *array*, the placement of the ticks is set via `tickvals`,',
'which are actual values, and the tick text is `ticktext`.',
'(*array* is the default value if `tickvals` is provided).',
'If *full domain*, the number of ticks is set bia `nticks` but ticks',
'are placed first at both axis ends and then at equal proportions',
'between the axis. So `nticks=5` would put ticks at both ends and',
'every quarter.',
'If *domain array*, the placement is similiar to *array* except that',
'`tickvals` are fractions between 0 and 1 representing distance on',
'the corresponding axis.'
Expand Down
4 changes: 2 additions & 2 deletions 4 test/jasmine/tests/pikul_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');

// Boilerplate taken from axes_test.js
describe('When generating axes w/ `tickmode`:"proportional",', function() {
describe('When generating axes w/ `tickmode`:"domain array",', function() {
var gd;

beforeEach(function() {
Expand All @@ -21,7 +21,7 @@ describe('When generating axes w/ `tickmode`:"proportional",', function() {
function generateTickConfig(tickLen){
// Intentionally configure to produce a single `(x|y)tick` class per tick
// labels and tick marks each produce one, so one or the other
standardConfig = {tickmode: 'proportional', ticklen: tickLen, showticklabels: false};
standardConfig = {tickmode: 'domain array', ticklen: tickLen, showticklabels: false};

// Tick values will be random:
var n = Math.floor(Math.random() * 100);
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.