<commit_before>/* @flow */
import React, {Component, PropTypes} from 'react';
import { contains, transpose, compose, map, update, assoc, last } from 'ramda';
import { round } from '../selectors/WeightSelectors';
import NVD3Chart from 'react-nvd3';
import CardContainer from './CardContainer';

export default class FailRatesByStageGraph extends Component {
  // $FlowIssue
  static propTypes = {
    failRatesByStage: PropTypes.array.isRequired
  };

  toGraphData(stagesData: any): any {
    const stages = stagesData.map(
      (stageData, index) => ({
        key: `Stage ${index + 1}`,
        values: stageData
      })
    );
    const lastIndex = stages.length - 1;
    return update(lastIndex, compose(assoc('key', 'Passed'), last)(stages), stages);
  };

  render(): any {
    const { failRatesByStage } = this.props;
    const graphData = this.toGraphData(failRatesByStage);
    return (<commit_msg>Give end stage graph some colours that match the theme<commit_after>/* @flow */
import React, {Component, PropTypes} from 'react';
import { contains, transpose, compose, map, update, assoc, last } from 'ramda';
import { round } from '../selectors/WeightSelectors';
import NVD3Chart from 'react-nvd3';
import CardContainer from './CardContainer';

export default class FailRatesByStageGraph extends Component {
  // $FlowIssue
  static propTypes = {
    failRatesByStage: PropTypes.array.isRequired
  };

  toGraphData(stagesData: any): any {
    const colors = ["#2196F3","#81a4d0","#ff5252","#FF7575","#4f47b4","#918bdf"];
    const stages = stagesData.map(
      (stageData, index) => ({
        key: `Stage ${index + 1}`,
        values: stageData,
        color: index === stagesData.length - 1 ? "#EDEDED" : colors[index]
      })
    );
    const lastIndex = stages.length - 1;
    return update(lastIndex, compose(assoc('key', 'Passed'), last)(stages), stages);
  };

  render(): any {
    const { failRatesByStage } = this.props;
    const graphData = this.toGraphData(failRatesByStage);
    return (
{'fraction_non_alphanumeric': 0.14030738720872582, 'fraction_numerical': 0.01636093207734259, 'mean_word_length': 3.7819905213270144, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '5203161', 'n_tokens_mistral': 645, 'n_tokens_neox': 624, 'n_words': 166}