Skip to content

Redraw breaks rendering #11

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
koliyo opened this issue Sep 13, 2016 · 2 comments
Closed

Redraw breaks rendering #11

koliyo opened this issue Sep 13, 2016 · 2 comments

Comments

@koliyo
Copy link

koliyo commented Sep 13, 2016

Plot redrawing is broken. The following example will show a working plot at first, but after a timer fires which triggers a new render the plot becomes broken

const Plotly = require('react-plotlyjs');

class BrokenPlot extends React.Component {
  constructor() {
    super();
    this.state = {foo: 0};
  }

  componentDidMount() {
    setTimeout(e => {
      this.setState({foo: 1});
    }, 1000);
  }

  render() {
    let layout = {
      title: 'simple example',
      xaxis: {
        title: 'time'
      }
    };
    let config = {
      showLink: false,
      displayModeBar: true
    };

    var trace1 = {
      x: [1, 2, 3, 4],
      y: [10, 15, 13, 17],
      mode: 'markers'
    };

    var trace2 = {
      x: [2, 3, 4, 5],
      y: [16, 5, 11, 9],
      mode: 'lines'
    };

    var trace3 = {
      x: [1, 2, 3, 4],
      y: [12, 9, 15, 12],
      mode: 'lines+markers'
    };

    var data = [ trace1, trace2, trace3 ];

    return (
      <Plotly className="whatever" data={data} layout={layout} config={config}/>
    );
  }
}

This wrapper library should use Plotly.newPlot instead, as described here: http://academy.plot.ly/react/3-with-plotly/

@benjeffery
Copy link
Owner

This used to work - Plotly has changed some things around. I'll see if there's a solution where we don't have to resort to newPlot.

@benjeffery
Copy link
Owner

Fixed in v0.3.6 on npm. For now resorting to newPlot - I played around with relayout but that caused issues too. I hope to get time to look into minimal redraw in a few weeks.

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