Echarts column width adaptive browser width, no overlap

problem description

column width can only be adapted according to browser width, for example, there are 10 columns. When initializing the display, if the browser width is small, then the columns must not overlap.

the environmental background of the problems and what methods you have tried

The api of a bar chart in

echart has a barWidth. How to write the dynamic width

related codes

/ / Please paste the code text below (do not replace the code with pictures)
series: [

    {
      data: yArr,
      type: "bar",
      barWidth: "40",
      barCategoryGap: "0",
      itemStyle: {
        normal: {
          color: function (params) {
            var colorList = color;
            return colorList[params.dataIndex];
          }
        }
      }
    },{
      data: varianceArr,
      type: "line",
      yAxisIndex: 1,
    }
  ]

what result do you expect? What is the error message actually seen?

expect to see that when the browser width is small, the columns are not coincident. The number of columns is returned from the interface data, maybe 10 or more, not fixed

Jun.30,2022

the bar chart itself is adaptive width


can make an adaptation, similar to this

clipboard.png

Menu