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
Ability to sync the dtick values of multiple y-axes with new tickmode value "sync" #6356
base: master
Are you sure you want to change the base?
Conversation
|
@alexcjohnson @jackparmer @archmoj |
0c8b15f
to
48e60c2
Compare
|
@archmoj @alexcjohnson Could you have a look here and give us some feedback please? |
|
Thanks very much for the PR. |
|
This is pretty cool. When I drag the right axis the grid lines stay at their initial locations and only the tick labels are updated. |
…zak/plotly.js into first_poc_tickmode_sync
|
All good with the checks here.
@archmoj I was trying to put this to work but looks a bit tricky because when we drag one axis, this should be the only one who refreshes the ticks. If I automatically refresh the others should be a bit mess, especially when we have more than two axes and some are connected and some not, if it makes sense. Of course I'm open to hear your tips and tricks to approach this feature. Thanks |
|
@archmoj I know this PR requires more effort to be merged but if you could have a look and give us some feedback would be great. This is the most desired feature for me in plotly.js. Thanks |
test/plot-schema.json
Outdated
| @@ -1463,7 +1463,8 @@ | |||
| "values": [ | |||
| "auto", | |||
| "linear", | |||
| "array" | |||
| "array", | |||
| "sync" | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
colorbar.tickmode should not have sync option.
You can override tickmode for colorbar here:
| tickmode: axesAttrs.tickmode, |
Something like:
tickmode: extendFlat({}, axesAttrs.tickmode, {
dflt: values: ['auto', 'linear', 'array'],
description: { /* only include available options */ }
}),There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly for indicator trace we don't need this option.
Please modify here:
plotly.js/src/traces/indicator/attributes.js
Line 310 in 4db333c
| tickmode: axesAttrs.tickmode, |
I see. Let's tweak this function plotly.js/src/plots/cartesian/dragbox.js Line 720 in 8f01627
That should fix updating sync axes while dragging the base axis. |
|
The behavior now looks great! |
@archmoj All looks ok to me: linear, log, date, category and multicategory. |
src/plots/cartesian/axes.js
Outdated
| var vali = ax.p2l(pos); | ||
| var val1 = ax.p2l(pos - 0.5); | ||
| var val2 = ax.p2l(pos + 0.5); | ||
| var d = 1 + Math.round(Math.log10(Math.abs(val2 - val1))); | ||
| var e = Math.pow(10, -d); | ||
| var valR = Math.round(vali * e) / e; | ||
| var objR = axes.tickText(ax, valR); | ||
| var obj = axes.tickText(ax, vali); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are the variable names here following a current convention, or can we ditch the abbreviations to make them more descriptive?
|
Tremendous work @filipesantiagoAM . Thanks for all of the guidance @archmoj |
| var objR = axes.tickText(ax, valR); | ||
| var obj = axes.tickText(ax, vali); | ||
| obj.text = objR.text; | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now to be more accurate about the position of labels and ticks lets simplify this part
from:
var objR = axes.tickText(ax, valR);
var obj = axes.tickText(ax, vali);
obj.text = objR.text;to:
var obj = axes.tickText(ax, valR);There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this change, the scroll behaviour is not perfect. It flicks when we try to scroll. Should I commit the changes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes please commit the change. One may argue that having a more accurate static graph is more important.
After that to reduce the flicks we may end up reducing the deltas from 0.2 to 0.15 or even 0.1 here:
var val1 = ax.p2l(pos - 0.1);
var val2 = ax.p2l(pos + 0.1);There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What exactly do you mean by "it flicks"? Yes, the static graph needs to be accurate, but can't we get that and clean scroll behavior simultaneously?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var val1 = ax.p2l(pos - 0.1); var val2 = ax.p2l(pos + 0.1);
@alexcjohnson This fixes the "flicks".
@archmoj Clean and smooth now.
Co-authored-by: Mojtaba Samimi <[email protected]>
Co-authored-by: Mojtaba Samimi <[email protected]>
…zak/plotly.js into first_poc_tickmode_sync
The Issue
#1962
Developers:
Our Solution
This PR is an attempt to adapt the logic originating from https://github.com/VictorBezak/Plotly_Multi-Axes_Gridlines
in order to integrate it with the plotly schema. This PR is not fully tested and ready to be merged, but we wanted to get some feedback at this stage as we feel we now have a viable MVP solution.
How To Use
tickmode: "sync"on your 2ndyaxisthat also has propertyoverlayingset.new_tickmode_sync.jsonThings Tested and Working
Not Done Yet