开发中遇到的echarts常见问题

发布时间 2023-11-18 16:02:21作者: Baipei

柱状图legend不出现

①没有配置legend中的data属性
②data的name属性与series的name属性不同

设置legend阴影
         itemStyle: {
                    opacity: 1,
                    shadowColor: "rgba(255, 255, 255, 1)",
                    shadowOffsetX: 0,
                    shadowOffsetY: 0,
                    shadowBlur: 0,
                    borderCap: "butt"  
                }

饼图内部设置百分比

                label: {
                    //echarts饼图内部显示百分比设置
                    show: true,
                    position: "inside", //outside 外部显示  inside 内部显示
                    formatter: `{d}%`,
                    color: "#ffffff", //颜色
                    fontSize: 12 //字体大小
                },

如何配置echarts响应式

多个echarts图就在每个图都配这个方法
        window.addEventListener("resize", function() {
            charts.resize();
        });

echarts刷新后会变空白

多个echarts图就在每个图都配这个方法

document.querySelector('.某某类).setAttribute('_echarts_instance_', '');

如何调整echarts图在框中的位置

使用grid属性

[ECharts] DEPRECATED: itemStyle.normal.lineStyle is deprecated, use lineStyle instead.

原因是normal已经弃用了,在代码中删掉就行

Can’t get DOM width or height. Please check dom.clientWidth and dom.clientHeight. They should not be 0.For example, you may need to call this in the callback of window.onload.
没有设置高度,需要设置height

hoverAnimation报错

hoverAnimation在5.0版本已经弃用了,在series中换如下代码

        emphasis:{
            scale: false,
            }