8000 Add bounds to range and autorange of cartesian, gl3d and radial axes by archmoj · Pull Request #6547 · plotly/plotly.js · GitHub
[go: up one dir, main page]

Skip to content

Add bounds to range and autorange of cartesian, gl3d and radial axes #6547

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.

Sign up for GitHub

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

Merged
merged 43 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
2b470ba
add autorange min max to cartesian, gl3d & radial axes
archmoj Mar 31, 2023
e981da5
test autorange min max on cartesian gl3d & radial axes
archmoj Mar 31, 2023
c7b57f5
add range min and max to cartesian, gl3d and radial axes
archmoj Apr 3, 2023
8c2320d
draft log for PR 6547
archmoj Apr 3, 2023
3cda56a
Merge remote-tracking branch 'origin/master' into autorange-bounds
archmoj May 2, 2023
3f2e6e7
rename autorange clip min max
archmoj May 2, 2023
cf7b264
add autorange exact min and max
archmoj May 2, 2023
78b5160
centralized function
archmoj May 2, 2023
8c61f11
add autorange include
archmoj May 2, 2023
c528781
revisit autorange include options
archmoj May 2, 2023
113ec69
centralize autorange options defaults
archmoj May 2, 2023
c7153ca
ensure min < max in case both defined
archmoj May 2, 2023
ab9d1cc
limit range during scattergl update
archmoj May 3, 2023
16a8213
limit corner draggers considering rangemin or rangemax
archmoj May 5, 2023
4d891b3
ensure ranges stay in bound after setting in dragAxList
archmoj May 10, 2023
d787b9f
revise attributes
archmoj May 17, 2023
cb55c08
introduce null range and new autorange options
archmoj May 18, 2023
595a00c
use null in ranges to set defaults
archmoj May 18, 2023
fc79461
declare isReversed() function
archmoj May 18, 2023
c38ed70
use null ranges as default values for autorange eoptions min/max allowed
archmoj May 23, 2023
f8a0501
Merge branch 'master' into autorange-bounds
archmoj May 30, 2023
14ea726
Merge remote-tracking branch 'origin/master' into autorange-bounds
archmoj Jul 19, 2023
13dfe31
update draftlog
archmoj Jul 20, 2023
308ae20
Merge remote-tracking branch 'origin/master' into autorange-bounds
archmoj Jul 25, 2023
e4f906c
Update src/plots/cartesian/layout_attributes.js
archmoj Jul 25, 2023
04b8efa
update schema test
archmoj Jul 25, 2023
086282c
fix hasValidMinAndMax for autorangeoptions allowed attrs
archmoj Jul 26, 2023
699fb78
keep null items in range when calling cleanRange
archmoj Aug 1, 2023
36cb0fa
do not set autorange to false in constraints.handleDefaults for paria…
archmoj Aug 1, 2023
8e707c6
test partial ranges on matching axes
archmoj Aug 1, 2023
c6a147f
Update src/plots/cartesian/layout_attributes.js
archmoj Aug 2, 2023
1f5b819
update schema
archmoj Aug 2, 2023
cc03cf8
Update src/plots/cartesian/layout_attributes.js
archmoj Aug 2, 2023
51ca21e
update schema
archmoj Aug 2, 2023
4527d5d
Merge branch 'master' into autorange-bounds
archmoj Aug 11, 2023
be1d805
keep _rangeInitial0 & _rangeInitial1 instead of _rangeInitial array
archmoj Aug 9, 2023
a7ce254
fix double click interactions for partial ranges
archmoj Aug 18, 2023
fbe1fb9
add jasmine test
archmoj Aug 18, 2023
f0d48e6
revisit axReverse in autorange
archmoj Aug 18, 2023
5d4f665
fix double click on min reversed and max reversed cases
archmoj Aug 18, 2023
faccfc6
validate partial ranges and set autorange true for invalid partial ra…
archmoj Aug 22, 2023
7776305
handle invalid range and reversed autorange
archmoj Aug 23, 2023
30a692e
do not accept partial ranges if autorange is set to true
archmoj Aug 24, 2023
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 autorange exact min and max
  • Loading branch information
