What i want to do
Show multiple velvet on one page
What i have already done
Velvet was usually linear. Like Linecharts, I could show two diagrams on the same page without any problems. I used two separate drawChart () functions for them. Then I converted the diagrams to Barcharts (material design). Now it shows only one diagram. I already searched for the answer and found this: How to add two Google charts on one page? I follow this and it still does not work.
My code
<script type="text/javascript" src="https://www.google.com/jsapi"></script> <script type="text/javascript"> google.load("visualization", "1.1", { packages: ["Bar"] }); google.setOnLoadCallback(drawChart); function drawChart() { var data1 = new google.visualization.DataTable(); data1.addColumn("string", "Key1"); data1.addColumn("number", "Value1"); data1.addRows([ ['2015.01', 65.5], ['2015.02', 52.6], ['2015.03', 45.5], ['2015.04', 40.7], ['2015.05', 68.7], ['2015.06', 56.4], ['2015.07', 38.4], ['2015.08', 45.2], ['2015.09', 45.2], ['2015.10', 4.8] ]); var data2 = new google.visualization.DataTable(); data2.addColumn("string", "Key2"); data2.addColumn("number", "Value2"); data2.addRows([ ['2015.01', 300.08], ['2015.02', 455.08], ['2015.03', 454.62], ['2015.04', 362.93], ['2015.05', 527.12], ['2015.06', 588.28], ['2015.07', 409.93], ['2015.08', 432.08], ['2015.09', 462.33], ['2015.10', 32.38] ]); var options = {}; var chart1 = new google.charts.Bar(document.getElementById("chart_div1")); chart1.draw(data1, options); var chart2 = new google.charts.Bar(document.getElementById("chart_div2")); chart2.draw(data2, options); } </script> <div id="chart_div1"></div> <div id="chart_div2"></div>
Best here: https://jsfiddle.net/yrzf3v97/
Problem
It displays only one chart. Most of it is the first, and sometimes the second. Using the alert () function, it can confirm that the code works to the end.