谷歌图表:在IE中绘制双轴的多个条形图 [英] Google Charts: Drawing Multiple Bar Charts with dual axis in IE

查看:104
本文介绍了谷歌图表:在IE中绘制双轴的多个条形图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在同一页面上创建了带有双轴的多个条形图。它在Chrome中正常工作,但它在IE中不起作用。在IE中它显示一个错误


对象不支持属性或方法'contains'


HTML& JavaScript代码如下:
$ b

startChart();函数startChart(){var data = new google.visualization.arrayToDataTable([''Galaxy','Distance','Brightness'],['Canis Major Dwarf',8000,23.3],['Sagittarius Dwarf',24000, 4.5',['Ursa Major II Dwarf',30000,14.3],['Lg。Magellanic Cloud',50000,0.9],['Bootes I',60000,13.1]]) var options = {width:900,chart:{title:'Nearby galaxies',subtitle:'distance on the left,brightness in right'},series:{0:{axis:'distance'},// Bind series 0到名为'distance'的轴。 1:{axis:'brightness'} //将系列1绑定到名为'brightness'的轴。 },轴:{y:{distance:{label:'parsecs'},//左y轴。亮度:{侧:'右',标签:'明显幅度'} //右y轴。 }}}; var chart = new google.charts.Bar(document.getElementById('dual_y_div')); chart.draw(数据,选项); var chart1 = new google.charts.Bar(document.getElementById('dual_y_div1')); chart1.draw(数据,选项); };

< script src =https:// ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js\"></script><script type =text / javascriptsrc =https://www.google。 ?COM / JSAPI自动加载= { '模块':[{ '名称': '可视化', '版本': '1.1', '包':[ '酒吧']}]}>< /脚本>< ; div id =double_y_divstyle =width:900px; height:500px;>< / div>< div id =dual_y_div1style =width:900px; height:500px;>< / div>

解决方案

以下是一个示例,需要进行更改,以供多个材料图表



  google.ch arts.load('41',{packages:['bar']}); google.charts.setOnLoadCallback(startChart); function startChart(){var data = new google.visualization.arrayToDataTable([['Galaxy','距离','亮度'],['大犬座矮人',8000,23.3],['射手座矮人',24000,4.5],['Ursa Major II Dwarf',30000,14.3],['Lg。 Magellanic Cloud',50000,0.9],['Bootes I',60000,13.1]]); var options = {width:900,chart:{title:'Nearby galaxies',subtitle:'distance on the left,brightness in right'},series:{0:{axis:'distance'},// Bind series 0到名为'distance'的轴。 1:{axis:'brightness'} //将系列1绑定到名为'brightness'的轴。 },轴:{y:{distance:{label:'parsecs'},//左y轴。亮度:{侧:'右',标签:'明显幅度'} //右y轴。 }}}; var chart = new google.charts.Bar(document.getElementById('dual_y_div')); chart.draw(数据,选项); var chart1 = new google.charts.Bar(document.getElementById('dual_y_div1')); chart1.draw(data,options);};  

< ; HEAD> < meta http-equiv =X-UA-Compatiblecontent =IE = edge/> < script src =https://www.gstatic.com/charts/loader.js>< / script>< / head>< body> < div id =dual_y_divstyle =width:900px; height:500px;>< / div> < div id =dual_y_div1style =width:900px; height:500px;>< / div>< / body>


I'm creating multiple bar charts with dual axis on the same page. It works fine in chrome but it doesn't work in IE. In IE it shows an error

"Object doesn't support property or method 'contains'"

HTML & JavaScript code as follows:

      

startChart();
      function startChart() {
       
          var data = new google.visualization.arrayToDataTable([
              ['Galaxy', 'Distance', 'Brightness'],
              ['Canis Major Dwarf', 8000, 23.3],
              ['Sagittarius Dwarf', 24000, 4.5],
              ['Ursa Major II Dwarf', 30000, 14.3],
              ['Lg. Magellanic Cloud', 50000, 0.9],
              ['Bootes I', 60000, 13.1]
          ]);

          var options = {
              width: 900,
              chart: {
                  title: 'Nearby galaxies',
                  subtitle: 'distance on the left, brightness on the right'
              },
              series: {
                  0: {
                      axis: 'distance'
                  }, // Bind series 0 to an axis named 'distance'.
                  1: {
                      axis: 'brightness'
                  } // Bind series 1 to an axis named 'brightness'.
              },
              axes: {
                  y: {
                      distance: {
                          label: 'parsecs'
                      }, // Left y-axis.
                      brightness: {
                          side: 'right',
                          label: 'apparent magnitude'
                      } // Right y-axis.
                  }
              }
          };

          var chart = new google.charts.Bar(document.getElementById('dual_y_div'));
          chart.draw(data, options);
  var chart1 = new google.charts.Bar(document.getElementById('dual_y_div1'));
          chart1.draw(data, options);

      };

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script type="text/javascript" src="https://www.google.com/jsapi?autoload={'modules':[{'name':'visualization','version':'1.1','packages':['bar']}]}"></script>
<div id="dual_y_div" style="width: 900px; height: 500px;"></div>
<div id="dual_y_div1" style="width: 900px; height: 500px;"></div>

解决方案

Following is an example, with the changes needed, for multiple Material Charts

google.charts.load('41', {packages: ['bar']});
google.charts.setOnLoadCallback(startChart);

function startChart() {

  var data = new google.visualization.arrayToDataTable([
    ['Galaxy', 'Distance', 'Brightness'],
    ['Canis Major Dwarf', 8000, 23.3],
    ['Sagittarius Dwarf', 24000, 4.5],
    ['Ursa Major II Dwarf', 30000, 14.3],
    ['Lg. Magellanic Cloud', 50000, 0.9],
    ['Bootes I', 60000, 13.1]
  ]);

  var options = {
    width: 900,
    chart: {
      title: 'Nearby galaxies',
      subtitle: 'distance on the left, brightness on the right'
    },
    series: {
      0: {
        axis: 'distance'
      }, // Bind series 0 to an axis named 'distance'.
      1: {
        axis: 'brightness'
      } // Bind series 1 to an axis named 'brightness'.
    },
    axes: {
      y: {
        distance: {
          label: 'parsecs'
        }, // Left y-axis.
        brightness: {
          side: 'right',
          label: 'apparent magnitude'
        } // Right y-axis.
      }
    }
  };

  var chart = new google.charts.Bar(document.getElementById('dual_y_div'));
  chart.draw(data, options);
  var chart1 = new google.charts.Bar(document.getElementById('dual_y_div1'));
  chart1.draw(data, options);
};

<head>
  <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
  <script src="https://www.gstatic.com/charts/loader.js"></script>
</head>
<body>
  <div id="dual_y_div" style="width: 900px; height: 500px;"></div>
  <div id="dual_y_div1" style="width: 900px; height: 500px;"></div>
</body>

这篇关于谷歌图表:在IE中绘制双轴的多个条形图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