Skip to content

newPlot does not clear histogram axis type!!! #1231

Closed
@andrewkfiedler

Description

@andrewkfiedler

Here are the relevant codepens to reproduce:
http://codepen.io/andrewkfiedler/pen/XNqMeW?editors=0010
http://codepen.io/andrewkfiedler/pen/ObZpzv?editors=0010

In the first codepen, you can see that plotting a histogram of type 'Number' causes future histograms to be assumed to be of type 'Number' as well. As such it throws an error (the second plot is attempted 5 seconds after the first, so wait 5 seconds).

In the second codepen, you can see that plotting a histogram of type 'String' causes future histograms to be assumed to be of type 'String' as well. As such, the numbers are binned as though they are strings.

Both are examples are using Plotly.newPlot.

Activity

etpinard

etpinard commented on Dec 7, 2016

@etpinard
Contributor

What is the desired behavior here in your mind?

andrewkfiedler

andrewkfiedler commented on Dec 7, 2016

@andrewkfiedler
Author

In my mind, Plotly should not crash when switching the type of data used in a histogram. 'Strings' are useful in histograms to bin things into categories, while 'Numbers' are useful to group things into ranges.

Using one type should not cause Plotly to assume that's the type for all future histograms.

I'd actually prefer being allowed to specify the type instead of allowing Plotly to make the decision for me, as right now I have to append a https://en.wikipedia.org/wiki/Zero-width_space in order to force String types that sometimes involve Numbers to be seen as such.

andrewkfiedler

andrewkfiedler commented on Dec 14, 2016

@andrewkfiedler
Author

Anything else I can provide to help out on this?

etpinard

etpinard commented on Dec 14, 2016

@etpinard
Contributor

Oh. You're using newPlot. Ok that's bad. Sorry I thought you were complaining about multi-trace graphs being cast to the same axis type. newPlot (as the name suggests) should clean up everything about the previous graphs.

Thanks for the report.

etpinard

etpinard commented on Dec 15, 2016

@etpinard
Contributor

Changing the issue title to attract more attention.

changed the title [-]Previous histograms affect future histograms[/-] [+]`newPlot` does not clear histogram axis type!!![/+] on Dec 15, 2016
etpinard

etpinard commented on Dec 15, 2016

@etpinard
Contributor

The issue can be replicated all the back be to v1.0.0: not a regression.

self-assigned this
on Dec 15, 2016
etpinard

etpinard commented on Dec 16, 2016

@etpinard
Contributor

We haven't fixed the bug yet, but here's a workaround: http://codepen.io/etpinard/pen/dOwJoZ

Our poor user input object management is responsible for this bug.

alexcjohnson

alexcjohnson commented on Sep 29, 2017

@alexcjohnson
Collaborator

Just to be clear what @etpinard means by "poor user input object management" - the issue is that we mutate the layout object you pass in, so the workaround is to create a new layout object for each newPlot call.

We can only fix this in v2, at which point we can clone data and layout and mutate those rather than the ones you pass in.

added this to the v2.0.0 milestone on Sep 29, 2017
removed their assignment
on Sep 29, 2017
etpinard

etpinard commented on Mar 28, 2019

@etpinard
Contributor

Merging into #2234

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugsomething broken

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      Participants

      @alexcjohnson@etpinard@andrewkfiedler

      Issue actions

        `newPlot` does not clear histogram axis type!!! · Issue #1231 · plotly/plotly.js