how to set the height of a bar chart in Echarts

To set the height of a bar chart in ECharts, you can specify the height of the chart using the height attribute within the grid property.

Here is a simple example:

// 引入 ECharts
import echarts from 'echarts';

// 初始化图表
const chart = echarts.init(document.getElementById('chart'));

// 配置图表参数
const option = {
  grid: {
    height: 200 // 设置图表的高度为200像素
  },
  xAxis: {
    type: 'category',
    data: ['Category 1', 'Category 2', 'Category 3', 'Category 4', 'Category 5']
  },
  yAxis: {
    type: 'value'
  },
  series: [{
    type: 'bar',
    data: [100, 200, 300, 400, 500]
  }]
};

// 渲染图表
chart.setOption(option);

In the example above, you can adjust the height of the chart to 200 pixels by setting the grid.height property to 200. Feel free to customize this value as needed.

bannerAds