Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to minimize whitespace around Baidu's echarts

I'm trying to incorporate Baidu's echarts (which look really good). However, there is a lot of whitespace around the actual graph when one doesn't set a title nor uses their toolbar. Is there a way to have the graph/chart use more of the canvas?

My current solution to add an extra inside the container one and then set it's width and height to be be bigger by the margins I want to remove and the offset it by setting 'top' and 'left' to negative values of the respective margins. Not elegant and more importantly, not robust, but it works for the moment.

like image 342
max.ott Avatar asked Jan 21 '15 11:01

max.ott


3 Answers

In ECharts 4, 5

As mentioned by some other posters, the correct way to get rid of the whitespace is to change options.grid.

https://echarts.apache.org/en/option.html#grid

grid: {
  left: 0,
  top: 0,
  right: 0,
  bottom: 0
}

In ECharts 4, the names of the grid properties have been changed to left, right, top, and bottom.

Thanks to the answers above for pointing me in the right direction!

Further, changing the option.legend, as suggested above, had no effect on my chart.

like image 79
bjornl Avatar answered Oct 07 '22 06:10

bjornl


You can use the properties defined on the grid (x, y, x2 and y2). These properties are mentioned on the documentation: http://echarts.baidu.com/doc/doc-en.html#Grid

like image 43
arbc Avatar answered Oct 07 '22 04:10

arbc


In ECharts 3 you can use the options grid.left, grid.top, grid.right and/or grid.bottom. According to the documentation, left and right default to 10%, and top and bottom default to 60 (px).

Documentation: https://ecomfe.github.io/echarts-doc/public/en/option.html#grid.

const option = {
  // these are the grid default values
  grid: {
    top:    60,
    bottom: 60,
    left:   '10%',
    right:  '10%',
  },
  // your other options...
}
like image 7
sierrasdetandil Avatar answered Oct 07 '22 05:10

sierrasdetandil