簡體   English   中英

如何刪除y軸線並格式化谷歌列圖表中的y軸值

[英]how to remove the y-axis line and format the value of the y-axis in google column chart

我在我的圖表中的應用程序中使用谷歌列圖表我需要刪除我的藍色和灰色條之間的微小空間,並格式化y軸值。 請建議我,如何消除它們之間的微小差距。 我的圖表 在此輸入圖像描述

圖表代碼

google.load("visualization", "1", {packages: ["columnchart"]});                
var datum=[];
                        datum=[[2,15,25]];
var data = google.visualization.arrayToDataTable([['column1', 'column2', 'column3']].concat(datum), false);
                            var options = {
                            legend: {position: 'none'},
                            colors: ['3399FF', 'C0C0C0'],
                            tooltip: {trigger: 'none'},
//                            vAxis: {minValue: 0, maxValue: maxValue, ticks: tick, format: '$'}
                            };
                                    var chart = new google.visualization.ColumnChart(document.getElementById('chart'));
                            chart.draw(data, options);

更新

如何刪除y軸線並需要格式化y軸值,如$ 10,$ 15,$ 30。 在柱形圖包中有沒有辦法做到這一點。 我已經提到做圖表的鏈接就是這個

您可以將以下內容添加到options對象: bar: {groupWidth: '100%'}

這將消除灰色和藍色條之間的差距。

所有選項也列在文檔中

首先,不要使用舊版本的ColumnChart; 它已被棄用,並不提供新版本不具備的任何功能。 加載它像這樣:

google.load('visualization', '1', {packages: ['corechart']});

要格式化軸值,需要使用vAxis.format選項:

var options = {
    legend: {position: 'none'},
    colors: ['3399FF', 'C0C0C0'],
    tooltip: {trigger: 'none'},
    vAxis: {
        format: '$#'
    }
};

暫無
暫無

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

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