项目中使用ECharts,echarts-liquidfill 水球图

水波球
  1. 安装
    npm install echarts-liquidfill
    npm install --save echarts-for-react
    npm install --save echarts
  2. 如果出现这样的报错
npm WARN [email protected] requires a peer of echarts@^4.8.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of zrender@^4.3.1 but none is installed. You must install peer dependencies yourself.

解决办法

npm i echarts@^4.8.0 zrender@^4.3.1
  1. 如果出现这样的报错
Component series.liquidFill not exists. Load it first.

解决办法

import 'echarts-liquidfill/src/liquidFill.js'

4.使用
4.1. 引用依赖

import ReactEcharts from 'echarts-for-react'
import 'echarts-liquidfill/src/liquidFill.js'

4.2. 构建DOM


4.3. 常用的option有

项目中使用ECharts,echarts-liquidfill 水球图_第1张图片
如下为该图片的代码示例
var option = {
    series: [{
        type: 'liquidFill',
        data: [0.6]
    }]
};
项目中使用ECharts,echarts-liquidfill 水球图_第2张图片
如下为该图片的代码示例
var option = {
    series: [{
        type: 'liquidFill',
        data: [0.6, 0.5, 0.4, 0.3]
    }]
};
项目中使用ECharts,echarts-liquidfill 水球图_第3张图片
如下为该图片的代码示例
var option = {
    series: [{
        type: 'liquidFill',
        data: [0.5, 0.4, 0.3],
        color: ['red', '#0f0', 'rgb(0, 0, 255)'],
        itemStyle: {
                opacity: 0.6
        },
        emphasis: {
            itemStyle: {
                opacity: 0.9
            }
        }
    }]
};
项目中使用ECharts,echarts-liquidfill 水球图_第4张图片
如下为该图片的代码示例
var option = {
    series: [{
        type: 'liquidFill',
        data: [0.5, 0.4, {
            value: 0.3,
            itemStyle: {
                color: 'red',
                opacity: 0.6
            },
            emphasis: {
                itemStyle: {
                    opacity: 0.9
                }
            }
        }]
    }]
};
项目中使用ECharts,echarts-liquidfill 水球图_第5张图片
如下为该图片的代码示例
option = {
    series: [{
        type: 'liquidFill',
        data: [0.5, 0.4, 0.3, 0.2],
        shape: 'container',
        outline: {
            show: false
        }
    }]
};
项目中使用ECharts,echarts-liquidfill 水球图_第6张图片
如下为该图片的代码示例
var option = {
    series: [{
        type: 'liquidFill',
        data: [0.6, 0.55, 0.4, 0.25],
        radius: '60%',
        outline: {
            show: false
        },
        backgroundStyle: {
            borderColor: '#156ACF',
            borderWidth: 1,
            shadowColor: 'rgba(0, 0, 0, 0.4)',
            shadowBlur: 20
        },
        shape: 'path://M367.855,428.202c-3.674-1.385-7.452-1.966-11.146-1.794c0.659-2.922,0.844-5.85,0.58-8.719 c-0.937-10.407-7.663-19.864-18.063-23.834c-10.697-4.043-22.298-1.168-29.902,6.403c3.015,0.026,6.074,0.594,9.035,1.728 c13.626,5.151,20.465,20.379,15.32,34.004c-1.905,5.02-5.177,9.115-9.22,12.05c-6.951,4.992-16.19,6.536-24.777,3.271 c-13.625-5.137-20.471-20.371-15.32-34.004c0.673-1.768,1.523-3.423,2.526-4.992h-0.014c0,0,0,0,0,0.014 c4.386-6.853,8.145-14.279,11.146-22.187c23.294-61.505-7.689-130.278-69.215-153.579c-61.532-23.293-130.279,7.69-153.579,69.202 c-6.371,16.785-8.679,34.097-7.426,50.901c0.026,0.554,0.079,1.121,0.132,1.688c4.973,57.107,41.767,109.148,98.945,130.793 c58.162,22.008,121.303,6.529,162.839-34.465c7.103-6.893,17.826-9.444,27.679-5.719c11.858,4.491,18.565,16.6,16.719,28.643 c4.438-3.126,8.033-7.564,10.117-13.045C389.751,449.992,382.411,433.709,367.855,428.202z',
        label: {
            position: ['38%', '40%'],
            formatter: function() {
                return 'ECharts\nLiquid Fill';
            },
            fontSize: 40,
            color: '#D94854'
        }
    }]
};

更多配置请参考官方大大https://github.com/ecomfe/echarts-liquidfill

你可能感兴趣的:(项目中使用ECharts,echarts-liquidfill 水球图)