react-dc-js
react-dc-js copied to clipboard
How we use legend in PieChart
How we use legend in PieChart?
Please share example code for the same
@slgauravsharma The legend can be used in a similar way standard dc.js
For example, from App.js in the playground:
import * as dc from 'dc'
<PieChart
dimension={gainOrLoss}
group={gainOrLossGroup}
width={180}
height={180}
radius={80}
legend={dc.legend()}
/>
Or something slightly more custom:
<PieChart
dimension={gainOrLoss}
group={gainOrLossGroup}
width={250}
height={180}
radius={80}
legend={new dc.Legend().itemHeight(20).gap(5)}
/>
Adding to the comment above, ideally, this would soon become a feature (avoiding the use of dc directly), such as:
legend={{
itemHeight: 20,
gap: 5
}}
or even
legendItemHeight={20}
legendGap={5}