Javascript 谷歌排行榜:IE8和IE9表现缓慢,但Mozilla表现良好

Javascript 谷歌排行榜:IE8和IE9表现缓慢,但Mozilla表现良好,javascript,jquery,json,google-visualization,Javascript,Jquery,Json,Google Visualization,在下面的JS/JQUERY/JSON中,任何人都能发现是什么让IE慢到爬行的程度 // Load the Visualization API and the controls package. google.load("visualization", "1.1", {"packages":["corechart", "controls"]}); // Set a callback to run when the Google Visualization API is l

在下面的JS/JQUERY/JSON中,任何人都能发现是什么让IE慢到爬行的程度

    // Load the Visualization API and the controls package.
    google.load("visualization", "1.1", {"packages":["corechart", "controls"]});

    // Set a callback to run when the Google Visualization API is loaded.
    google.setOnLoadCallback(drawDashboard);

    // Callback that creates and populates a data table,
    // instantiates a dashboard, a range slider and a pie chart,
    // passes in the data and draws it.

    var barChart;
    var ChartColumnsLength;

    function drawDashboard() {

        // Create our data table.
        var data = new google.visualization.DataTable(
            {
            cols: [{id: '0', label: 'Geographical location', type: 'string'},
                   {id: '1', label: 'Total calls', type: 'number'},
                   {id: '2', label: 'Unique calls', type: 'number'},
                   {id: '3', label: 'Missed', type: 'number'},
                   {id: '4', label: 'Engaged', type: 'number'},
                   {id: '5', label: 'Unanswered', type: 'number'},
                   {id: '6', label: 'Average secs to pick-up', type: 'number'}],

            rows: [{c:[{v: 'Unknown'}, {v: 4895}, {v: 2886}, {v: 3}, {v: 302}, {v: 305}, {v: 8.5}]},{c:[{v: 'Aberdeen'}, {v: 7}, {v: 7}, {v: 0}, {v: 0}, {v: 0}, {v: 6.6}]}
                    ]
            },
            0.6
        )

        // Create a dashboard.
        var dashboard = new google.visualization.Dashboard(document.getElementById("dashboard_div"));

        // Define category pickers
        var controlPicker1 = new google.visualization.ControlWrapper({
            "controlType": "CategoryFilter",
            "containerId": "control1",
            "options": {
            "filterColumnLabel": "Geographical location",
            "ui": {
                "labelStacking": "horizontal",
                "allowTyping": true,
                "allowMultiple": true
            }
            }
        });

        var view = new google.visualization.DataView(data);

        // Create a chart, passing some options
        barChart = new google.visualization.ChartWrapper({
            "chartType": "BarChart",
            "containerId": "chart_div",
            "options": {
            "width": "100%",
            "height": "120%",
            "vAxis": {title: "Geographical location"},
            "hAxis": {title: "Number of calls"},
            "fontSize": 14,
            "chartArea": {top: 0, right: 0, bottom: 0, height:"100%", width:"70%"}
            },
            "view": {"columns": [0,1,2,3,4,5,6]}
        });

        google.visualization.events.addListener(dashboard, "ready", function() {

            // Dashboard redraw, have a look at how many rows the barChart is displaying
            var numRows = barChart.getDataTable().getNumberOfRows();
            if(ChartColumnsLength){
                var numCols = ChartColumnsLength.length-1;
            }else{
                var numCols = barChart.getDataTable().getNumberOfColumns()-1;
            }
            var expectedHeight = (numRows * (numCols * 20))+70;
            if (parseInt(barChart.getOption("height"), 10) != expectedHeight) {
                // Update the chart options and redraw just it
                drawDiv("chart_div", expectedHeight);
                barChart.setOption("height", expectedHeight);
                barChart.setOption("width", "100%");
                barChart.setOption("chartArea", {top: 10, right: 0, bottom: 0, height: (expectedHeight-70), width:"70%"});
                barChart.draw();
            }
        });

        // Establish dependencies, declaring that "filter" drives "barChart",
        // so that the pie chart will only display entries that are let through
        // given the chosen slider range.
        dashboard.bind(controlPicker1, barChart);
        // Draw the dashboard.
        dashboard.draw(view);
    }

    function drawDiv(id,h) {
        var div=document.getElementById(id);
        h = (h) + "px";

        var w=parseInt(div.style.width);
        w = ($(this).width()-200) + "px";

        $(div).height(h);
        $(div).width(w);
    }

    function listValuesCheckBox(){

        var myArray = [];
        var k = 1;
        myArray[0]=0;
        var at_least_one_checked = false;
        for (var i=0; i < document.frm_obj.elements.length; i++) {
            var e = document.frm_obj.elements[i];
            if(e.checked == true){
                at_least_one_checked = true;
                myArray[k] = parseInt(e.value,10);
                k = k+1;
            }

        }
        if(at_least_one_checked == true){
            return myArray;
        }else{
            alert("I cannot display a chart with zero bars. Please select at least one bar using the tick boxes.");
            stop_script_running;
        }
    }

    function changeChartColumns() {
        // ChartColumnsLength is a global variable
        ChartColumnsLength = listValuesCheckBox();
        barChart.setView({"columns": ChartColumnsLength});
        barChart.draw();
    }

    $(document).ready(function(){
        $("#start_date_uk").datepicker({
            changeMonth: true,
            numberOfMonths: 3,
            showButtonPanel: true,
            showCurrentAtPos: 1,
            autoSize: true,
            changeYear: true,
            dateFormat: "dd-mm-yy",
            defaultDate: new Date(2009, 09, 08),
            onSelect: function(dateText, inst) {
                $(".datepicker").datepicker("option", "defaultDate", dateText);
            }
        });
        $("#end_date_uk").datepicker({
            changeMonth: true,
            numberOfMonths: 3,
            showButtonPanel: true,
            showCurrentAtPos: 1,
            autoSize: true,
            changeYear: true,
            dateFormat: "dd-mm-yy",
            defaultDate: new Date(2011, 02, 28),
            onSelect: function(dateText, inst) {
                $(".datepicker").datepicker("option", "defaultDate", dateText);
            }
        });
    });

    </script>
