簡體   English   中英

如何通過Y軸0值畫一條線

[英]How to draw a line through Y axis 0 value

如果存在負值,我需要創建一條線以顯示在Y軸上為零。 我需要這樣做,因為我已禁用了Y軸上的標簽,並希望通過一行顯示它為0,並將負值與正值分開。

在此處輸入圖片說明

使用plotLines繪制直線,將值設置為0:

plotLines: [{
            color: '#000000',
            width: 1,
            value: 0
        }],

這是一個演示:

 $(function () { $('#container').highcharts({ chart: { type: 'column' }, title: { text: 'Column chart with negative values' }, xAxis: { categories: ['Apples', 'Oranges', 'Pears', 'Grapes', 'Bananas'] }, credits: { enabled: false }, series: [{ name: 'John', data: [5, 3, 4, 7, 2] }, { name: 'Jane', data: [2, -2, -3, 2, 1] }, { name: 'Joe', data: [3, 4, 4, -2, 5] }], yAxis:{ gridLineWidth: 0, plotLines: [{ color: '#000000', width: 1, value: 0 }], labels: { enabled: false } } }); }); 
 rect { stroke-width:0; } 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="https://code.highcharts.com/highcharts.js"></script> <script src="https://code.highcharts.com/modules/exporting.js"></script> <div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div> 

PS:此條形圖的代碼不是我的,我從Highcharts的網站上復制了它: http ://www.highcharts.com/demo/column-negative

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM