echarts icon indicating copy to clipboard operation
echarts copied to clipboard

柱状图series中的data个数不一致时溢出

Open waiting0729 opened this issue 8 years ago • 2 comments

One-line summary [问题简述]

我使用echarts官方的例子:http://echarts.baidu.com/examples/editor.html?c=bar-y-category-stack 发现一个问题:这几个柱形的series中的data个数不一致的时候会出现溢出,柱形图不会随个数自由伸缩

Version & Environment [版本及环境]

  • ECharts version [ECharts 版本]:4.1.0
  • Browser version [浏览器类型和版本]:chrome
  • OS Version [操作系统类型和版本]:windows

Expected behaviour [期望结果]

期望柱形图随data数量伸缩

ECharts option [ECharts配置项]

option = {

    tooltip : {
        trigger: 'axis',
        axisPointer : {            // 坐标轴指示器,坐标轴触发有效
            type : 'shadow'        // 默认为直线,可选为:'line' | 'shadow'
        }
    },
    legend: {
        data: ['直接访问', '邮件营销','联盟广告','视频广告','搜索引擎']
    },
    grid: {
        left: '3%',
        right: '4%',
        bottom: '3%',
        containLabel: true
    },
    xAxis:  {
        type: 'value'
    },
    yAxis: {
        type: 'category',
        data: ['周一','周二','周三','周四','周五','周六','周日']
    },
    series: [
        {
            name: '直接访问',
            type: 'bar',
            stack: '总量',
            label: {
                normal: {
                    show: true,
                    position: 'insideRight'
                }
            },
            data: [320, 302, 301, 334,  330, 320]
        },
        {
            name: '邮件营销',
            type: 'bar',
            stack: '总量',
            label: {
                normal: {
                    show: true,
                    position: 'insideRight'
                }
            },
            data: [120, 132, 101, 134, 90, 230, 210]
        },
        {
            name: '联盟广告',
            type: 'bar',
            stack: '总量',
            label: {
                normal: {
                    show: true,
                    position: 'insideRight'
                }
            },
            data: [220, 182, 191, 234, 290, 330, 310]
        },
        {
            name: '视频广告',
            type: 'bar',
            stack: '总量',
            label: {
                normal: {
                    show: true,
                    position: 'insideRight'
                }
            },
            data: [150]
        },
        {
            name: '搜索引擎',
            type: 'bar',
            stack: '总量',
            label: {
                normal: {
                    show: true,
                    position: 'insideRight'
                }
            },
            data: [820, 832, 901, 934, ]
        }
    ]

}

image 如上图,图形不能正确的反映几个series中data里面的数据

Other comments [其他信息]

waiting0729 avatar Sep 14 '18 10:09 waiting0729

这是预期的展现,你希望的展现方式是什么?

pissang avatar Sep 15 '18 04:09 pissang

感谢回复,我这个问题已经解决了。 搭个楼借问另外一个问题: 想实现禁用掉legend的点击事件(主要不想要在饼图情况下点击图例取消该图例响应的占比),但是保留hover事件 在实现过程中发现,用了selectedMode: false,后hover事件也会被禁用掉 准备监听legendselectchanged事件,代码: myChart.on('legendselectchanged', function (params) { console.log('legendselectchanged') var option = myChart.getOption(); console.log(option) myChart.setOption(option) }); 发现还是会取消相应的比例,这种有没有好的方法解决?

waiting0729 avatar Sep 17 '18 07:09 waiting0729