在添加一个大的JSON数据集之前,速度并不慢,但基于Mozilla的broswers在类似条件下也可以。没有脚本运行时错误

    // Load the Visualization API and the controls package.
    google.load("visualization", "1.1", {"packages":["corechart", "controls"]});

    // Set a callback to run when the Google Visualization API is loaded.
    google.setOnLoadCallback(drawDashboard);

    // Callback that creates and populates a data table,
    // instantiates a dashboard, a range slider and a pie chart,
    // passes in the data and draws it.

    var barChart;
    var ChartColumnsLength;

    function drawDashboard() {

        // Create our data table.
        var data = new google.visualization.DataTable(
            {
            cols: [{id: '0', label: 'Geographical location', type: 'string'},
                   {id: '1', label: 'Total calls', type: 'number'},
                   {id: '2', label: 'Unique calls', type: 'number'},
                   {id: '3', label: 'Missed', type: 'number'},
                   {id: '4', label: 'Engaged', type: 'number'},
                   {id: '5', label: 'Unanswered', type: 'number'},
                   {id: '6', label: 'Average secs to pick-up', type: 'number'}],

            rows: [{c:[{v: 'Unknown'}, {v: 4895}, {v: 2886}, {v: 3}, {v: 302}, {v: 305}, {v: 8.5}]},{c:[{v: 'Aberdeen'}, {v: 7}, {v: 7}, {v: 0}, {v: 0}, {v: 0}, {v: 6.6}]}
                    ]
            },
            0.6
        )

        // Create a dashboard.
        var dashboard = new google.visualization.Dashboard(document.getElementById("dashboard_div"));

        // Define category pickers
        var controlPicker1 = new google.visualization.ControlWrapper({
            "controlType": "CategoryFilter",
            "containerId": "control1",
            "options": {
            "filterColumnLabel": "Geographical location",
            "ui": {
                "labelStacking": "horizontal",
                "allowTyping": true,
                "allowMultiple": true
            }
            }
        });

        var view = new google.visualization.DataView(data);

        // Create a chart, passing some options
        barChart = new google.visualization.ChartWrapper({
            "chartType": "BarChart",
            "containerId": "chart_div",
            "options": {
            "width": "100%",
            "height": "120%",
            "vAxis": {title: "Geographical location"},
            "hAxis": {title: "Number of calls"},
            "fontSize": 14,
            "chartArea": {top: 0, right: 0, bottom: 0, height:"100%", width:"70%"}
            },
            "view": {"columns": [0,1,2,3,4,5,6]}
        });

        google.visualization.events.addListener(dashboard, "ready", function() {

            // Dashboard redraw, have a look at how many rows the barChart is displaying
            var numRows = barChart.getDataTable().getNumberOfRows();
            if(ChartColumnsLength){
                var numCols = ChartColumnsLength.length-1;
            }else{
                var numCols = barChart.getDataTable().getNumberOfColumns()-1;
            }
            var expectedHeight = (numRows * (numCols * 20))+70;
            if (parseInt(barChart.getOption("height"), 10) != expectedHeight) {
                // Update the chart options and redraw just it
                drawDiv("chart_div", expectedHeight);
                barChart.setOption("height", expectedHeight);
                barChart.setOption("width", "100%");
                barChart.setOption("chartArea", {top: 10, right: 0, bottom: 0, height: (expectedHeight-70), width:"70%"});
                barChart.draw();
            }
        });

        // Establish dependencies, declaring that "filter" drives "barChart",
        // so that the pie chart will only display entries that are let through
        // given the chosen slider range.
        dashboard.bind(controlPicker1, barChart);
        // Draw the dashboard.
        dashboard.draw(view);
    }

    function drawDiv(id,h) {
        var div=document.getElementById(id);
        h = (h) + "px";

        var w=parseInt(div.style.width);
        w = ($(this).width()-200) + "px";

        $(div).height(h);
        $(div).width(w);
    }

    function listValuesCheckBox(){

        var myArray = [];
        var k = 1;
        myArray[0]=0;
        var at_least_one_checked = false;
        for (var i=0; i < document.frm_obj.elements.length; i++) {
            var e = document.frm_obj.elements[i];
            if(e.checked == true){
                at_least_one_checked = true;
                myArray[k] = parseInt(e.value,10);
                k = k+1;
            }

        }
        if(at_least_one_checked == true){
            return myArray;
        }else{
            alert("I cannot display a chart with zero bars. Please select at least one bar using the tick boxes.");
            stop_script_running;
        }
    }

    function changeChartColumns() {
        // ChartColumnsLength is a global variable
        ChartColumnsLength = listValuesCheckBox();
        barChart.setView({"columns": ChartColumnsLength});
        barChart.draw();
    }

    $(document).ready(function(){
        $("#start_date_uk").datepicker({
            changeMonth: true,
            numberOfMonths: 3,
            showButtonPanel: true,
            showCurrentAtPos: 1,
            autoSize: true,
            changeYear: true,
            dateFormat: "dd-mm-yy",
            defaultDate: new Date(2009, 09, 08),
            onSelect: function(dateText, inst) {
                $(".datepicker").datepicker("option", "defaultDate", dateText);
            }
        });
        $("#end_date_uk").datepicker({
            changeMonth: true,
            numberOfMonths: 3,
            showButtonPanel: true,
            showCurrentAtPos: 1,
            autoSize: true,
            changeYear: true,
            dateFormat: "dd-mm-yy",
            defaultDate: new Date(2011, 02, 28),
            onSelect: function(dateText, inst) {
                $(".datepicker").datepicker("option", "defaultDate", dateText);
            }
        });
    });

    </script>
