Google Visualization library loading creates two different results

偶尔善良 提交于 2019-12-11 13:31:28

问题


I'm having a very frustrating issue with proper loading of the Google Visualization library. I have two charts on my page. One is a columnchart and the other is a linechart.

Im loading my library like this: google.load('visualization', '1.0', {'packages':['corechart'],'callback':drawcharts});

Then im calling my columnchart like this:

var chart = new google.visualization.ColumnChart(chartDiv)

and my linechart like this:

myLineChart = new google.visualization.LineChart(document.getElementById('myChart2'));

This results in the following two charts:

The first pic is the linechart and that is the issue. When i instead load my visualization library like this:

google.load('visualization', '1.0', {'packages':['linechart','columnchart'], 'callback': drawcharts});

I get my linechart how I want it:

but my columnchart becomes like this:

I've tried adjusting the bar:groupwidth on the columnchart but i'm getting issues when using an Addlistener event on the columnchart.

How can I load the libraries required so I can have the corechart version of the linechart and the normal columnchart (not the one with corechart)? Basically, image 2 and 3? How is corechart.linechart different from just loading linechart?


回答1:


Such a silly mistake. My width of my chart div and the width set in my chart options were not the same. When I made them the same, it works fine.



来源:https://stackoverflow.com/questions/35133899/google-visualization-library-loading-creates-two-different-results

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!