Google 图表:识别特定控件

发布于 2024-11-16 15:30:07 字数 2220 浏览 2 评论 0原文

有没有办法识别一组绑定控件中的哪个控件被用户更改?

在本例中,我想知道在一组 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

请帮我爱他 2024-11-23 15:30:07

你的帖子里没有太多信息。因此,我将向您展示如何响应表中的排序事件。

google.visualization.events.addListener(table, 'sort',
  function(event) {
    data.sort([{column: event.column, desc: !event.ascending}]);
    chart.draw(view);
  });

因此,根据您的图表类型:

google.visualization.events.addListener(map, 'select',
        function() {
          table.setSelection(map.getSelection());
        });

找到您想要的事件,将侦听器添加到图表中。

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.

google.visualization.events.addListener(table, 'sort',
  function(event) {
    data.sort([{column: event.column, desc: !event.ascending}]);
    chart.draw(view);
  });

So depending on your chart type:

google.visualization.events.addListener(map, 'select',
        function() {
          table.setSelection(map.getSelection());
        });

Find the event you want, add the listener to the chart.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文