forked from @vx/legend and maintaining it for further usage.
npm install --save react-d3-legends
yarn add react-d3-legends
Legends associate shapes and colors to data.
// legends for linear scales; // legends for quantile scales; // legends for ordinal scales; // legends for size scales; // legends for threshold scales; // custom legends;
API
LegendLinear
LegendQuantile
LegendOrdinal
LegendThreshold
LegendSize
Legend
supported Shapes: circle, square, rectangle, triangle-up, triangle-down, diamond, cross
Example
; { return <div> <svg>/** chart stuff */</svg> <div style= width: "100%" display: "flex" justifyContent: "center" fontSize: "14px" onClick=thislegendClick > <Legend scale=colorScale direction="row" labelMargin="0 15px 0 0" shape=customPointShape /> </div> </div> ;}