user2301515
user2301515

Reputation: 5117

Multiple lines of axislabel in echarts

enter image description here Does anybody know. How to make a multiple lines of axis label with Echart (https://echarts.apache.org/examples/en/)? I need a group label (year, season, ..) and vertical lines for separating groups. Thank you.

Upvotes: 2

Views: 4549

Answers (1)

Sergey Fedorov
Sergey Fedorov

Reputation: 4450

  1. Vertical lines can draw with markLine, see example.
  2. Just add second xAxis with desired labels, something like this:

  var myChart = echarts.init(document.getElementById('main'));
  var option = {
      tooltip: {},
      xAxis: [{
        data: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
      },{
        position: 'bottom',
        offset: 30,
        axisLine: {
            show: false,
        },
        axisTick: {
            show: false,
        },
        data: ['Winter', 'Spring', 'Summer', 'Autumn']
      }],
      yAxis: {},
      series: [{
        name: 'Series',
          type: 'bar',
          data: [5, 20, 36, 10, 10, 20,5, 20, 36, 10, 10, 20]
      }]
  };

  myChart.setOption(option);
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/echarts.min.js"></script>
<div id="main" style="width: 1024px;height:400px;"></div>

Upvotes: 6

Related Questions