Skip to content

[BUG] data[type=contour].autocontour not working with restyle #4201

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

Closed
mafar opened this issue Sep 18, 2019 · 3 comments
Closed

[BUG] data[type=contour].autocontour not working with restyle #4201

mafar opened this issue Sep 18, 2019 · 3 comments

Comments

@mafar
Copy link
Contributor

mafar commented Sep 18, 2019

CodePen: https://codepen.io/mafar/pen/XWrxarp?editors=0010
This pen is bare minimum for bug reproduction

Explaination: https://plot.ly/javascript/reference/#contour
Initial data see below

  1. Define data with autocontour:true
  2. Define contours start,end and size option even they will be ignored because of autocontour:true

Once plot is drawn , restlye it with

var update = {
  autocontour: false,
  "contours.start": 3 
};
Plotly.restyle("myDiv", update, 0);

But plot does not update !!! as expected where it should have used contours.start end and size values

Code:

var data = [
  {
    z: [
      [10, 10.625, 12.5, 15.625, 20],
      [5.625, 6.25, 8.125, 11.25, 15.625],
      [2.5, 3.125, 5, 8.125, 12.5],
      [0.625, 1.25, 3.125, 6.25, 10.625],
      [0, 0.625, 2.5, 5.625, 10]
    ],
    type: "contour",
    ncontours: 15,
    autocontour: true,
    contours: {
      start: 1,
      end: 5,
      size: 1
    }
  }
];
var layout = {
  title: Contours"
};
Plotly.newPlot("myDiv", data, layout);
var update = {
  autocontour: false,
  "contours.start": 3 
};
Plotly.restyle("myDiv", update, 0);
@etpinard
Copy link
Contributor

Writing down a similar play-by-play as in #4199 (comment) for this report:

Plotly.newPlot(gd, [
  {
    z: [
      [10, 10.625, 12.5, 15.625, 20],
      [5.625, 6.25, 8.125, 11.25, 15.625],
      [2.5, 3.125, 5, 8.125, 12.5],
      [0.625, 1.25, 3.125, 6.25, 10.625],
      [0, 0.625, 2.5, 5.625, 10]
    ],
    type: "contour",
    ncontours: 15,
    autocontour: true,
    contours: {
      start: 1,
      end: 5,
      size: 1
    }
  }
])

// gives (the auto contours)
gd.data[0].contours // => {start: 2, end: 18, size: 2}

// then
Plotly.restyle(gd, { autocontour: false, "contours.start": 3 })
// gives
gd.data[0].contours // => {start: 3, end: 18, size: 2}
// ... keeping the previous auto contours value and 
//     ignoring the starting {start: 1, end: 5, size: 1} settings

@etpinard
Copy link
Contributor

As this bug has the same cause and will be solved at the same time as #4199 - I'll merge the two tickets together.

Thanks again @mafar for the very clear bug reports! Cheers

@mafar
Copy link
Contributor Author

mafar commented Sep 19, 2019

One additional comment:
Toggle of autocontour should work ,which it currently does not.
When i toggle autocontour Only, nothing happens in plotly , it should apply values based on this toggle

Turn on manual contour settings
js Plotly.restyle(gd, { autocontour: false })

Turn on autocontour which will consumencontours value (default is 15 anyway)
js Plotly.restyle(gd, { autocontour: true})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants