<commit_before>import Visualization from "../../visualization";
import ReactIgnore from "../../react-ignore";
import {max} from "../../tools";
import {Map} from "immutable";
import Plotly from "plotly.js/lib/core";
Plotly.register([
  require('plotly.js/lib/bar')
]);

class Chart extends Visualization{
  getData(){
    return super.getData();
  }

  getDecoratedLayout(){
    var {title, xAxisRange, yAxisRange} = this.props;
    var layout = this.getLayout();
    layout.width = this.props.width;
    if(title) layout.title = title;
    if(xAxisRange) layout.xaxis.range = xAxisRange;
    if(yAxisRange) layout.yaxis.range = yAxisRange;
    return layout;
  }

  componentDidMount(){
    super.componentDidMount();
    Plotly.newPlot(this.refs.chartContainer, this.getData(), this.getDecoratedLayout());
  }

  componentWillUnmount(){
    Plotly.Plots.purge(this.refs.chartContainer);
  }

  componentDidUpdate(prevProps){
    super.componentDidUpdate(prevProps);
    if(this.constructor.UPDATABLE_FIELDS.some(prop => prevProps[prop] != this.props[prop])){
      this.refs.chartContainer.data = this.getData();
      this.refs.chartContainer.layout = this.getDecoratedLayout();
      setTimeout(() => Plotly.redraw(this.refs.chartContainer));
    } else if(['title', 'width', 'xAxisRange', 'yAxisRange'].some(prop => prevProps[prop] != this.props[prop])){
      setTimeout(() => Plotly.relayout(this.refs.chartContainer, this.getDecoratedLayout()));
    }
  }

  render(){<commit_msg>Fixed a bug when chart axis labels were not being translated during language switch<commit_after>import Visualization from "../../visualization";
import ReactIgnore from "../../react-ignore";
import {max} from "../../tools";
import {Map} from "immutable";
import Plotly from "plotly.js/lib/core";
Plotly.register([
  require('plotly.js/lib/bar')
]);

class Chart extends Visualization{
  getData(){
    return super.getData();
  }

  getDecoratedLayout(){
    var {title, xAxisRange, yAxisRange} = this.props;
    var layout = this.getLayout();
    layout.width = this.props.width;
    if(title) layout.title = title;
    if(xAxisRange) layout.xaxis.range = xAxisRange;
    if(yAxisRange) layout.yaxis.range = yAxisRange;
    return layout;
  }

  componentDidMount(){
    super.componentDidMount();
    Plotly.newPlot(this.refs.chartContainer, this.getData(), this.getDecoratedLayout());
  }

  componentWillUnmount(){
    Plotly.Plots.purge(this.refs.chartContainer);
  }

  componentDidUpdate(prevProps){
    super.componentDidUpdate(prevProps);
    if(this.constructor.UPDATABLE_FIELDS.some(prop => prevProps[prop] != this.props[prop])){
      this.refs.chartContainer.data = this.getData();
      this.refs.chartContainer.layout = this.getDecoratedLayout();
      setTimeout(() => Plotly.redraw(this.refs.chartContainer));
    } else if(['title', 'width', 'xAxisRange', 'yAxisRange', 'translations'].some(prop => prevProps[prop] != this.props[prop])){
      setTimeout(() => Plotly.relayout(this.refs.chartContainer, this.getDecoratedLayout()));
    }
  }

  render(){
{'fraction_non_alphanumeric': 0.15784313725490196, 'fraction_numerical': 0.0, 'mean_word_length': 4.2504288164665525, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '7044333', 'n_tokens_mistral': 970, 'n_tokens_neox': 961, 'n_words': 173}