dyh333
dyh333

Reputation: 395

echarts: bar chart show the value on the right align

as the picture, I hope show the value in the right align, but did not found option. any help? thanks

demo-show

Upvotes: 1

Views: 2390

Answers (1)

Clocher Zhong
Clocher Zhong

Reputation: 2456

You can simply add another axis to achieve this, like demo below: It kind of like a trick.

let echartsObj = echarts.init(document.querySelector('#canvas'));
   
let seriesData = [1, 1, 2, 3, 4, 6, 8];

    option = {
        color: ['#3398DB'],
        grid: {
            containLabel: true
        },
        yAxis : [
            {
                type : 'category',
                data : ['192.168.167', '192.168.167', '192.168.167', '192.168.167', '192.168.167', '192.168.12.15', '192.168.167'],

            },
            {
                type : 'category',
                data : seriesData,
                axisLine: {
                    show: false
                },
                axisTick: {
                    show: false
                }
            }
        ],
        
        xAxis : [
            {
                type : 'value',
                 splitLine: {
                    show: false
                }
            }
        ],
        series : [
            {
                type:'bar',
                data:seriesData
            }
        ]
    };

    echartsObj.setOption(option)
<html>
      <header>
        <script src="https://cdn.bootcss.com/echarts/4.1.0.rc2/echarts-en.min.js"></script>
      </header>
      <body>
        <div id="canvas" style="width: 100%; height: 400px">
        </div>
      </body>
    </html>

Upvotes: 1

Related Questions