<commit_before>import React, { PropTypes } from 'react'
import c3 from 'c3'
import House from 'static/images/House-In-Monasterios_1.jpg'
import _ from 'lodash'
import { Grid, Row, Col } from 'react-bootstrap'

// Load classes based on the Data model using classNames
class DashboardResourcePane extends React.Component {
  static propTypes = {
    resource: PropTypes.string.isRequired,
    audits: PropTypes.array
  };
  constructor (props) {
    super(props)
    this.state = {
      chartData: {},
      chart: {},
      chartWidth: window.innerWidth < 992 ? window.innerWidth / 2 : window.innerWidth / 4,
      noData: true,
      mountId: 'resource-chart-' + props.resource
    }
    this.handleResize = this.handleResize.bind(this)
  }

  handleResize (e) {
    let width = window.innerWidth < 992 ? window.innerWidth / 2 : window.innerWidth / 4
    this.state.chart.resize({'width': width})
    // this.setState({chartWidth: width})
  }

  componentDidMount () {
    let chartObj = {
      data: {
        json: {},
        type: 'pie'
      }
    }
    let size = window.innerWidth < 992 ? window.innerWidth / 2 : window.innerWidth / 4
    chartObj.size = {width: size}
    chartObj.bindto = '#resource-chart-' + this.props.resource
    // When done as exampleData.bindto += this.props.resource it becomes additive!?!? What?
    // am I making a bunch of extra of charts
    chartObj.data.json = this.state.chartData
    let chart = c3.generate(chartObj)
    this.setState({<commit_msg>Refactor graph resize to account for state<commit_after>import React, { PropTypes } from 'react'
import c3 from 'c3'
import House from 'static/images/House-In-Monasterios_1.jpg'
import _ from 'lodash'
import { Grid, Row, Col } from 'react-bootstrap'

// Load classes based on the Data model using classNames
class DashboardResourcePane extends React.Component {
  static propTypes = {
    resource: PropTypes.string.isRequired,
    audits: PropTypes.array
  };
  constructor (props) {
    super(props)
    this.state = {
      chartData: {},
      chart: {},
      chartWidth: window.innerWidth < 992 ? window.innerWidth / 2 : window.innerWidth / 4,
      noData: true,
      mountId: 'resource-chart-' + props.resource
    }
    this.handleResize = this.handleResize.bind(this)
  }

  handleResize (e) {
    let width = window.innerWidth < 992 ? window.innerWidth / 2 : window.innerWidth / 4
    this.state.chart.resize({'width': width})
    // this.setState({chartWidth: width})
  }

  componentDidMount () {
    let chartObj = {
      data: {
        json: {},
        type: 'pie'
      }
    }
    // let size = window.innerWidth < 992 ? window.innerWidth / 2 : window.innerWidth / 4
    chartObj.size = {width: this.state.chartWidth}
    chartObj.bindto = '#resource-chart-' + this.props.resource
    // When done as exampleData.bindto += this.props.resource it becomes additive!?!? What?
    // am I making a bunch of extra of charts
    chartObj.data.json = this.state.chartData
    let chart = c3.generate(chartObj)
    this.setState({
{'fraction_non_alphanumeric': 0.1198551201843925, 'fraction_numerical': 0.012512347711557459, 'mean_word_length': 2.894871794871795, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, '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': '4672350', 'n_tokens_mistral': 961, 'n_tokens_neox': 937, 'n_words': 245}