diff options
Diffstat (limited to 'client/chart/singlePie.chart.js')
| -rw-r--r-- | client/chart/singlePie.chart.js | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/client/chart/singlePie.chart.js b/client/chart/singlePie.chart.js index fcff3214..ed2da582 100644 --- a/client/chart/singlePie.chart.js +++ b/client/chart/singlePie.chart.js @@ -2,15 +2,11 @@ import React, { Component } from 'react' import csv from 'parse-csv' import C3Chart from 'react-c3js' -import { toTuples } from '../util' - import 'c3/c3.css' import './chart.css' import { - rainbow, otherCountriesLabel, - institutionOrder, institutionLabels, - initialInstitutionLookup, + rainbow, bigRainbow } from './constants' class SinglePieChart extends Component { @@ -45,7 +41,6 @@ class SinglePieChart extends Component { } render() { - const { payload } = this.props const { keys, data, fields } = this.state console.log(keys, data) const [labelField, numberField] = keys @@ -59,15 +54,14 @@ class SinglePieChart extends Component { return [label, number] }).sort((a, b) => b[1] - a[1]) - console.log(rows) - let chartRows = rows.slice(0, rowsToDisplay) - let otherCount = rows.slice(rowsToDisplay).reduce((a, b) => { return a + b[1] }, 0) + let otherCount = rows.slice(rowsToDisplay).reduce((a, b) => a + b[1], 0) if (otherCount > 0) { chartRows.push([fields.OtherLabel, otherCount]) } - console.log(rowsToDisplay, chartRows) + const height = chartRows.length < 6 ? 316 : + chartRows.length < 10 ? 336 : 356 return ( <div className='chart'> @@ -78,7 +72,7 @@ class SinglePieChart extends Component { type: 'pie', }} color={{ - pattern: rainbow, + pattern: chartRows.length < 10 ? rainbow : bigRainbow, }} tooltip={{ format: { @@ -86,7 +80,7 @@ class SinglePieChart extends Component { } }} size={{ - height: chartRows.length < 4 ? 316 : 336, + height, }} /> <span className='chartCaption'>{fields.Caption}</span> |