我已经消除了糟糕的HTML,并将原始JSON添加到更简单的交互式操场示例中,没有负面的速度影响

    // Load the Visualization API and the controls package.
    google.load("visualization", "1.1", {"packages":["corechart", "controls"]});

    // Set a callback to run when the Google Visualization API is loaded.
    google.setOnLoadCallback(drawDashboard);

    // Callback that creates and populates a data table,
    // instantiates a dashboard, a range slider and a pie chart,
    // passes in the data and draws it.

    var barChart;
    var ChartColumnsLength;

    function drawDashboard() {

        // Create our data table.
        var data = new google.visualization.DataTable(
            {
            cols: [{id: '0', label: 'Geographical location', type: 'string'},
                   {id: '1', label: 'Total calls', type: 'number'},
                   {id: '2', label: 'Unique calls', type: 'number'},
                   {id: '3', label: 'Missed', type: 'number'},
                   {id: '4', label: 'Engaged', type: 'number'},
                   {id: '5', label: 'Unanswered', type: 'number'},
                   {id: '6', label: 'Average secs to pick-up', type: 'number'}],

            rows: [{c:[{v: 'Unknown'}, {v: 4895}, {v: 2886}, {v: 3}, {v: 302}, {v: 305}, {v: 8.5}]},{c:[{v: 'Aberdeen'}, {v: 7}, {v: 7}, {v: 0}, {v: 0}, {v: 0}, {v: 6.6}]}
                    ]
            },
            0.6
        )

        // Create a dashboard.
        var dashboard = new google.visualization.Dashboard(document.getElementById("dashboard_div"));

        // Define category pickers
        var controlPicker1 = new google.visualization.ControlWrapper({
            "controlType": "CategoryFilter",
            "containerId": "control1",
            "options": {
            "filterColumnLabel": "Geographical location",
            "ui": {
                "labelStacking": "horizontal",
                "allowTyping": true,
                "allowMultiple": true
            }
            }
        });

        var view = new google.visualization.DataView(data);

        // Create a chart, passing some options
        barChart = new google.visualization.ChartWrapper({
            "chartType": "BarChart",
            "containerId": "chart_div",
            "options": {
            "width": "100%",
            "height": "120%",
            "vAxis": {title: "Geographical location"},
            "hAxis": {title: "Number of calls"},
            "fontSize": 14,
            "chartArea": {top: 0, right: 0, bottom: 0, height:"100%", width:"70%"}
            },
            "view": {"columns": [0,1,2,3,4,5,6]}
        });

        google.visualization.events.addListener(dashboard, "ready", function() {

            // Dashboard redraw, have a look at how many rows the barChart is displaying
            var numRows = barChart.getDataTable().getNumberOfRows();
            if(ChartColumnsLength){
                var numCols = ChartColumnsLength.length-1;
            }else{
                var numCols = barChart.getDataTable().getNumberOfColumns()-1;
            }
            var expectedHeight = (numRows * (numCols * 20))+70;
            if (parseInt(barChart.getOption("height"), 10) != expectedHeight) {
                // Update the chart options and redraw just it
                drawDiv("chart_div", expectedHeight);
                barChart.setOption("height", expectedHeight);
                barChart.setOption("width", "100%");
                barChart.setOption("chartArea", {top: 10, right: 0, bottom: 0, height: (expectedHeight-70), width:"70%"});
                barChart.draw();
            }
        });

        // Establish dependencies, declaring that "filter" drives "barChart",
        // so that the pie chart will only display entries that are let through
        // given the chosen slider range.
        dashboard.bind(controlPicker1, barChart);
        // Draw the dashboard.
        dashboard.draw(view);
    }

    function drawDiv(id,h) {
        var div=document.getElementById(id);
        h = (h) + "px";

        var w=parseInt(div.style.width);
        w = ($(this).width()-200) + "px";

        $(div).height(h);
        $(div).width(w);
    }

    function listValuesCheckBox(){

        var myArray = [];
        var k = 1;
        myArray[0]=0;
        var at_least_one_checked = false;
        for (var i=0; i < document.frm_obj.elements.length; i++) {
            var e = document.frm_obj.elements[i];
            if(e.checked == true){
                at_least_one_checked = true;
                myArray[k] = parseInt(e.value,10);
                k = k+1;
            }

        }
        if(at_least_one_checked == true){
            return myArray;
        }else{
            alert("I cannot display a chart with zero bars. Please select at least one bar using the tick boxes.");
            stop_script_running;
        }
    }

    function changeChartColumns() {
        // ChartColumnsLength is a global variable
        ChartColumnsLength = listValuesCheckBox();
        barChart.setView({"columns": ChartColumnsLength});
        barChart.draw();
    }

    $(document).ready(function(){
        $("#start_date_uk").datepicker({
            changeMonth: true,
            numberOfMonths: 3,
            showButtonPanel: true,
            showCurrentAtPos: 1,
            autoSize: true,
            changeYear: true,
            dateFormat: "dd-mm-yy",
            defaultDate: new Date(2009, 09, 08),
            onSelect: function(dateText, inst) {
                $(".datepicker").datepicker("option", "defaultDate", dateText);
            }
        });
        $("#end_date_uk").datepicker({
            changeMonth: true,
            numberOfMonths: 3,
            showButtonPanel: true,
            showCurrentAtPos: 1,
            autoSize: true,
            changeYear: true,
            dateFormat: "dd-mm-yy",
            defaultDate: new Date(2011, 02, 28),
            onSelect: function(dateText, inst) {
                $(".datepicker").datepicker("option", "defaultDate", dateText);
            }
        });
    });

    </script>
