Google Charts: Drawing Multiple Bar Charts with dual axis in IE

前端 未结 2 619
抹茶落季
抹茶落季 2020-11-28 16:30

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

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-28 16:43

    I guess this is still a bug of the google visualization api. (link)

    However, I changed the Bar chart into a columnChart and changed the options for the axis so that they work with the column chart and it did the trick.

    However this https://jsfiddle.net/5b8au8t4/1/ is working.

    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,       
                  title: 'Nearby galaxies',
                  vAxes: {
    			0: {
    				title: 'parsecs',
    				
    				},
    			1: {
    				title: 'apparent magnitude',
    				
    			},
              },
                  series: {
    			0:{
    				targetAxisIndex:0,
    				
    				},
    			1:{
    				targetAxisIndex:1,
    				
    				},
                },
              };
              var chart = new google.visualization.ColumnChart(document.getElementById('dual_y_div'));
              chart.draw(data, options);
      var chart1 = new google.visualization.ColumnChart(document.getElementById('dual_y_div1'));
              chart1.draw(data, options);
    
          }
    
    
    

    I'm hoping that this will help you.

提交回复
热议问题