How to use plugins with chartist.js?

前端 未结 2 2028
轻奢々
轻奢々 2021-01-22 19:20

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

2条回答
  •  臣服心动
    2021-01-22 19:42

    You can use the plugin by adding it on the options property, but first you need to import the ff. dependencies:

    import React, { Component } from 'react';
    import ChartistGraph from "react-chartist";
    import Legend from "chartist-plugin-legend";
    

    add the plugin:

    let options = {
        width:400,
        height:500,
        plugins: [
            Legend()
        ]
    };
    

    Render it:

    and because the CSS is not included, you can examine the index file of the plugin here and play with it.

提交回复
热议问题