Nivo: Couple of questions about ResponsivePie

Created on 12 Jul 2019  路  2Comments  路  Source: plouc/nivo

  1. Is it possible to pass a list of custom colors to a ResponsivePie instead of using a color scheme? Something like <ResponsivePie colors={['white', 'black', 'green']}...
  2. How can I get the percent of a category? My data value is an integer. I was trying something like
    <ResponsivePie radialLabel={ function(e) { return e.id + Number.parseFloat(e.value/100).toFixed(1) + '%' } }...
pie question

Most helpful comment

And it turns out that the colors={} property does accept a list with custom colors so I was able to solve item #1 like this:

const chartColors = ['#0088FE', '#FF8042', '#00C49F', '#FFBB28'];
<ResponsivePie colors={chartColors}...

All 2 comments

I was able to solve item #2 by adding to my data a key called percent containing the proper percent value. I then add it to my radialLabel like radialLabel={ function(e) { return e.id + e.percent } }...

And it turns out that the colors={} property does accept a list with custom colors so I was able to solve item #1 like this:

const chartColors = ['#0088FE', '#FF8042', '#00C49F', '#FFBB28'];
<ResponsivePie colors={chartColors}...
Was this page helpful?
0 / 5 - 0 ratings