<commit_before>import React from 'react';
import ScatterPlot from './ScatterPlot.jsx';
import Histogram from './Histogram.jsx';
import css from '../../css/scatterplot.css';

// ----------------------------------------------------------------------------
// Everything in here can me moved to another file!
// ----------------------------------------------------------------------------

const styles = {
  width   : 500,
  height  : 300,
  padding : 30,
};

// Number of data points for the chart
const numDataPoints = 50;

// Returns a random number from 0 to 1000
const randomNum = () => Math.floor(Math.random() * 1000);

// Creates an array of 50 elements of (x, y) coordinates 
const randomDataSet = () => {
  return Array.apply(null, {length: numDataPoints}).map(() => [randomNum(), randomNum()]);
}

// Returns a pair of random gaussian numbers
const randomGaussNum = (mu, sigma) => {
  // Generate pair of independent random uniformly distributed variables
  // within interval (0,1).
  let u1 = Math.random();
  let u2 = Math.random();

  // Transform u1 and u2 to independent random variables with a standard 
  // normal distribution.
  let z0 = Math.sqrt(-2 * Math.log(u1)) * Math.cos(2 * Math.PI * u2);
  let z1 = Math.sqrt(-2 * Math.log(u1)) * Math.sin(2 * Math.PI * u2);

  // Transform standard normal deviate, z0, to a value within a normal
  // distribution with mean, mu, and standard deviation, sigma.
  return z0 * sigma + mu;
}

// Creates an array of random normally distrubted test scores with mean, mu,
// and standard deviation, sigma.
const randomGaussDataSet = (mu, sigma) => {
  console.log('From CHART: ', Array.apply(null, {length: numDataPoints}).map(() => randomGaussNum(mu, sigma)));
  return Array.apply(null, {length: numDataPoints}).map(() => randomGaussNum(mu, sigma));
}
// ----------------------------------------------------------------------------


class Chart extends React.Component {
  constructor(props) {
    super(props);
    this.state = { 
      data: randomDataSet(),
      currentClassId: this.props.currentClassId,
      currentClassName: this.props.currentClassName,
      gaussData: this.props.classTestData
    };
  }

  randomizeData() {
    this.setState({ data: randomDataSet() });
  }

  render() {
    return (
      <div>
        <h1>{this.props.currentClassName} - MidTerm 1</h1>
        <ScatterPlot {...this.state} {...styles} />
        <Histogram {...this.state} {...styles} />
        <div className="controls">
          <button className="btn randomize" onClick={() => this.randomizeData()}>
            Randomize Data
          </button>
        </div>
      </div>
    );
  }
};

export default Chart<commit_msg>(feat) Import and render BarChart in Chart component for development<commit_after>import React from 'react';
import ScatterPlot from './ScatterPlot.jsx';
import Histogram from './Histogram.jsx';
import BarChart from './BarChart.jsx';
import css from '../../css/scatterplot.css';

// ----------------------------------------------------------------------------
// Everything in here can me moved to another file!
// ----------------------------------------------------------------------------

const styles = {
  width   : 500,
  height  : 300,
  padding : 30,
};

// Number of data points for the chart
const numDataPoints = 50;

// Returns a random number from 0 to 1000
const randomNum = () => Math.floor(Math.random() * 1000);

// Creates an array of 50 elements of (x, y) coordinates 
const randomDataSet = () => {
  return Array.apply(null, {length: numDataPoints}).map(() => [randomNum(), randomNum()]);
}

// Returns a pair of random gaussian numbers
const randomGaussNum = (mu, sigma) => {
  // Generate pair of independent random uniformly distributed variables
  // within interval (0,1).
  let u1 = Math.random();
  let u2 = Math.random();

  // Transform u1 and u2 to independent random variables with a standard 
  // normal distribution.
  let z0 = Math.sqrt(-2 * Math.log(u1)) * Math.cos(2 * Math.PI * u2);
  let z1 = Math.sqrt(-2 * Math.log(u1)) * Math.sin(2 * Math.PI * u2);

  // Transform standard normal deviate, z0, to a value within a normal
  // distribution with mean, mu, and standard deviation, sigma.
  return z0 * sigma + mu;
}

// Creates an array of random normally distrubted test scores with mean, mu,
// and standard deviation, sigma.
const randomGaussDataSet = (mu, sigma) => {
  console.log('From CHART: ', Array.apply(null, {length: numDataPoints}).map(() => randomGaussNum(mu, sigma)));
  return Array.apply(null, {length: numDataPoints}).map(() => randomGaussNum(mu, sigma));
}
// ----------------------------------------------------------------------------


class Chart extends React.Component {
  constructor(props) {
    super(props);
    this.state = { 
      data: randomDataSet(),
      currentClassId: this.props.currentClassId,
      currentClassName: this.props.currentClassName,
      gaussData: this.props.classTestData
    };
  }

  randomizeData() {
    this.setState({ data: randomDataSet() });
  }

  render() {
    return (
      <div>
        <h1>{this.props.currentClassName} - MidTerm 1</h1>
        <ScatterPlot {...this.state} {...styles} />
        <Histogram {...this.state} {...styles} />
        <BarChart {...this.state} {...styles} />
        <div className="controls">
          <button className="btn randomize" onClick={() => this.randomizeData()}>
            Randomize Data
          </button>
        </div>
      </div>
    );
  }
};

export default Chart
{'fraction_non_alphanumeric': 0.21730455287502268, 'fraction_numerical': 0.015236713223290404, 'mean_word_length': 2.2189141856392296, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 40, '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': '1358928', 'n_tokens_mistral': 1612, 'n_tokens_neox': 1537, 'n_words': 475}