简体   繁体   English

如何删除y轴线并格式化谷歌列图表中的y轴值

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

Im using google column chart in my application in my chart i need to remove the tiny space between my blue and grey bars and also to format the y axis values. 我在我的图表中的应用程序中使用谷歌列图表我需要删除我的蓝色和灰色条之间的微小空间,并格式化y轴值。 Please suggest me, how to remove that tiny gap between them. 请建议我,如何消除它们之间的微小差距。 My Chart 我的图表 在此输入图像描述

Code for the chart 图表代码

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);

Updated 更新

How to remove the yaxis line and need to format the y axis value like $10, $15, $30. 如何删除y轴线并需要格式化y轴值,如$ 10,$ 15,$ 30。 Is there any way to do that in column chart package. 在柱形图包中有没有办法做到这一点。 The link i'have refered to do the chart is this 我已经提到做图表的链接就是这个

You can add the following to your options object: bar: {groupWidth: '100%'} . 您可以将以下内容添加到options对象: bar: {groupWidth: '100%'}

This will remove the gap between your gray and your blue bar. 这将消除灰色和蓝色条之间的差距。

All options are also listed in the documentation . 所有选项也列在文档中

First off, don't use the old version of the ColumnChart; 首先,不要使用旧版本的ColumnChart; it is deprecated and doesn't offer any features that the newer version doesn't also have. 它已被弃用,并不提供新版本不具备的任何功能。 Load it like this: 加载它像这样:

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

To format the axis values, you need to use the vAxis.format option: 要格式化轴值,需要使用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