因此,我认为可能是IE不喜欢的JS

    // Load the Visualization API and the controls package.
    google.load("visualization", "1.1", {"packages":["corechart", "controls"]});

    // Set a callback to run when the Google Visualization API is loaded.
    google.setOnLoadCallback(drawDashboard);

    // Callback that creates and populates a data table,
    // instantiates a dashboard, a range slider and a pie chart,
    // passes in the data and draws it.

    var barChart;
    var ChartColumnsLength;

    function drawDashboard() {

        // Create our data table.
        var data = new google.visualization.DataTable(
            {
            cols: [{id: '0', label: 'Geographical location', type: 'string'},
                   {id: '1', label: 'Total calls', type: 'number'},
                   {id: '2', label: 'Unique calls', type: 'number'},
                   {id: '3', label: 'Missed', type: 'number'},
                   {id: '4', label: 'Engaged', type: 'number'},
                   {id: '5', label: 'Unanswered', type: 'number'},
                   {id: '6', label: 'Average secs to pick-up', type: 'number'}],

            rows: [{c:[{v: 'Unknown'}, {v: 4895}, {v: 2886}, {v: 3}, {v: 302}, {v: 305}, {v: 8.5}]},{c:[{v: 'Aberdeen'}, {v: 7}, {v: 7}, {v: 0}, {v: 0}, {v: 0}, {v: 6.6}]}
                    ]
            },
            0.6
        )

        // Create a dashboard.
        var dashboard = new google.visualization.Dashboard(document.getElementById("dashboard_div"));

        // Define category pickers
        var controlPicker1 = new google.visualization.ControlWrapper({
            "controlType": "CategoryFilter",
            "containerId": "control1",
            "options": {
            "filterColumnLabel": "Geographical location",
            "ui": {
                "labelStacking": "horizontal",
                "allowTyping": true,
                "allowMultiple": true
            }
            }
        });

        var view = new google.visualization.DataView(data);

        // Create a chart, passing some options
        barChart = new google.visualization.ChartWrapper({
            "chartType": "BarChart",
            "containerId": "chart_div",
            "options": {
            "width": "100%",
            "height": "120%",
            "vAxis": {title: "Geographical location"},
            "hAxis": {title: "Number of calls"},
            "fontSize": 14,
            "chartArea": {top: 0, right: 0, bottom: 0, height:"100%", width:"70%"}
            },
            "view": {"columns": [0,1,2,3,4,5,6]}
        });

        google.visualization.events.addListener(dashboard, "ready", function() {

            // Dashboard redraw, have a look at how many rows the barChart is displaying
            var numRows = barChart.getDataTable().getNumberOfRows();
            if(ChartColumnsLength){
                var numCols = ChartColumnsLength.length-1;
            }else{
                var numCols = barChart.getDataTable().getNumberOfColumns()-1;
            }
            var expectedHeight = (numRows * (numCols * 20))+70;
            if (parseInt(barChart.getOption("height"), 10) != expectedHeight) {
                // Update the chart options and redraw just it
                drawDiv("chart_div", expectedHeight);
                barChart.setOption("height", expectedHeight);
                barChart.setOption("width", "100%");
                barChart.setOption("chartArea", {top: 10, right: 0, bottom: 0, height: (expectedHeight-70), width:"70%"});
                barChart.draw();
            }
        });

        // Establish dependencies, declaring that "filter" drives "barChart",
        // so that the pie chart will only display entries that are let through
        // given the chosen slider range.
        dashboard.bind(controlPicker1, barChart);
        // Draw the dashboard.
        dashboard.draw(view);
    }

    function drawDiv(id,h) {
        var div=document.getElementById(id);
        h = (h) + "px";

        var w=parseInt(div.style.width);
        w = ($(this).width()-200) + "px";

        $(div).height(h);
        $(div).width(w);
    }

    function listValuesCheckBox(){

        var myArray = [];
        var k = 1;
        myArray[0]=0;
        var at_least_one_checked = false;
        for (var i=0; i < document.frm_obj.elements.length; i++) {
            var e = document.frm_obj.elements[i];
            if(e.checked == true){
                at_least_one_checked = true;
                myArray[k] = parseInt(e.value,10);
                k = k+1;
            }

        }
        if(at_least_one_checked == true){
            return myArray;
        }else{
            alert("I cannot display a chart with zero bars. Please select at least one bar using the tick boxes.");
            stop_script_running;
        }
    }

    function changeChartColumns() {
        // ChartColumnsLength is a global variable
        ChartColumnsLength = listValuesCheckBox();
        barChart.setView({"columns": ChartColumnsLength});
        barChart.draw();
    }

    $(document).ready(function(){
        $("#start_date_uk").datepicker({
            changeMonth: true,
            numberOfMonths: 3,
            showButtonPanel: true,
            showCurrentAtPos: 1,
            autoSize: true,
            changeYear: true,
            dateFormat: "dd-mm-yy",
            defaultDate: new Date(2009, 09, 08),
            onSelect: function(dateText, inst) {
                $(".datepicker").datepicker("option", "defaultDate", dateText);
            }
        });
        $("#end_date_uk").datepicker({
            changeMonth: true,
            numberOfMonths: 3,
            showButtonPanel: true,
            showCurrentAtPos: 1,
            autoSize: true,
            changeYear: true,
            dateFormat: "dd-mm-yy",
            defaultDate: new Date(2011, 02, 28),
            onSelect: function(dateText, inst) {
                $(".datepicker").datepicker("option", "defaultDate", dateText);
            }
        });
    });

    </script>
