Google 图表:识别特定控件
有没有办法识别一组绑定控件中的哪个控件被用户更改?
在本例中,我想知道在一组 5 个绑定控件中,用户刚刚更改了控件 3。
我想根据用户选择的不同值的数量来调整控件所在的 div 的大小。我可以得到这些,但我无法确定哪个控件已更改。
所以,就像这样:
var controlPicker1 = new google.visualization.ControlWrapper({
"controlType": "CategoryFilter",
"containerId": "control1",
"options": {
"filterColumnLabel": "Media source",
"ui": {
"labelStacking": "horizontal",
"allowTyping": true,
"allowMultiple": true
}
}
});
var view = new google.visualization.DataView(data);
barChart = new google.visualization.ChartWrapper({
"chartType": "BarChart",
"containerId": "chart_div",
"options": {
"width": "100%",
"height": "120%",
"vAxis": {title: "Media source (Branch - Dialled number)"},
"hAxis": {title: "Number of calls"},
"fontSize": 14,
"chartArea": {top: 0, right: 0, bottom: 0, height:"100%", width:"70%"}
},
"view": {"columns": [0,6,7,8,9,10,11]}
});
google.visualization.events.addListener(dashboard, "ready", function() {
barChart.draw();
resizeControl("control1", 50, barChart.getDataTable().getDistinctValues(1), 500);
}
});
dashboard.bind(controlPicker1, controlPicker2);
dashboard.bind(controlPicker2, controlPicker3);
dashboard.bind(controlPicker3, controlPicker4);
dashboard.bind(controlPicker4, controlPicker5);
dashboard.bind(controlPicker5, barChart);
dashboard.draw(view);
}
function resizeControl(name, total, div1, length) {
var control=div1.length;
if(total>control){
var div=document.getElementById(name);
var w=parseInt(div.style.width);
var revs=($(this).width()/length);
var newh = 35;
for (var i=0; i <(control / revs); i++) {
if(i>0)newh = newh+25;
}
newh + "px";
$(div).height(newh);
}
}
谢谢,
H.
Is there a way to identify which control in a set of bound controls is changed by the user?
In this instance I want to know that in a set of 5 bound controls, the user just changed control 3.
I want to resize the div that the control is within, based on the number of distinct values the user has chosen. I can get these, but I cannot identify which control has been changed.
So, something like:
var controlPicker1 = new google.visualization.ControlWrapper({
"controlType": "CategoryFilter",
"containerId": "control1",
"options": {
"filterColumnLabel": "Media source",
"ui": {
"labelStacking": "horizontal",
"allowTyping": true,
"allowMultiple": true
}
}
});
var view = new google.visualization.DataView(data);
barChart = new google.visualization.ChartWrapper({
"chartType": "BarChart",
"containerId": "chart_div",
"options": {
"width": "100%",
"height": "120%",
"vAxis": {title: "Media source (Branch - Dialled number)"},
"hAxis": {title: "Number of calls"},
"fontSize": 14,
"chartArea": {top: 0, right: 0, bottom: 0, height:"100%", width:"70%"}
},
"view": {"columns": [0,6,7,8,9,10,11]}
});
google.visualization.events.addListener(dashboard, "ready", function() {
barChart.draw();
resizeControl("control1", 50, barChart.getDataTable().getDistinctValues(1), 500);
}
});
dashboard.bind(controlPicker1, controlPicker2);
dashboard.bind(controlPicker2, controlPicker3);
dashboard.bind(controlPicker3, controlPicker4);
dashboard.bind(controlPicker4, controlPicker5);
dashboard.bind(controlPicker5, barChart);
dashboard.draw(view);
}
function resizeControl(name, total, div1, length) {
var control=div1.length;
if(total>control){
var div=document.getElementById(name);
var w=parseInt(div.style.width);
var revs=($(this).width()/length);
var newh = 35;
for (var i=0; i <(control / revs); i++) {
if(i>0)newh = newh+25;
}
newh + "px";
$(div).height(newh);
}
}
Thanks,
H.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你的帖子里没有太多信息。因此,我将向您展示如何响应表中的排序事件。
因此,根据您的图表类型:
找到您想要的事件,将侦听器添加到图表中。
There's not a lot of information in your post. So I'll show you how to responder to a sort event in a Table.
So depending on your chart type:
Find the event you want, add the listener to the chart.