import React, { Component } from 'react'; import * as _ from 'lodash'; import { RadialBarChart, RadialBar, Cell, Legend, Tooltip, ResponsiveContainer, LabelList, PolarAngleAxis } from 'recharts'; import { changeNumberOfData } from './utils'; import { scaleOrdinal } from 'd3-scale'; import { schemeCategory10 } from 'd3-scale-chromatic'; const colors = scaleOrdinal(schemeCategory10).range(); const data = [ { name: '18-24', uv: 60, amt: 31.47, pv: 2400, fill: '#8884d8' }, { name: '25-29', uv: 50, amt: 26.69, pv: 4500, fill: '#83a6ed' }, { name: '30-34', uv: 30, amt: 15.69, pv: -1398, fill: '#8dd1e1' }, { name: '35-39', uv: 59, amt: 8.22, pv: 2800, fill: '#82ca9d' }, { name: '40-49', uv: 48, amt: 8.63, pv: 1908, fill: '#a4de6c' }, { name: '50+', uv: 62, amt: 2.63, pv: -2800, fill: '#d0ed57' }, { name: 'unknown', uv: 38, amt: 6.67, pv: 4800, fill: '#ffc658' }, ]; const initialState = { data }; export default class Demo extends Component { static displayName = 'RadialBarChartDemo'; state = initialState; chartRef = React.createRef(); handleChangeData = () => { this.setState(() => _.mapValues(initialState, changeNumberOfData)); }; componentDidMount() { if (this.chartRef) { console.log(this.chartRef.current.getItemByXY({ x: 150, y: 100 })) } } render () { const { data } = this.state; const style = { lineHeight: '24px', left: 300, }; const label = { orientation: 'outer' }; return (
change data

RadialBarChart

{ data.map((entry, index) => ( )) }

RadialBarChart with positive and negative value

RadialBarChart which has two RadialBar

RadialBarChart wrapped by ResponsiveContainer

Stacked RadialBarChart wrapped by ResponsiveContainer

{ data.map((entry, index) => ( )) } { data.map((entry, index) => ( )) }
); } }