欢迎任何意见

    // Load the Visualization API and the controls package.
    google.load("visualization", "1.1", {"packages":["corechart", "controls"]});

    // Set a callback to run when the Google Visualization API is loaded.
    google.setOnLoadCallback(drawDashboard);

    // Callback that creates and populates a data table,
    // instantiates a dashboard, a range slider and a pie chart,
    // passes in the data and draws it.

    var barChart;
    var ChartColumnsLength;

    function drawDashboard() {

        // Create our data table.
        var data = new google.visualization.DataTable(
            {
            cols: [{id: '0', label: 'Geographical location', type: 'string'},
                   {id: '1', label: 'Total calls', type: 'number'},
                   {id: '2', label: 'Unique calls', type: 'number'},
                   {id: '3', label: 'Missed', type: 'number'},
                   {id: '4', label: 'Engaged', type: 'number'},
                   {id: '5', label: 'Unanswered', type: 'number'},
                   {id: '6', label: 'Average secs to pick-up', type: 'number'}],

            rows: [{c:[{v: 'Unknown'}, {v: 4895}, {v: 2886}, {v: 3}, {v: 302}, {v: 305}, {v: 8.5}]},{c:[{v: 'Aberdeen'}, {v: 7}, {v: 7}, {v: 0}, {v: 0}, {v: 0}, {v: 6.6}]}
                    ]
            },
            0.6
        )

        // Create a dashboard.
        var dashboard = new google.visualization.Dashboard(document.getElementById("dashboard_div"));

        // Define category pickers
        var controlPicker1 = new google.visualization.ControlWrapper({
            "controlType": "CategoryFilter",
            "containerId": "control1",
            "options": {
            "filterColumnLabel": "Geographical location",
            "ui": {
                "labelStacking": "horizontal",
                "allowTyping": true,
                "allowMultiple": true
            }
            }
        });

        var view = new google.visualization.DataView(data);

        // Create a chart, passing some options
        barChart = new google.visualization.ChartWrapper({
            "chartType": "BarChart",
            "containerId": "chart_div",
            "options": {
            "width": "100%",
            "height": "120%",
            "vAxis": {title: "Geographical location"},
            "hAxis": {title: "Number of calls"},
            "fontSize": 14,
            "chartArea": {top: 0, right: 0, bottom: 0, height:"100%", width:"70%"}
            },
            "view": {"columns": [0,1,2,3,4,5,6]}
        });

        google.visualization.events.addListener(dashboard, "ready", function() {

            // Dashboard redraw, have a look at how many rows the barChart is displaying
            var numRows = barChart.getDataTable().getNumberOfRows();
            if(ChartColumnsLength){
                var numCols = ChartColumnsLength.length-1;
            }else{
                var numCols = barChart.getDataTable().getNumberOfColumns()-1;
            }
            var expectedHeight = (numRows * (numCols * 20))+70;
            if (parseInt(barChart.getOption("height"), 10) != expectedHeight) {
                // Update the chart options and redraw just it
                drawDiv("chart_div", expectedHeight);
                barChart.setOption("height", expectedHeight);
                barChart.setOption("width", "100%");
                barChart.setOption("chartArea", {top: 10, right: 0, bottom: 0, height: (expectedHeight-70), width:"70%"});
                barChart.draw();
            }
        });

        // Establish dependencies, declaring that "filter" drives "barChart",
        // so that the pie chart will only display entries that are let through
        // given the chosen slider range.
        dashboard.bind(controlPicker1, barChart);
        // Draw the dashboard.
        dashboard.draw(view);
    }

    function drawDiv(id,h) {
        var div=document.getElementById(id);
        h = (h) + "px";

        var w=parseInt(div.style.width);
        w = ($(this).width()-200) + "px";

        $(div).height(h);
        $(div).width(w);
    }

    function listValuesCheckBox(){

        var myArray = [];
        var k = 1;
        myArray[0]=0;
        var at_least_one_checked = false;
        for (var i=0; i < document.frm_obj.elements.length; i++) {
            var e = document.frm_obj.elements[i];
            if(e.checked == true){
                at_least_one_checked = true;
                myArray[k] = parseInt(e.value,10);
                k = k+1;
            }

        }
        if(at_least_one_checked == true){
            return myArray;
        }else{
            alert("I cannot display a chart with zero bars. Please select at least one bar using the tick boxes.");
            stop_script_running;
        }
    }

    function changeChartColumns() {
        // ChartColumnsLength is a global variable
        ChartColumnsLength = listValuesCheckBox();
        barChart.setView({"columns": ChartColumnsLength});
        barChart.draw();
    }

    $(document).ready(function(){
        $("#start_date_uk").datepicker({
            changeMonth: true,
            numberOfMonths: 3,
            showButtonPanel: true,
            showCurrentAtPos: 1,
            autoSize: true,
            changeYear: true,
            dateFormat: "dd-mm-yy",
            defaultDate: new Date(2009, 09, 08),
            onSelect: function(dateText, inst) {
                $(".datepicker").datepicker("option", "defaultDate", dateText);
            }
        });
        $("#end_date_uk").datepicker({
            changeMonth: true,
            numberOfMonths: 3,
            showButtonPanel: true,
            showCurrentAtPos: 1,
            autoSize: true,
            changeYear: true,
            dateFormat: "dd-mm-yy",
            defaultDate: new Date(2011, 02, 28),
            onSelect: function(dateText, inst) {
                $(".datepicker").datepicker("option", "defaultDate", dateText);
            }
        });
    });

    </script>
