Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/85.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 谷歌列图表与组_Javascript_Jquery_Charts_Google Visualization - Fatal编程技术网

Javascript 谷歌列图表与组

Javascript 谷歌列图表与组,javascript,jquery,charts,google-visualization,Javascript,Jquery,Charts,Google Visualization,我的数据格式- ['Group','Count','Month','Year'], ['A',10,'February',2015], ['B',8,'February',2015], ['C',15,'February',2016] 我将使用一个过滤器来显示每个月的数据,以组列分隔 X轴将有组Y轴将在所有年份(2014年、2015年、2016年)进行计数 像这样的 我正在使用谷歌仪表板。我的代码- var dashboard = new google.visualization.Dashbo

我的数据格式-

['Group','Count','Month','Year'],
['A',10,'February',2015],
['B',8,'February',2015],
['C',15,'February',2016]
我将使用一个过滤器来显示每个月的数据,以组列分隔

X轴将有组Y轴将在所有年份(2014年、2015年、2016年)进行计数

像这样的

我正在使用谷歌仪表板。我的代码-

var dashboard = new google.visualization.Dashboard(document.getElementById('dashboard4_div'));
var slider = new google.visualization.ControlWrapper({
          'controlType': 'CategoryFilter',
          'containerId': 'filter4_div',
          'options': {
            'filterColumnLabel': 'Month',
            'ui': {
            'allowTyping': true,
            'allowMultiple': false,
            'allowNone': false,
            'sortValues': false,
            'label': 'Choose month',
        }
          }
        });

var ColumnChart = new google.visualization.ChartWrapper({
    'chartType': 'ColumnChart',
    'containerId': 'chart4_div',

// How to take in two column values 

});
dashboard.bind(slider, ColumnChart);

        // Draw the dashboard.
        dashboard.draw(data);

我想知道如何使用Google Charts在我的图表中添加两列值,因为在绘制图表之前需要对数据进行操作,
独立绘制类别过滤器和图表

使用
滑块的原始数据表

然后,当
滑块上出现
'ready'
'statechange'
事件时,
使用
selectedValues
筛选行

过滤后,使用
data.group
将年份从行转换为列

请参阅以下工作片段

google.charts.load('current'{
回调:函数(){
var data=google.visualization.arrayToDataTable([
[“组”、“计数”、“月”、“年”],
[A',2015年2月10日],
[B',8',2015年2月],
[C',2016年2月15日],
[A',7',2016年2月],
[B',5',2016年2月],
[C',12',2015年2月],
[A',20',2015年3月],
[B',2015年3月16日],
[C',30',2016年3月],
[A',14',2016年3月],
[B',10',2016年3月],
[C',24',2015年3月]
]);
var slider=new google.visualization.ControlWrapper({
“controlType”:“CategoryFilter”,
“containerId”:“filter_div”,
“dataTable”:数据,
“选项”:{
'filterColumnLabel':'Month',
“用户界面”:{
“allowTyping”:真,
“allowMultiple”:false,
“AllowOne”:错误,
“sortValues”:false,
“标签”:“选择月份”,
}
}
});
google.visualization.events.addListener(滑动条'ready',drawChart);
google.visualization.events.addListener(滑块,'statechange',drawChart);
函数绘图图(){
var sliderData=new google.visualization.DataView(slider.getDataTable());
sliderData.setRows(sliderData.getFilteredRows([{
专栏:2,
值:slider.getState().selectedValues[0]
}]));
//按“组”/“年”分组
var dataGroup=google.visualization.data.group(
幻灯片数据,
[0, 3],
[{列:1,聚合:google.visualization.data.sum,类型:'number',标签:'Count'}]
);
排序([{column:0},{column:1}]);
//构建最终数据表
var yearData=new google.visualization.DataTable({
科尔斯:[
{label:'Group',type:'string'}
]
});
//为每年添加一列
var年份=数据组。GetDistinctValue(1);
对于(变量i=0;i


我根据图表预期的格式更改了输入数据。谢谢你的帮助@如果您还需要一个过滤器/滑块,您如何制作相同的图表?@kbhithesh请参阅上面的编辑…@WhiteHat现在我明白了。谢谢