echarts中水球图插件的使用

本文详细介绍了如何在ECharts中使用液体填充图插件,并分享了遇到的错误解决方案,包括升级echarts到v4.9.0-S版本和引入echarts-liquidfill@2.0.6来实现预期的水球效果。
摘要由CSDN通过智能技术生成

echarts中水球图插件的使用

过程中的注意点:

1.报错:"export ‘default’ (imported as ‘echarts’) was not found in ‘echarts’

解决:echarts版本不行,下载 npm i echarts@4.9.0 -S

2.没有水球效果

解决: 下载这个版本 npm i echarts-liquidfill@2.0.6

<template>
    <div class="waveChart">
        <div class="chart" ref="SimpleChart" style="height:200px"></div>
    </div>
</template>
<script>
import echarts from "echarts";
import "echarts-liquidfill";

export default {
    name: "WaveChart",
    methods: {
        
        initChart() {
            //初始化图表
            let myChart = echarts.init(this.$refs.SimpleChart);
            let option = {
                title: {
                    text: "水球图",
                    textStyle: {
                        fontSize: 12,
                        // fontWeight: "bold",
                        color: "#FEFEFE",
                    },
                    x: "center",
                    y: "65%",
                },
                series: [
                    {
                        type: "liquidFill",
                        radius: "77%",
                        center: ["50%", "50%"],
                        data: [0.5,0.5],
                        backgroundStyle: {
                            borderWidth: 6,
                            borderColor: "rgba(17, 24, 48, 0.8)",
                            color: new echarts.graphic.LinearGradient(0, 1, 0, 0, [
                                { offset: 0, color: "#000" },
                                { offset: 1, color: "rgba(17, 24, 48, 0.6)" },
                            ]),
                        },
                        outline: {
                            show: false,
                        },
                        color: [
                            new echarts.graphic.LinearGradient(0, 1, 0, 0, [
                                { offset: 0, color: "#2475FD" },
                                { offset: 1, color: "#46B3FF" },
                            ]),
                            new echarts.graphic.LinearGradient(0, 1, 0, 0, [
                                { offset: 0, color: "#2475FD" },
                                { offset: 1, color: "#46B3FF" },
                            ]),
                        ],
                        label: {
                            normal: {
                                position: "top",
                                distance: -45,
                                fontSize: 20,
                                z: 10,
                                color: "#259DFF",
                                
                            },
                        },
                    },
                    {
                        type: "pie",
                        center: ["50%", "50%"],
                        radius: ["77%", "80%"],
                        hoverAnimation: false,
                        data: [
                            {
                                name: "",
                                value: 500,
                                labelLine: {
                                    show: false,
                                },
                                itemStyle: {
                                    color: "#2475FD",
                                },
                            },
                        ],
                    },
                ],
            };
            myChart.setOption(option);
        },
    },  
    mounted() {
        this.initChart();
    },
    
};
</script>
<style  scoped>
.waveChart {
    width: 100%;
    position: relative;
}
 .chart {
        width: 100%;
        height: 100%;
    }
</style>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值