Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/414.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 我想让谷歌图表对所有大小的设备都能做出响应_Javascript_Responsive_Pygooglechart - Fatal编程技术网

Javascript 我想让谷歌图表对所有大小的设备都能做出响应

Javascript 我想让谷歌图表对所有大小的设备都能做出响应,javascript,responsive,pygooglechart,Javascript,Responsive,Pygooglechart,我在我的webApp图表中自动生成了来自谷歌分析的数据,但并不是所有设备都能响应 JavaScript代码: var dataChart1 = new gapi.analytics.googleCharts.DataChart({ query: { 'ids': 'ga:789456123', // <-- Replace with the ids value for your view. 'start-date': '30daysAgo',

我在我的webApp图表中自动生成了来自谷歌分析的数据,但并不是所有设备都能响应

JavaScript代码:

 var dataChart1 = new gapi.analytics.googleCharts.DataChart({
    query: {
      'ids': 'ga:789456123', // <-- Replace with the ids value for your view.
      'start-date': '30daysAgo',
      'end-date': 'yesterday',
      'metrics': 'ga:pageviews',
      'filters': 'ga:pagePath==<?php echo $page; ?>',
      'dimensions': 'ga:date'
    },
    chart: {
      'container': 'chart-1-container',
      'type': 'LINE',
      'options': {
        'width': '40%'
      }
    }
  });
  dataChart1.execute();
var dataChart1=new gapi.analytics.googleCharts.DataChart({
查询:{

'ids':'ga:789456123',//请试试这个,它可以帮助你更好

$(window).resize(function(){
    drawChart();
});

绑定
窗口调整大小
事件侦听器,并在调整大小时重新绘制图表

例如,使用Jquery

$(window).resize(function(){
    redrawMychart() // impement this method which calls draw() method
});
编辑: 因为您使用的是嵌入式Api。。 调用
dataChart1.execute();
将在“窗口大小调整”中为您完成这项工作


注意:由于每次调整窗口大小时都会重新绘制,请寻找智能调整大小选项以防止多次重画。

感谢您的回复,但我不会绘制由google analytics生成的图表,我应该在哪里调用此方法以及如何使用此方法?您的意思是用函数windows.resize和在bod中替换chartname.execute吗函数调用chartname的y,execute?@mousa.Alshaikh,我的意思是调用
dataChart1.execute()
窗口上。调整
事件的大小,如果您的
dataChart1
变量应该可以在该范围内访问,请将其设置为
全局
,或者在
局部范围
中创建一个具有相同设置的新变量。谢谢,我将尝试它的工作,但不是针对所有图表。我有带地理类型的图表,还有一个带饼图的图表ats错误的调整大小功能它只在折线图上工作??感谢您的回复,我会尝试它以便更好地理解和使用,请看一下这个
$(window).resize(function(){
    redrawMychart() // impement this method which calls draw() method
});