(这里是myujqueryinclude)

    // Load the Visualization API and the controls package.
    google.load("visualization", "1.1", {"packages":["corechart", "controls"]});

    // Set a callback to run when the Google Visualization API is loaded.
    google.setOnLoadCallback(drawDashboard);

    // Callback that creates and populates a data table,
    // instantiates a dashboard, a range slider and a pie chart,
    // passes in the data and draws it.

    var barChart;
    var ChartColumnsLength;

    function drawDashboard() {

        // Create our data table.
        var data = new google.visualization.DataTable(
            {
            cols: [{id: '0', label: 'Geographical location', type: 'string'},
                   {id: '1', label: 'Total calls', type: 'number'},
                   {id: '2', label: 'Unique calls', type: 'number'},
                   {id: '3', label: 'Missed', type: 'number'},
                   {id: '4', label: 'Engaged', type: 'number'},
                   {id: '5', label: 'Unanswered', type: 'number'},
                   {id: '6', label: 'Average secs to pick-up', type: 'number'}],

            rows: [{c:[{v: 'Unknown'}, {v: 4895}, {v: 2886}, {v: 3}, {v: 302}, {v: 305}, {v: 8.5}]},{c:[{v: 'Aberdeen'}, {v: 7}, {v: 7}, {v: 0}, {v: 0}, {v: 0}, {v: 6.6}]}
                    ]
            },
            0.6
        )

        // Create a dashboard.
        var dashboard = new google.visualization.Dashboard(document.getElementById("dashboard_div"));

        // Define category pickers
        var controlPicker1 = new google.visualization.ControlWrapper({
            "controlType": "CategoryFilter",
            "containerId": "control1",
            "options": {
            "filterColumnLabel": "Geographical location",
            "ui": {
                "labelStacking": "horizontal",
                "allowTyping": true,
                "allowMultiple": true
            }
            }
        });

        var view = new google.visualization.DataView(data);

        // Create a chart, passing some options
        barChart = new google.visualization.ChartWrapper({
            "chartType": "BarChart",
            "containerId": "chart_div",
            "options": {
            "width": "100%",
            "height": "120%",
            "vAxis": {title: "Geographical location"},
            "hAxis": {title: "Number of calls"},
            "fontSize": 14,
            "chartArea": {top: 0, right: 0, bottom: 0, height:"100%", width:"70%"}
            },
            "view": {"columns": [0,1,2,3,4,5,6]}
        });

        google.visualization.events.addListener(dashboard, "ready", function() {

            // Dashboard redraw, have a look at how many rows the barChart is displaying
            var numRows = barChart.getDataTable().getNumberOfRows();
            if(ChartColumnsLength){
                var numCols = ChartColumnsLength.length-1;
            }else{
                var numCols = barChart.getDataTable().getNumberOfColumns()-1;
            }
            var expectedHeight = (numRows * (numCols * 20))+70;
            if (parseInt(barChart.getOption("height"), 10) != expectedHeight) {
                // Update the chart options and redraw just it
                drawDiv("chart_div", expectedHeight);
                barChart.setOption("height", expectedHeight);
                barChart.setOption("width", "100%");
                barChart.setOption("chartArea", {top: 10, right: 0, bottom: 0, height: (expectedHeight-70), width:"70%"});
                barChart.draw();
            }
        });

        // Establish dependencies, declaring that "filter" drives "barChart",
        // so that the pie chart will only display entries that are let through
        // given the chosen slider range.
        dashboard.bind(controlPicker1, barChart);
        // Draw the dashboard.
        dashboard.draw(view);
    }

    function drawDiv(id,h) {
        var div=document.getElementById(id);
        h = (h) + "px";

        var w=parseInt(div.style.width);
        w = ($(this).width()-200) + "px";

        $(div).height(h);
        $(div).width(w);
    }

    function listValuesCheckBox(){

        var myArray = [];
        var k = 1;
        myArray[0]=0;
        var at_least_one_checked = false;
        for (var i=0; i < document.frm_obj.elements.length; i++) {
            var e = document.frm_obj.elements[i];
            if(e.checked == true){
                at_least_one_checked = true;
                myArray[k] = parseInt(e.value,10);
                k = k+1;
            }

        }
        if(at_least_one_checked == true){
            return myArray;
        }else{
            alert("I cannot display a chart with zero bars. Please select at least one bar using the tick boxes.");
            stop_script_running;
        }
    }

    function changeChartColumns() {
        // ChartColumnsLength is a global variable
        ChartColumnsLength = listValuesCheckBox();
        barChart.setView({"columns": ChartColumnsLength});
        barChart.draw();
    }

    $(document).ready(function(){
        $("#start_date_uk").datepicker({
            changeMonth: true,
            numberOfMonths: 3,
            showButtonPanel: true,
            showCurrentAtPos: 1,
            autoSize: true,
            changeYear: true,
            dateFormat: "dd-mm-yy",
            defaultDate: new Date(2009, 09, 08),
            onSelect: function(dateText, inst) {
                $(".datepicker").datepicker("option", "defaultDate", dateText);
            }
        });
        $("#end_date_uk").datepicker({
            changeMonth: true,
            numberOfMonths: 3,
            showButtonPanel: true,
            showCurrentAtPos: 1,
            autoSize: true,
            changeYear: true,
            dateFormat: "dd-mm-yy",
            defaultDate: new Date(2011, 02, 28),
            onSelect: function(dateText, inst) {
                $(".datepicker").datepicker("option", "defaultDate", dateText);
            }
        });
    });

    </script>

