美文网首页
react-highcharts 画3d饼图

react-highcharts 画3d饼图

作者: louhangfei | 来源:发表于2017-09-29 10:45 被阅读0次

    首先要用安装highcharts-3d

    npm i -S highcharts-3d
    

    引入的时候要注意:

    import highcharts3d from 'highcharts/highcharts-3d';
    highcharts3d(ReactHighcharts.Highcharts);
    

    完整代码:

    
    import ReactHighcharts from 'react-highcharts';
    import highcharts3d from 'highcharts/highcharts-3d';
    highcharts3d(ReactHighcharts.Highcharts);
    render() {
        const {title } = this.props;
        const config = {
          chart: {
            type: 'pie',
            options3d: {
              enabled: true,
              alpha: 45,
              beta: 0,
            },
          },
          title: {
            text: title,
          },
          colors: ['#629ef8', '#51d89d', '#a79ae7'],
        
          },
          series: [{
            name: '用餐次数',
            data: [
                    {name: '1', y: 400},
                    {name: '2', y: 1000},
                    {name: '3', y: 100},
    
            ],
          }],
        };
        return <ReactHighcharts config={config} ref="chart" />;
      }
    

    相关文章

      网友评论

          本文标题:react-highcharts 画3d饼图

          本文链接:https://www.haomeiwen.com/subject/ejzbextx.html