Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/263.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在谷歌图表中,X轴有多个值和条形图宽度不受影响_Javascript_Php_Jquery_Google Visualization - Fatal编程技术网

Javascript 在谷歌图表中,X轴有多个值和条形图宽度不受影响

Javascript 在谷歌图表中,X轴有多个值和条形图宽度不受影响,javascript,php,jquery,google-visualization,Javascript,Php,Jquery,Google Visualization,我对谷歌图表没有很好的经验。 我用的是柱状图。下面是我的代码: google.charts.load('current', {'packages':['corechart','bar']}); var data = new google.visualization.arrayToDataTable(data_to_display); var options={ bar:{ groupWidth: '20'

我对谷歌图表没有很好的经验。 我用的是柱状图。下面是我的代码:

google.charts.load('current', {'packages':['corechart','bar']});
var data = new google.visualization.arrayToDataTable(data_to_display);
        var options={
            bar:{
                groupWidth: '20'
            },
            bars:'vertical',
            hAxis:{
                title:'Number of Visits',
                slantedText:false,
                titleTextStyle: {
                    fontSize: 14,
                    bold: false,
                    italic: false,
                    // The color of the text.
                    color: '#3a3a3a',
                },
                format: '0',
            },
            vAxis: {
                title: 'Customer Count',
                titleTextStyle: {
                    fontSize: 14,
                    bold: false,
                    italic: false,
                    // The color of the text.
                    color: '#3a3a3a',
                },
                format: '0',
                // The color of the text outline.
            },
            legend: { position: legendPosition },
            height: 370,
            tooltip: { isHtml: true }, 
            /*seriesType: 'bars',
            series: {5: {type: 'line'}}*/
        };
var chart = new google.visualization.ColumnChart(document.getElementById(element_id));
        chart.draw(data, options);
我正在按照以下结构传递JSON数据:

[["Customer Count","Number of Visits",{"type":"string","role":"tooltip","p":{"html":"true"}}],[2,1,"<div style=\"width:130px;\"><b>Number of Visits :</b> 2</div><div style=\"width:130px;\"><b>Customer Count :</b> 1</div>"],[3,3,"<div style=\"width:130px;\"><b>Number of Visits :</b> 3</div><div style=\"width:130px;\"><b>Customer Count :</b> 3</div>"],[2,5,"<div style=\"width:130px;\"><b>Number of Visits :</b> 2</div><div style=\"width:130px;\"><b>Customer Count :</b> 5</div>"],[1,6,"<div style=\"width:130px;\"><b>Number of Visits :</b> 1</div><div style=\"width:130px;\"><b>Customer Count :</b> 6</div>"],[1,8,"<div style=\"width:130px;\"><b>Number of Visits :</b> 1</div><div style=\"width:130px;\"><b>Customer Count :</b> 8</div>"],[1,10,"<div style=\"width:130px;\"><b>Number of Visits :</b> 1</div><div style=\"width:130px;\"><b>Customer Count :</b> 10</div>"],[1,12,"<div style=\"width:130px;\"><b>Number of Visits :</b> 1</div><div style=\"width:130px;\"><b>Customer Count :</b> 12</div>"],[1,13,"<div style=\"width:130px;\"><b>Number of Visits :</b> 1</div><div style=\"width:130px;\"><b>Customer Count :</b> 13</div>"]]
[“客户数量”、“访问次数”、“类型”:“字符串”、“角色”:“工具提示”、“p”:{“html”:“true”}]、[2,1,“访问次数:2客户数量:1”]、[3,3”,“访问次数:3客户数量:3”]、[2,5”,“访问次数:2客户数量:5”]、[1,6”,“访问次数:1客户数量:6”、[1,8”,“访问次数:1客户数量:8”、[1,10],“访问次数:1客户数量:10”],[1,12,“访问次数:1客户数量:12”],[1,13,”访问次数:1客户数量:13”]
任何人都可以帮助我如何增加条形图的宽度。也不希望在X轴上多次显示值。请参阅附加的屏幕截图。

通常,没有数字/连续的X轴

这将取消
groupWidth
,因为您只有一个小勾号来绘制列

“客户计数”
的值更改为字符串将启用
groupWidth

请参阅下面的示例

google.charts.load('current'{
回调:函数(){
var data=google.visualization.arrayToDataTable([[“客户数量”、“访问次数”、{“类型”:“字符串”、“角色”:“工具提示”、“p”:“{“html”:“true”}],“2',1”,“访问次数:2客户数量:1”],['3',3,“访问次数:3客户数量:3”],['2',5,“访问次数:2客户数量:5”],['1',6,“访问次数:1客户数量:6”,['1',8,”访问数量:1客户数量:8”],['1',10,“访问数量:1客户数量:10”],['1',12,“访问数量:1客户数量:12”],['1',13,“访问数量:1客户数量:13”]);
排序([{column:0},{column:1}]);
新的google.visualization.ColumnChart(document.getElementById('chart\u div')).draw(
数据,
{
酒吧:{
群组宽度:20
},
工具提示:{
isHtml:是的
}
}
);
},
软件包:['corechart']
});

通常,没有数字/连续的x轴

这将取消
groupWidth
,因为您只有一个小勾号来绘制列

“客户计数”
的值更改为字符串将启用
groupWidth

请参阅下面的示例

google.charts.load('current'{
回调:函数(){
var data=google.visualization.arrayToDataTable([[“客户数量”、“访问次数”、{“类型”:“字符串”、“角色”:“工具提示”、“p”:“{“html”:“true”}],“2',1”,“访问次数:2客户数量:1”],['3',3,“访问次数:3客户数量:3”],['2',5,“访问次数:2客户数量:5”],['1',6,“访问次数:1客户数量:6”,['1',8,”访问数量:1客户数量:8”],['1',10,“访问数量:1客户数量:10”],['1',12,“访问数量:1客户数量:12”],['1',13,“访问数量:1客户数量:13”]);
排序([{column:0},{column:1}]);
新的google.visualization.ColumnChart(document.getElementById('chart\u div')).draw(
数据,
{
酒吧:{
群组宽度:20
},
工具提示:{
isHtml:是的
}
}
);
},
软件包:['corechart']
});