下面是所有脚本:

    // Load the Visualization API and the controls package.
    google.load("visualization", "1.1", {"packages":["corechart", "controls"]});

    // Set a callback to run when the Google Visualization API is loaded.
    google.setOnLoadCallback(drawDashboard);

    // Callback that creates and populates a data table,
    // instantiates a dashboard, a range slider and a pie chart,
    // passes in the data and draws it.

    var barChart;
    var ChartColumnsLength;

    function drawDashboard() {

        // Create our data table.
        var data = new google.visualization.DataTable(
            {
            cols: [{id: '0', label: 'Geographical location', type: 'string'},
                   {id: '1', label: 'Total calls', type: 'number'},
                   {id: '2', label: 'Unique calls', type: 'number'},
                   {id: '3', label: 'Missed', type: 'number'},
                   {id: '4', label: 'Engaged', type: 'number'},
                   {id: '5', label: 'Unanswered', type: 'number'},
                   {id: '6', label: 'Average secs to pick-up', type: 'number'}],

            rows: [{c:[{v: 'Unknown'}, {v: 4895}, {v: 2886}, {v: 3}, {v: 302}, {v: 305}, {v: 8.5}]},{c:[{v: 'Aberdeen'}, {v: 7}, {v: 7}, {v: 0}, {v: 0}, {v: 0}, {v: 6.6}]}
                    ]
            },
            0.6
        )

        // Create a dashboard.
        var dashboard = new google.visualization.Dashboard(document.getElementById("dashboard_div"));

        // Define category pickers
        var controlPicker1 = new google.visualization.ControlWrapper({
            "controlType": "CategoryFilter",
            "containerId": "control1",
            "options": {
            "filterColumnLabel": "Geographical location",
            "ui": {
                "labelStacking": "horizontal",
                "allowTyping": true,
                "allowMultiple": true
            }
            }
        });

        var view = new google.visualization.DataView(data);

        // Create a chart, passing some options
        barChart = new google.visualization.ChartWrapper({
            "chartType": "BarChart",
            "containerId": "chart_div",
            "options": {
            "width": "100%",
            "height": "120%",
            "vAxis": {title: "Geographical location"},
            "hAxis": {title: "Number of calls"},
            "fontSize": 14,
            "chartArea": {top: 0, right: 0, bottom: 0, height:"100%", width:"70%"}
            },
            "view": {"columns": [0,1,2,3,4,5,6]}
        });

        google.visualization.events.addListener(dashboard, "ready", function() {

            // Dashboard redraw, have a look at how many rows the barChart is displaying
            var numRows = barChart.getDataTable().getNumberOfRows();
            if(ChartColumnsLength){
                var numCols = ChartColumnsLength.length-1;
            }else{
                var numCols = barChart.getDataTable().getNumberOfColumns()-1;
            }
            var expectedHeight = (numRows * (numCols * 20))+70;
            if (parseInt(barChart.getOption("height"), 10) != expectedHeight) {
                // Update the chart options and redraw just it
                drawDiv("chart_div", expectedHeight);
                barChart.setOption("height", expectedHeight);
                barChart.setOption("width", "100%");
                barChart.setOption("chartArea", {top: 10, right: 0, bottom: 0, height: (expectedHeight-70), width:"70%"});
                barChart.draw();
            }
        });

        // Establish dependencies, declaring that "filter" drives "barChart",
        // so that the pie chart will only display entries that are let through
        // given the chosen slider range.
        dashboard.bind(controlPicker1, barChart);
        // Draw the dashboard.
        dashboard.draw(view);
    }

    function drawDiv(id,h) {
        var div=document.getElementById(id);
        h = (h) + "px";

        var w=parseInt(div.style.width);
        w = ($(this).width()-200) + "px";

        $(div).height(h);
        $(div).width(w);
    }

    function listValuesCheckBox(){

        var myArray = [];
        var k = 1;
        myArray[0]=0;
        var at_least_one_checked = false;
        for (var i=0; i < document.frm_obj.elements.length; i++) {
            var e = document.frm_obj.elements[i];
            if(e.checked == true){
                at_least_one_checked = true;
                myArray[k] = parseInt(e.value,10);
                k = k+1;
            }

        }
        if(at_least_one_checked == true){
            return myArray;
        }else{
            alert("I cannot display a chart with zero bars. Please select at least one bar using the tick boxes.");
            stop_script_running;
        }
    }

    function changeChartColumns() {
        // ChartColumnsLength is a global variable
        ChartColumnsLength = listValuesCheckBox();
        barChart.setView({"columns": ChartColumnsLength});
        barChart.draw();
    }

    $(document).ready(function(){
        $("#start_date_uk").datepicker({
            changeMonth: true,
            numberOfMonths: 3,
            showButtonPanel: true,
            showCurrentAtPos: 1,
            autoSize: true,
            changeYear: true,
            dateFormat: "dd-mm-yy",
            defaultDate: new Date(2009, 09, 08),
            onSelect: function(dateText, inst) {
                $(".datepicker").datepicker("option", "defaultDate", dateText);
            }
        });
        $("#end_date_uk").datepicker({
            changeMonth: true,
            numberOfMonths: 3,
            showButtonPanel: true,
            showCurrentAtPos: 1,
            autoSize: true,
            changeYear: true,
            dateFormat: "dd-mm-yy",
            defaultDate: new Date(2011, 02, 28),
            onSelect: function(dateText, inst) {
                $(".datepicker").datepicker("option", "defaultDate", dateText);
            }
        });
    });

    </script>

    // Load the Visualization API and the controls package.
    google.load("visualization", "1.1", {"packages":["corechart", "controls"]});

    // Set a callback to run when the Google Visualization API is loaded.
    google.setOnLoadCallback(drawDashboard);

    // Callback that creates and populates a data table,
    // instantiates a dashboard, a range slider and a pie chart,
    // passes in the data and draws it.

    var barChart;
    var ChartColumnsLength;

    function drawDashboard() {

        // Create our data table.
        var data = new google.visualization.DataTable(
            {
            cols: [{id: '0', label: 'Geographical location', type: 'string'},
                   {id: '1', label: 'Total calls', type: 'number'},
                   {id: '2', label: 'Unique calls', type: 'number'},
                   {id: '3', label: 'Missed', type: 'number'},
                   {id: '4', label: 'Engaged', type: 'number'},
                   {id: '5', label: 'Unanswered', type: 'number'},
                   {id: '6', label: 'Average secs to pick-up', type: 'number'}],

            rows: [{c:[{v: 'Unknown'}, {v: 4895}, {v: 2886}, {v: 3}, {v: 302}, {v: 305}, {v: 8.5}]},{c:[{v: 'Aberdeen'}, {v: 7}, {v: 7}, {v: 0}, {v: 0}, {v: 0}, {v: 6.6}]}
                    ]
            },
            0.6
        )

        // Create a dashboard.
        var dashboard = new google.visualization.Dashboard(document.getElementById("dashboard_div"));

        // Define category pickers
        var controlPicker1 = new google.visualization.ControlWrapper({
            "controlType": "CategoryFilter",
            "containerId": "control1",
            "options": {
            "filterColumnLabel": "Geographical location",
            "ui": {
                "labelStacking": "horizontal",
                "allowTyping": true,
                "allowMultiple": true
            }
            }
        });

        var view = new google.visualization.DataView(data);

        // Create a chart, passing some options
        barChart = new google.visualization.ChartWrapper({
            "chartType": "BarChart",
            "containerId": "chart_div",
            "options": {
            "width": "100%",
            "height": "120%",
            "vAxis": {title: "Geographical location"},
            "hAxis": {title: "Number of calls"},
            "fontSize": 14,
            "chartArea": {top: 0, right: 0, bottom: 0, height:"100%", width:"70%"}
            },
            "view": {"columns": [0,1,2,3,4,5,6]}
        });

        google.visualization.events.addListener(dashboard, "ready", function() {

            // Dashboard redraw, have a look at how many rows the barChart is displaying
            var numRows = barChart.getDataTable().getNumberOfRows();
            if(ChartColumnsLength){
                var numCols = ChartColumnsLength.length-1;
            }else{
                var numCols = barChart.getDataTable().getNumberOfColumns()-1;
            }
            var expectedHeight = (numRows * (numCols * 20))+70;
            if (parseInt(barChart.getOption("height"), 10) != expectedHeight) {
                // Update the chart options and redraw just it
                drawDiv("chart_div", expectedHeight);
                barChart.setOption("height", expectedHeight);
                barChart.setOption("width", "100%");
                barChart.setOption("chartArea", {top: 10, right: 0, bottom: 0, height: (expectedHeight-70), width:"70%"});
                barChart.draw();
            }
        });

        // Establish dependencies, declaring that "filter" drives "barChart",
        // so that the pie chart will only display entries that are let through
        // given the chosen slider range.
        dashboard.bind(controlPicker1, barChart);
        // Draw the dashboard.
        dashboard.draw(view);
    }

    function drawDiv(id,h) {
        var div=document.getElementById(id);
        h = (h) + "px";

        var w=parseInt(div.style.width);
        w = ($(this).width()-200) + "px";

        $(div).height(h);
        $(div).width(w);
    }

    function listValuesCheckBox(){

        var myArray = [];
        var k = 1;
        myArray[0]=0;
        var at_least_one_checked = false;
        for (var i=0; i < document.frm_obj.elements.length; i++) {
            var e = document.frm_obj.elements[i];
            if(e.checked == true){
                at_least_one_checked = true;
                myArray[k] = parseInt(e.value,10);
                k = k+1;
            }

        }
        if(at_least_one_checked == true){
            return myArray;
        }else{
            alert("I cannot display a chart with zero bars. Please select at least one bar using the tick boxes.");
            stop_script_running;
        }
    }

    function changeChartColumns() {
        // ChartColumnsLength is a global variable
        ChartColumnsLength = listValuesCheckBox();
        barChart.setView({"columns": ChartColumnsLength});
        barChart.draw();
    }

    $(document).ready(function(){
        $("#start_date_uk").datepicker({
            changeMonth: true,
            numberOfMonths: 3,
            showButtonPanel: true,
            showCurrentAtPos: 1,
            autoSize: true,
            changeYear: true,
            dateFormat: "dd-mm-yy",
            defaultDate: new Date(2009, 09, 08),
            onSelect: function(dateText, inst) {
                $(".datepicker").datepicker("option", "defaultDate", dateText);
            }
        });
        $("#end_date_uk").datepicker({
            changeMonth: true,
            numberOfMonths: 3,
            showButtonPanel: true,
            showCurrentAtPos: 1,
            autoSize: true,
            changeYear: true,
            dateFormat: "dd-mm-yy",
            defaultDate: new Date(2011, 02, 28),
            onSelect: function(dateText, inst) {
                $(".datepicker").datepicker("option", "defaultDate", dateText);
            }
        });
    });

    </script>
//加载可视化API和控件包。
load(“可视化”,“1.1”,“包”:[“corechart”,“controls”]});
//将回调设置为在加载Google Visualization API时运行。
setOnLoadCallback(drawDashboard);
//创建并填充数据表的回调,
//实例化仪表板、范围滑块和饼图,
//传入数据并绘制它。
var柱状图;
柱长;
函数drawDashboard(){
//创建我们的数据表。
var data=new google.visualization.DataTable(
{
cols:[{id:'0',标签:'Geographical location',类型:'string'},
{id:'1',标签:'Total calls',类型:'number'},
{id:'2',标签:'Unique calls',类型:'number'},
{id:'3',标签:'Missed',类型:'number'},
{id:'4',标签:'Engaged',类型:'number'},
{id:'5',标签:'Unanswered',类型:'number'},
{id:'6',标签:'Average secs to pick-up',键入:'number'}],
行:[{c:[{v:[{v:'Unknown'},{v:4895},{v:2886},{v:3},{v:302},{v:305},{v:8.5}},{c:[{v:'Aberdeen'},{v:7},{v:0},{v:0},{v:0},{v:6}
]
},
0.6
)
//创建一个仪表板。
var dashboard=newgoogle.visualization.dashboard(document.getElementById(“dashboard_div”);
//定义类别选择器
var controlPicker1=新的google.visualization.ControlWrapper({
“controlType”:“CategoryFilter”,
“集装箱运输”:“控制1”,
“选择”:{
“filterColumnLabel”:“地理位置”,
“用户界面”:{
“标签装订”:“水平”,
“allowTyping”:正确,
“allowMultiple”:正确
}
}
});
var view=newgoogle.visualization.DataView(数据);
//创建一个图表,传递一些选项
barChart=新的google.visualization.ChartWrapper({
“图表类型”:“条形图”,
“集装箱船”:“海图分区”,
“选择”:{
“宽度”:“100%”,
“高度”:“120%”,
“vAxis”:{标题:“地理位置”},
“hAxis”:{标题:“呼叫数”},
“字体大小”:14,
“图表区域”:{顶部:0,右侧:0,底部:0,高度:“100%”,宽度:“70%”
},
“视图”:{“列”:[0,1,2,3,4,5,6]}
});
google.visualization.events.addListener(仪表板,“就绪”,函数(){
//重新绘制仪表板,查看条形图显示的行数
var numRows=barChart.getDataTable().getNumberOfRows();
如果(图表列长度){
var numCols=图表列长度。长度-1;
}否则{
var numCols=barChart.getDataTable().getNumberOfColumns()-1;
}
var预期高度=(numRows*(numCols*20))+70;
if(parseInt(barChart.getOption(“高度”),10)!=expectedHeight){
//更新图表选项并重新绘制它
drawDiv(“图表分区”,预期高度);
设置选项(“高度”,预期高度);
设置选项(“宽度”、“100%”);
setOption(“chartArea”,{top:10,right:0,bottom:0,height:(expectedHeight-70),width:“70%”);
barChart.draw();
}
});
//建立依赖关系,声明“过滤器”驱动“条形图”,
//这样,饼图将只显示通过的条目
//给定选定的滑块范围。
dashboard.bind(controlPicker1,条形图);
//绘制仪表板。
仪表板。绘制(视图);
}
函数drawDiv(id,h){
var div=document.getElementById(id);
h=(h)+“px”;
var w=parseInt(div.style.width);
w=($(this).width()-200)+“px”;
$(div).高度(h);
$(div).宽度(w);
}
函数listValuesCheckBox(){
var myArray=[];
var k=1;
myArray[0]=0;
var至少检查一次=false;
对于(变量i=0;i