简体   繁体   English

避免 eCharts 中的图例重叠条形图

[英]Avoid legend overlap bar graph in eCharts

I've using eCharts 3 by baidu to build a stacked bar graph but the legend always overlaps the graph.我使用百度的 eCharts 3 构建了堆积条形图,但图例总是与图表重叠。 What I want to do is to move the graph to the left so the legend would have enough space and won't overlap the graph but I can't find the solution.我想要做的是将图表向左移动,以便图例有足够的空间并且不会与图表重叠,但我找不到解决方案。 This is my graph right now这是我现在的图表在此处输入图像描述

I've just solved it! 我刚解决了! To handle the space for the graphs you have to tune the grid. 要处理图形的空间,您必须调整网格。 Setting 设置

myChart.setOption({
    grid: { 
    right: '17%'
     }
    });

Just made enough space to place the legend without overlapping it. 只需留出足够的空间放置图例而不重叠它。

I work in angular and I solved it by separating the chart into 2 component, one is a component where I draw the legend by myself and one is to draw pie only using echarts.我在 angular 工作,我通过将图表分成 2 个组件来解决它,一个是我自己绘制图例的组件,一个是仅使用 echarts 绘制饼图的组件。 both are contained under a parent component having display: flex where I have flex-grow: 1 for the pie child component.两者都包含在具有 display: flex 的父组件下,其中我有 flex-grow: 1 用于 pie 子组件。 this solved the responsiveness issue for me.这为我解决了响应能力问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM