import * as _ from 'lodash'; import React, { Component } from 'react'; import { Radar, RadarChart, PolarGrid, Legend, Tooltip, PolarAngleAxis, PolarRadiusAxis, ResponsiveContainer, LabelList } from 'recharts'; import { changeNumberOfData } from './utils'; const data = [ { subject: 'Math', A: 120, B: 110, C: [80, 120] }, { subject: 'Chinese', A: 98, B: 130, C: [90, 113] }, { subject: 'English', A: 86, B: 130, C: [70, 134] }, { subject: 'Geography', A: null, B: 100, C: [88, 130] }, { subject: 'Physics', A: 85, B: 90, C: [55, 110] }, { subject: 'History', A: 65, B: 85, C: [60, 120] }, ]; const initialState = { data }; export default class Demo extends Component { static displayName = 'RadarChartDemo'; constructor(props: any) { super(props); this.state = initialState; this.handleChangeData = this.handleChangeData.bind(this); } handleChangeData() { this.setState(() => _.mapValues(initialState, changeNumberOfData)); } handleMouseEnter(props: any) { console.log(props); } render() { const { data } = this.state; return (
change data

A simple RadarChart

A range RadarChart

A RadarChart of two students' score

RadarChart wrapped by ResponsiveContainer

); } }