<commit_before>import Plotly from 'plotly.js/lib/core';
import ReactIgnore from '../react-ignore';

class PlotlyChart extends React.PureComponent {
  componentDidMount() {
    const { data, layout } = this.props;
    Plotly.newPlot(
      this.chartContainer,
      data,
      layout,
    );
  }

  componentWillUnmount() {
    Plotly.Plots.purge(this.container);
  }

  render() {
    return (
      <div className="chart-container">
        <ReactIgnore>
          <div ref={(c) => { this.chartContainer = c; }} />
        </ReactIgnore>
      </div>
    );
  }
}

PlotlyChart.defaultProps = {
  data: [],
  layout: {},
}

export default PlotlyChart;<commit_msg>OCE-439 New plotly chart updating<commit_after>import Plotly from 'plotly.js/lib/core';
import ReactIgnore from '../react-ignore';

class PlotlyChart extends React.PureComponent {
  componentDidMount() {
    const { data, layout } = this.props;
    Plotly.newPlot(
      this.chartContainer,
      data,
      layout,
    );
  }

  componentWillUnmount() {
    Plotly.Plots.purge(this.container);
  }

  componentDidUpdate(prevProps) {
    const { data, layout } = this.props;
    if (data !== prevProps[data]) {
      this.chartContainer.data = data;
      this.chartContainer.layout = layout;
      setTimeout(() => Plotly.redraw(this.chartContainer));
    } else if (layout !== prevProps[layout]) {
      setTimeout(() => Plotly.relayout(this.chartContainer, layout));
    }
  }

  render() {
    return (
      <div className="chart-container">
        <ReactIgnore>
          <div ref={(c) => { this.chartContainer = c; }} />
        </ReactIgnore>
      </div>
    );
  }
}

PlotlyChart.defaultProps = {
  data: [],
  layout: {},
}

export default PlotlyChart;
{'fraction_non_alphanumeric': 0.14558058925476602, 'fraction_numerical': 0.0017331022530329288, 'mean_word_length': 2.7327586206896552, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6706042', 'n_tokens_mistral': 559, 'n_tokens_neox': 552, 'n_words': 104}