<commit_before>/* eslint-disable react/forbid-prop-types */
/**
 * mSupply Mobile
 * Sustainable Solutions (NZ) Ltd. 2018
 */

import React from 'react';
import PropTypes from 'prop-types';
import { VictoryLabel, VictoryPie } from 'victory-native';

import { APP_FONT_FAMILY, GREY } from '../globalStyles';

export const PieChart = ({ width, height, data }) => {
  const { values } = data;
  const {
    padVertical,
    padHorizontal,
    innerRadius,
    labelRadius,
    padAngle,
    colorScale,
    style,
  } = victoryStyles.pieChart;

  const padding = {
    top: height * padVertical,
    bottom: height * padVertical,
    right: width * padHorizontal,
    left: width * padHorizontal,
  };

  const widthPadded = width * (1 - padHorizontal);
  return (
    <VictoryPie
      width={width}
      height={height}
      padding={padding}
      padAngle={padAngle}
      innerRadius={widthPadded * innerRadius}
      labelRadius={widthPadded * labelRadius}
      colorScale={colorScale}
      labelComponent={<VictoryLabel style={style} />}
      data={values[0]}
    />
  );
};

PieChart.propTypes = {
  width: PropTypes.number.isRequired,
  height: PropTypes.number.isRequired,
  data: PropTypes.array.isRequired,
};

const victoryStyles = {
  pieChart: {
    padVertical: 0.15,
    padHorizontal: 0.15,
    innerRadius: 0.2,
    labelRadius: 0.375,
    padAngle: 2.5,
    colorScale: 'warm',
    style: { fontFamily: APP_FONT_FAMILY, fill: GREY },
  },
};<commit_msg>Add map data to get values<commit_after>/* eslint-disable react/forbid-prop-types */
/**
 * mSupply Mobile
 * Sustainable Solutions (NZ) Ltd. 2018
 */

import React from 'react';
import PropTypes from 'prop-types';
import { VictoryLabel, VictoryPie } from 'victory-native';

import { APP_FONT_FAMILY, GREY } from '../globalStyles';

export const PieChart = ({ width, height, data }) => {
  const {
    padVertical,
    padHorizontal,
    innerRadius,
    labelRadius,
    padAngle,
    colorScale,
    style,
  } = victoryStyles.pieChart;

  const padding = {
    top: height * padVertical,
    bottom: height * padVertical,
    right: width * padHorizontal,
    left: width * padHorizontal,
  };

  const widthPadded = width * (1 - padHorizontal);
  return data.map(({ values }) => (
    <VictoryPie
      width={width}
      height={height}
      padding={padding}
      padAngle={padAngle}
      innerRadius={widthPadded * innerRadius}
      labelRadius={widthPadded * labelRadius}
      colorScale={colorScale}
      labelComponent={<VictoryLabel style={style} />}
      data={values}
    />
  ));
};

PieChart.propTypes = {
  width: PropTypes.number.isRequired,
  height: PropTypes.number.isRequired,
  data: PropTypes.array.isRequired,
};

const victoryStyles = {
  pieChart: {
    padVertical: 0.15,
    padHorizontal: 0.15,
    innerRadius: 0.2,
    labelRadius: 0.375,
    padAngle: 2.5,
    colorScale: 'warm',
    style: { fontFamily: APP_FONT_FAMILY, fill: GREY },
  },
};
{'fraction_non_alphanumeric': 0.128083812098682, 'fraction_numerical': 0.013180128421764109, 'mean_word_length': 3.1867043847241865, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 10, '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': '1324236', 'n_tokens_mistral': 1001, 'n_tokens_neox': 956, 'n_words': 216}