echarts icon indicating copy to clipboard operation
echarts copied to clipboard

BarChart bar is moved outside of container and overlaps with yAxis labels.

Open sobolev-alexey opened this issue 9 years ago • 15 comments

One-line summary [问题简述]

Scaled bar element is getting to wide and overlaps with yAxis labels. See screenshots

Version & Environment [版本及环境]

  • ECharts version [ECharts 版本]: 3.6.1
  • Browser version [浏览器类型和版本]: Chrome 59.0.3071.86 (Official Build) (64-bit)
  • OS Version [操作系统类型和版本]: macOS Sierra 10.12.5

Expected behaviour [期望结果]

ECharts option [ECharts配置项]

Other comments [其他信息]

barchart_width

image

image

sobolev-alexey avatar Jun 12 '17 15:06 sobolev-alexey

xAxis.boundaryGap: true ?

pissang avatar Jun 14 '17 10:06 pissang

@pissang yes, other xAxis configs:

Data.map(({ data }, index) =>
 echarts.util.merge({
    type: 'value',
    data: data,
    minInterval: 5,
    splitNumber: 4,
    min: 0,
    max: maxValue,
    gridIndex: index,
    axisLine: { onZero: false },
    axisTick: { show: false },
    axisLabel: {
      show: true,
      margin: 5,
    },
    splitLine: { show: false },
    showMinLabel: false,
    boundaryGap: true,
  }, options, true)
)

sobolev-alexey avatar Jun 14 '17 11:06 sobolev-alexey

Can you put the code on the jsfiddle? thanks.

pissang avatar Jun 14 '17 12:06 pissang

sure, I posted the code here: http://gallery.echartsjs.com/editor.html?c=xHkwrlhAz-&v=1 If you zoom and scroll to the right, you'll see the orange bar overlaps with yAxis. Screenshot attached. barchart

sobolev-alexey avatar Jun 14 '17 12:06 sobolev-alexey

Great. Will check it out!

pissang avatar Jun 15 '17 08:06 pissang

Found you are using time type in xAxis. time axis is continuous and much more like value type. You should use category type xAxis when using bar series. Or use line series instead if you insist on time xAxis.

pissang avatar Jun 15 '17 08:06 pissang

Thanks, @pissang, changing type to category fixed the issue.

sobolev-alexey avatar Jun 15 '17 16:06 sobolev-alexey

Another option is to use offset for yAxis. Which will move yAxis to left side hence creating more space for bar. You may also need to limit bar width by barMaxWidth in bar series options.

ahmadalibaloch avatar Oct 08 '18 16:10 ahmadalibaloch

Overlapping Issue Charts

Can you please help me, why bars are overlapping? I am using xAxis.type = time.

gshikhar94 avatar Apr 24 '19 11:04 gshikhar94

any updates?

arashkevich25 avatar May 06 '20 10:05 arashkevich25

@pissang @Ovilia : any updates on this ? can we using time as type for XAxis for bar charts in the near future ?

mnischay avatar Sep 07 '23 15:09 mnischay

any updates? Having the same issue now. I need the axis to be of type time because the data I'm displaying is coming from an API and is not always evenly spaced (e.g. it can be 1 hour apart for multiple datapoints then suddenly 3 days apart).

Switching the xAxis to category, when the axis should be time, only works if the time difference between each datapoint is evenly spaced.

Using offset and barMaxWidth works for some times, but not others (particularly when there's little data to display).

It'd be awesome if the outside of the chart could be on a different zLevel, for example, so that the bars would just be hidden underneath it when it overflows. I'm thinking of dealing with it by passing the data to the xAxis (e.g. ["2022-01-01T00:00:00.000Z", "2022-01-01T01:00:00.000Z", "2022-01-01T02:00:00.000Z", ...]) so that the "type:category" works, if there are no updates.

Here's what I'm working on for reference: image

hdonati-CFU avatar Aug 09 '24 17:08 hdonati-CFU

any updates?

Zit8 avatar Aug 14 '24 12:08 Zit8

any updates?

Feroks avatar Mar 10 '25 09:03 Feroks

any updates?

alinscodes avatar Mar 12 '25 10:03 alinscodes