Had*_*igh 9 json google-visualization
在以下JSON中:
var data = new google.visualization.DataTable(
{
cols: [{id: 'Option1', label: 'Manufacturer', type: 'string'},
{id: 'Option2', label: 'Region', type: 'string'},
{id: 'Option3', label: 'Option3', type: 'number'},
{id: 'Option4', label: 'Option4', type: 'number'},
{id: 'Option5', label: 'Option5', type: 'number'},
{id: 'Option6', label: 'Option6', type: 'number'},
{id: 'Option7', label: 'Option7', type: 'number'},
{id: 'Option8', label: 'Option8', type: 'number'}],
rows: [{c:[{v: 'Ford'}, {v: 'South East'}, {v: 2}, {v: 3}, {v: 4}, {v: 5}, {v: 6}, {v: 7}]},
{c:[{v: 'Ford'}, {v: 'South East'}, {v: 2}, {v: 3}, {v: 4}, {v: 5}, {v: 6}, {v: 7}]},
{c:[{v: 'Ford'}, {v: 'South East'}, {v: 2}, {v: 3}, {v: 4}, {v: 5}, {v: 6}, {v: 7}]},
{c:[{v: 'BMW'}, {v: 'South East'}, {v: 2}, {v: 3}, {v: 4}, {v: 5}, {v: 6}, {v: 7}]},
{c:[{v: 'BMW'}, {v: 'North'}, {v: 2}, {v: 3}, {v: 4}, {v: 5}, {v: 6}, {v: 7}]},
{c:[{v: 'BMW'}, {v: 'North'}, {v: 2}, {v: 3}, {v: 4}, {v: 5}, {v: 6}, {v: 7}]},
{c:[{v: 'Citroen'}, {v: 'North'}, {v: 2}, {v: 3}, {v: 4}, {v: 5}, {v: 6}, {v: 7}]},
{c:[{v: 'Citroen'}, {v: 'South East'}, {v: 2}, {v: 3}, {v: 4}, {v: 5}, {v: 6}, {v: 7}]}
]
},
0.6
)
Run Code Online (Sandbox Code Playgroud)
我的图表'将'显示制造商为每行有7条数据的行.
我希望能够使用从属控件过滤数据,以便只查看每个区域中的行(第1列).
在当前时间,此图形不会绘制,因为region列不是整数,因此无法显示.
因此,我想"隐藏"区域列,使其不显示为条形,但可以与依赖控件一起使用.
任何人都可以帮助我,因为我找不到任何办法吗?我认为hideColumns方法不起作用,因为它从数据对象中删除了列,并且依赖控件无法看到它.
Had*_*igh 19
解决方案是使用'view'.
// Create a bar chart, passing some options
barChart = new google.visualization.ChartWrapper({
'chartType': 'BarChart',
'containerId': 'chart_div',
'options': {
'width': '100%',
'height': '120%',
'vAxis': {title: "Branch"},
'hAxis': {title: "Cups"},
'fontSize': 14,
'showRowNumber' : true,
},
'view': {'columns': [0,2,3,4,5,6,7]}
});
Run Code Online (Sandbox Code Playgroud)
希望这可以帮助其他人解决同样的问题.