I need two identical graphics

36 views
Skip to first unread message

Вячеслав В. Шерх

unread,
Nov 6, 2015, 2:23:25 AM11/6/15
to Google Visualization API
Why draw only one chart? For earlier thanks for the reply. :)

Variant №1

<html>
<head>

<script type="text/javascript" src="https://www.google.com/jsapi"></script>


<script type="text/javascript">

google.load("visualization", "1.1", {packages:["bar"]});

google.setOnLoadCallback(function () {
drawChartProfit();
drawChart();
});

function drawChart() {
var data = google.visualization.arrayToDataTable([
['Year', 'Sales', 'Expenses', 'Profit'],
          ['2014', 1000, 400, 200],
          ['2015', 1170, 460, 250],
          ['2016', 660, 1120, 300],
          ['2017', 1030, 540, 350]
        ]);

var options = {
chart: {
title: 'Company Performance',
subtitle: 'Sales, Expenses, and Profit: 2014-2017',
          }
        };

var chart = new google.charts.Bar(document.getElementById('columnchart_material'));

chart.draw(data, options);
      }

function drawChartProfit() {
var dataProfit = google.visualization.arrayToDataTable([
['Year', 'Sales', 'Expenses', 'Profit'],
          ['2014', 1000, 400, 200],
          ['2015', 1170, 460, 250],
          ['2016', 660, 1120, 300],
          ['2017', 1030, 540, 350]
        ]);

var optionsProfit = {
chart: {
title: 'Company',
subtitle: 'Profit: 2014-2017',
          }
        };

var chartProfit = new google.charts.Bar(document.getElementById('columnchart_Profitmaterial'));

chartProfit.draw(dataProfit, optionsProfit);
      }


</script>

</head>
<body>
<div id="columnchart_material" style="width: 900px; height: 500px;"></div>
<br><br>
<div id="columnchart_Profitmaterial" style="width: 900px; height: 500px;"></div>

</body>
</html>

Variant №2

<html>
<head>

<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 data = google.visualization.arrayToDataTable([
['Year', 'Sales', 'Expenses', 'Profit'],
          ['2014', 1000, 400, 200],
          ['2015', 1170, 460, 250],
          ['2016', 660, 1120, 300],
          ['2017', 1030, 540, 350]
        ]);

var options = {
chart: {
title: 'Company Performance',
subtitle: 'Sales, Expenses, and Profit: 2014-2017',
          }
        };

var chart = new google.charts.Bar(document.getElementById('columnchart_material'));

chart.draw(data, options);
      }
</script>

<script type="text/javascript">
google.load("visualization", "1.1", {packages:["bar"]});

 google.setOnLoadCallback(drawChartProfit);

function drawChartProfit() {
var dataProfit = google.visualization.arrayToDataTable([
['Year', 'Sales', 'Expenses', 'Profit'],
          ['2014', 1000, 400, 200],
          ['2015', 1170, 460, 250],
          ['2016', 660, 1120, 300],
          ['2017', 1030, 540, 350]
        ]);

var optionsProfit = {
chart: {
title: 'Company Performance',
subtitle: 'Sales, Expenses, and Profit: 2014-2017',
          }
        };

var chartProfit = new google.charts.Bar(document.getElementById('columnchart_Profitmaterial'));

chartProfit.draw(dataProfit, optionsProfit);
      }
</script>

</head>
<body>
<div id="columnchart_material" style="width: 900px; height: 500px;"></div>
<br><br>
<div id="columnchart_Profitmaterial" style="width: 900px; height: 500px;"></div>

</body>
</html>

Sergey Grabkovsky

unread,
Nov 6, 2015, 8:05:22 AM11/6/15
to Google Visualization API
This is a known issue with 1.1. Please refer to this bug thread for more information: https://github.com/google/google-visualization-issues/issues/2066

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualizati...@googlegroups.com.
To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-visualization-api/09f3bdbd-5077-40a3-8173-1eb53b30dbcc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
unnamed.gif 
Sergey Grabkovsky | SWE  | gra...@google.com

Вячеслав В. Шерх

unread,
Nov 6, 2015, 9:04:31 AM11/6/15
to Google Visualization API
thank you very much

пятница, 6 ноября 2015 г., 19:05:22 UTC+6 пользователь Sergey написал:
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualization-api+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages