简体   繁体   English

Google图表:hi不是函数

[英]Google Charts: hi is not a function

The past few days I have been trying to execute my Google Charts webpage ( jsfiddle ), but it seems like the error keeps changing, even when I didn't do anything different except refresh the webpage. 过去几天,我一直在尝试执行我的Google Charts网页( jsfiddle ),但是即使我除了刷新网页外没有做任何其他事情,错误似乎也在不断变化。 I have tried using Chrome's "Empty Cache and hard reload" function, but that doesn't change anything. 我已经尝试使用Chrome的“空缓存和硬重载”功能,但这并没有任何改变。 The errors I have been getting include things like Uncaught typeError: hi is not a function . 我得到的错误包括Uncaught typeError: hi is not a function类的东西Uncaught typeError: hi is not a function I know this code works, because I was using it yesterday and it worked just fine. 我知道这段代码行得通,因为我昨天使用过它,并且一切正常。 I changed nothing in my code between the time it worked and now. 从工作到现在,我在代码中没有进行任何更改。 Am I importing something incorrectly, or is there something wrong with the Google Charts API. 我是错误地导入了某些内容,还是Google Charts API有问题? I get the same issue whenever I try to open Google's API 每当我尝试打开Google的API时,都会遇到相同的问题

javascript: javascript:

google.charts.load('current',{'packages':['controls','corechart']});
google.charts.setOnLoadCallback(drawDashboard);

function drawDashboard(){
    var dataSet = google.visualization.arrayToDataTable([
        [{label:'date',type:'datetime'},{label:'Bytes from network:Bytes to network',type:'number'}],
        [new Date(2016,01,23,00,00),1.0],
        [new Date(2016,01,23,01,00),1.0075187969924813],
        [new Date(2016,01,23,03,00),1.126865671641791],
        [new Date(2016,01,24,22,00),0.987012987012987],
        [new Date(2016,01,25,01,00),1.0],
        [new Date(2016,01,25,02,00),0.9166666666666666],
        [new Date(2016,01,25,10,00),1.0],
        [new Date(2016,01,26,12,00),1.0],
        [new Date(2016,01,27,17,00),0.9864864864864865],
        [new Date(2016,01,28,22,00),0.03125],
        [new Date(2016,02,01,22,00),0.97],
    ]);

    var dashboard = new google.visualization.Dashboard(document.getElementById('dashboard_div'));

    var dateRangeFilter = new google.visualization.ControlWrapper({'controlType':'ChartRangeFilter',
                                                                   'containerId':'filter_div',
                                                                   'options':{
                                                                       'filterColumnLabel':'date',
                                                                       'ui':{
                                                                           'chartOptions':{
                                                                               'chartArea':{
                                                                                   'width':'90%'
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                   });

    var lineChart = new google.visualization.ChartWrapper({'chartType':'LineChart',
                                                           'containerId':'curve_chart',
                                                           'options':{
                                                               'title': 'Total Bytes from the Source Network to Total Bytes To the Source Network per Day',
                                                               'curveType': 'function',
                                                               'chartArea': {'height': '80%', 'width': '90%'},
                                                               'legend': 'none'
                                                           }
                                                          });

    dashboard.bind(dateRangeFilter,lineChart);

    dashboard.draw(dataSet);
}

html: 的HTML:

<html>
    <head>
        <link rel="stylesheet" href="styles.css">
        <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
        <script type="text/javascript">
            //javascript code from above
        </script>
    </head>
    <body>
        <h1>Data for this IP network</h1>
        <hr />
        <a href="../index.html">&lt&ltBACK TO INDEX</a>
        <div id="dashboard_div">
            <div id="curve_chart"></div>
            <div id="filter_div"></div>
        </div>
    </body>
</html>

css: CSS:

h1{
    text-align:center;
}
#dashboard_div{
    border:1px solid #ccc;
    margin:10px;
}
#curve_chart{
    width:915px;
    height:300px;
}
#filter_div{
    width:915px;
    height:50px;
}

This is related to caching and redirects used by the loader mechanism. 这与加载程序机制使用的缓存和重定向有关。 A new release was pushed by the Google Visualization Team, and it broke a lot of people. Google可视化团队推了一个新版本,它打破了很多人的想法。 Fixing to version 43 or 44 instead of using 'current' in your loader call should fix the issue for now. 修复到版本43或44而不是在loader调用中使用“ current”,现在应该可以解决此问题。

See https://github.com/google/google-visualization-issues/issues/2185 参见https://github.com/google/google-visualization-issues/issues/2185

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM