I am using chartist.js for making pie chart component. I want to make use of legend plugin https://codeyellowbv.github.io/chartist-plugin-legend/
I am not getting the le
Try folowing as the chartist-plugin-legend return Chartist.plugins.legend function. You can pass options also to add customization here is link where you can read it: Link chartist-plugin-legend
let plugins = [
Legend()
]
Made this change also as react-chartist doesnot take any props called plugins.
Now add a .css file in your directory and import it in your component file. with following content. The content is same as mentioned on the plugin page.
.ct-legend {
position: relative;
z-index: 10;
li {
position: relative;
padding-left: 23px;
margin-bottom: 3px;
}
li:before {
width: 12px;
height: 12px;
position: absolute;
left: 0;
content: '';
border: 3px solid transparent;
border-radius: 2px;
}
li.inactive:before {
background: transparent;
}
&.ct-legend-inside {
position: absolute;
top: 0;
right: 0;
}
@for $i from 0 to length($ct-series-colors) {
.ct-series-#{$i}:before {
background-color: nth($ct-series-colors, $i + 1);
border-color: nth($ct-series-colors, $i + 1);
}
}
}
Now you can give styling as you want. legend plugin also provides certains options that you can send. Read about it and accordingly pass in the options