archmoj committed May 2, 2023
commit cf7b2642c359d15d49f15dedf75c3f005834d4b2
20 changes: 12 additions & 8 deletions src/plots/cartesian/autorange.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ var getFromId = axIds.getFromId;
var isLinked = axIds.isLinked;

module.exports = {
applyAutorangeClipMin: applyAutorangeClipMin,
applyAutorangeClipMax: applyAutorangeClipMax,
applyAutorangeMinOptions: applyAutorangeMinOptions,
applyAutorangeMaxOptions: applyAutorangeMaxOptions,
getAutoRange: getAutoRange,
makePadFn: makePadFn,
doAutoRange: doAutoRange,
Expand Down Expand Up @@ -178,8 +178,8 @@ function getAutoRange(gd, ax) {
];
}

newRange[0] = applyAutorangeClipMin(newRange[0], ax);
newRange[1] = applyAutorangeClipMax(newRange[1], ax);
newRange[0] = applyAutorangeMinOptions(newRange[0], ax);
newRange[1] = applyAutorangeMaxOptions(newRange[1], ax);

if(ax.limitRange) ax.limitRange();

Expand Down Expand Up @@ -631,12 +631,16 @@ function goodNumber(v) {
function lessOrEqual(v0, v1) { return v0 <= v1; }
function greaterOrEqual(v0, v1) { return v0 >= v1; }

function applyAutorangeClipMin(v, ax) {
if(!ax || ax.autorangeclipmin === undefined) return v;
function applyAutorangeMinOptions(v, ax) {
if(!ax) return v;
if(ax.autorangemin !== undefined) return ax.autorangemin;
if(ax.autorangeclipmin === undefined) return v;
return Math.max(v, ax.d2l(ax.autorangeclipmin));
}

function applyAutorangeClipMax(v, ax) {
if(!ax || ax.autorangeclipmax === undefined) return v;
function applyAutorangeMaxOptions(v, ax) {
if(!ax) return v;
if(ax.autorangemax !== undefined) return ax.autorangemax;
if(ax.autorangeclipmax === undefined) return v;
return Math.min(v, ax.d2l(ax.autorangeclipmax));
}
7 changes: 5 additions & 2 deletions src/plots/cartesian/axis_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,11 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, coerce,
if(autorangeDflt && options.reverseDflt) autorangeDflt = 'reversed';
var autoRange = coerce('autorange', autorangeDflt);
if(autoRange) {
coerce('autorangeclipmin');
coerce('autorangeclipmax');
var autorangemin = coerce('autorangemin');
var autorangemax = coerce('autorangemax');

if(autorangemin === undefined) coerce('autorangeclipmin');
if(autorangemax === undefined) coerce('autorangeclipmax');

if(axType === 'linear' || axType === '-') coerce('rangemode');
}
Expand Down
16 changes: 16 additions & 0 deletions src/plots/cartesian/layout_attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,22 @@ module.exports = {
'If `range` is provided, then `autorange` is set to *false*.'
].join(' ')
},
autorangemin: {
valType: 'any',
editType: 'plot',
impliedEdits: {'range[0]': undefined, 'range[1]': undefined},
description: [
'Use this value exactly as autorange minimum.'
].join(' ')
},
autorangemax: {
valType: 'any',
editType: 'plot',
impliedEdits: {'range[0]': undefined, 'range[1]': undefined},
description: [
'Use this value exactly as autorange maximum.'
].join(' ')
},
autorangeclipmin: {
valType: 'any',
editType: 'plot',
Expand Down
2 changes: 2 additions & 0 deletions src/plots/gl3d/layout/axis_attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ module.exports = overrideAll({
}),
autotypenumbers: axesAttrs.autotypenumbers,
autorange: axesAttrs.autorange,
autorangemin: axesAttrs.autorangemin,
autorangemax: axesAttrs.autorangemax,
autorangeclipmin: axesAttrs.autorangeclipmin,
autorangeclipmax: axesAttrs.autorangeclipmax,
rangemode: axesAttrs.rangemode,
Expand Down
8 changes: 4 additions & 4 deletions src/plots/gl3d/scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ var createAxesOptions = require('./layout/convert');
var createSpikeOptions = require('./layout/spikes');
var computeTickMarks = require('./layout/tick_marks');

var applyAutorangeClipMin = require('../cartesian/autorange').applyAutorangeClipMin;
var applyAutorangeClipMax = require('../cartesian/autorange').applyAutorangeClipMax;
var applyAutorangeMinOptions = require('../cartesian/autorange').applyAutorangeMinOptions;
var applyAutorangeMaxOptions = require('../cartesian/autorange').applyAutorangeMaxOptions;

var STATIC_CANVAS, STATIC_CONTEXT;

Expand Down Expand Up @@ -727,8 +727,8 @@ proto.plot = function(sceneData, fullLayout, layout) {
sceneBounds[1][i] += d / 32.0;
}

sceneBounds[0][i] = applyAutorangeClipMin(sceneBounds[0][i], axis);
sceneBounds[1][i] = applyAutorangeClipMax(sceneBounds[1][i], axis);
sceneBounds[0][i] = applyAutorangeMinOptions(sceneBounds[0][i], axis);
sceneBounds[1][i] = applyAutorangeMaxOptions(sceneBounds[1][i], axis);

if(axis.autorange === 'reversed') {
// swap bounds:
Expand Down
2 changes: 2 additions & 0 deletions src/plots/polar/layout_attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ var radialAxisAttrs = {
}),
autotypenumbers: axesAttrs.autotypenumbers,

autorangemin: axesAttrs.autorangemin,
autorangemax: axesAttrs.autorangemax,
autorangeclipmin: axesAttrs.autorangeclipmin,
autorangeclipmax: axesAttrs.autorangeclipmax,
autorange: extendFlat({}, axesAttrs.autorange, {editType: 'plot'}),
Expand Down
8 changes: 6 additions & 2 deletions src/plots/polar/layout_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,12 @@ function handleDefaults(contIn, contOut, coerce, opts) {
var autoRange = coerceAxis('autorange', !axOut.isValidRange(axIn.range));
axIn.autorange = autoRange;
if(autoRange) {
coerceAxis('autorangeclipmin');
coerceAxis('autorangeclipmax');
var autorangemin = coerceAxis('autorangemin');
var autorangemax = coerceAxis('autorangemax');

if(autorangemin === undefined) coerceAxis('autorangeclipmin');
if(autorangemax === undefined) coerceAxis('autorangeclipmax');

if(axType === 'linear' || axType === '-') coerceAxis('rangemode');
if(autoRange === 'reversed') axOut._m = -1;
}
Expand Down
Binary file modified test/image/baselines/bar-colorscale-colorbar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/bar_errorbars_inherit_color.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/gl3d_mesh3d_enable-alpha-with-rgba-color.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions test/image/mocks/bar-colorscale-colorbar.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"text": "bars + colorbar = <3"
},
"xaxis": {
"autorangemin": 0.5,
"type": "linear",
"range": [
-0.5,
Expand Down
3 changes: 3 additions & 0 deletions test/image/mocks/bar_errorbars_inherit_color.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@
],
"layout": {
"width": 600,
"yaxis": {
"autorangemax": 1100
},
"title": {
"text": "Bar chart error bars inherit color from marker.line not marker"
}
Expand Down
11 changes: 11 additions & 0 deletions test/image/mocks/gl3d_mesh3d_enable-alpha-with-rgba-color.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@
"title": {
"text": "Should draw transparent mesh<br>when having transparent rgba color"
},
"scene": {
"xaxis": {
"autorangemin": -0.5
},
"yaxis": {
"autorangemin": -0.5
},
"zaxis": {
"autorangemax": 2.5
}
},
"width": 400,
"height": 400
}
Expand Down
3 changes: 2 additions & 1 deletion test/image/mocks/polar_fills.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
"y": [0.54, 1]
},
"radialaxis": {
"range": [2, 5]
"autorangeclipmin": 2,
"autorangeclipmax": 5
}
},
"showlegend": false,
Expand Down
72 changes: 72 additions & 0 deletions test/plot-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -4320,6 +4320,18 @@
"impliedEdits": {},
"valType": "any"
},
"autorangemax": {
"description": "Use this value exactly as autorange maximum.",
"editType": "plot",
"impliedEdits": {},
"valType": "any"
},
"autorangemin": {
"description": "Use this value exactly as autorange minimum.",
"editType": "plot",
"impliedEdits": {},
"valType": "any"
},
"autotypenumbers": {
"description": "Using *strict* a numeric string in trace data is not converted to a number. Using *convert types* a numeric string in trace data may be treated as a number during automatic axis `type` detection. Defaults to layout.autotypenumbers.",
"dflt": "convert types",
Expand Down Expand Up @@ -5459,6 +5471,18 @@
"impliedEdits": {},
"valType": "any"
},
"autorangemax": {
"description": "Use this value exactly as autorange maximum.",
"editType": "plot",
"impliedEdits": {},
"valType": "any"
},
"autorangemin": {
"description": "Use this value exactly as autorange minimum.",
"editType": "plot",
"impliedEdits": {},
"valType": "any"
},
"autotypenumbers": {
"description": "Using *strict* a numeric string in trace data is not converted to a number. Using *convert types* a numeric string in trace data may be treated as a number during automatic axis `type` detection. Defaults to layout.autotypenumbers.",
"dflt": "convert types",
Expand Down Expand Up @@ -6055,6 +6079,18 @@
"impliedEdits": {},
"valType": "any"
},
"autorangemax": {
"description": "Use this value exactly as autorange maximum.",
"editType": "plot",
"impliedEdits": {},
"valType": "any"
},
"autorangemin": {
"description": "Use this value exactly as autorange minimum.",
"editType": "plot",
"impliedEdits": {},
"valType": "any"
},
"autotypenumbers": {
"description": "Using *strict* a numeric string in trace data is not converted to a number. Using *convert types* a numeric string in trace data may be treated as a number during automatic axis `type` detection. Defaults to layout.autotypenumbers.",
"dflt": "convert types",
Expand Down Expand Up @@ -6651,6 +6687,18 @@
"impliedEdits": {},
"valType": "any"
},
"autorangemax": {
"description": "Use this value exactly as autorange maximum.",
"editType": "plot",
"impliedEdits": {},
"valType": "any"
},
"autorangemin": {
"description": "Use this value exactly as autorange minimum.",
"editType": "plot",
"impliedEdits": {},
"valType": "any"
},
"autotypenumbers": {
"description": "Using *strict* a numeric string in trace data is not converted to a number. Using *convert types* a numeric string in trace data may be treated as a number during automatic axis `type` detection. Defaults to layout.autotypenumbers.",
"dflt": "convert types",
Expand Down Expand Up @@ -10361,6 +10409,18 @@
"impliedEdits": {},
"valType": "any"
},
"autorangemax": {
"description": "Use this value exactly as autorange maximum.",
"editType": "plot",
"impliedEdits": {},
"valType": "any"
},
"autorangemin": {
"description": "Use this value exactly as autorange minimum.",
"editType": "plot",
"impliedEdits": {},
"valType": "any"
},
"autotypenumbers": {
"description": "Using *strict* a numeric string in trace data is not converted to a number. Using *convert types* a numeric string in trace data may be treated as a number during automatic axis `type` detection. Defaults to layout.autotypenumbers.",
"dflt": "convert types",
Expand Down Expand Up @@ -11647,6 +11707,18 @@
"impliedEdits": {},
"valType": "any"
},
"autorangemax": {
"description": "Use this value exactly as autorange maximum.",
"editType": "plot",
"impliedEdits": {},
"valType": "any"
},
"autorangemin": {
"description": "Use this value exactly as autorange minimum.",
"editType": "plot",
"impliedEdits": {},
"valType": "any"
},
"autoshift": {
"description": "Automatically reposition the axis to avoid overlap with other axes with the same `overlaying` value. This repositioning will account for any `shift` amount applied to other axes on the same side with `autoshift` is set to true. Only has an effect if `anchor` is set to *free*.",
"dflt": false,
Expand Down
0