import { Component } from "react";

export class Donut extends Component {
    render() {
        let teamColors = undefined
        let tmp = []
        if (this.props.data.length > 0 && this.props.data[0].team) {
            this.props.data.forEach(element => {
                tmp.push(element.team === this.props.data.array[0].team ? "#3b3bd4" : "#d43b3b")
            });
        }
        if (tmp !== []) {
            teamColors = tmp
        }

        let chart = DonutChart(this.props.data, {
            name: d => d.name,
            value: d => d.count,
            width,
            height: 400,
            colors: teamColors
        })

        return (
            {chart}
        )
    }
}