Re: [visualization-api] two identical graphics

20 views
Skip to first unread message

Sergey Grabkovsky

unread,
Nov 6, 2015, 8:08:39 AM11/6/15
to Google Visualization API
This is a known issue with Material charts in 1.1. Please refer to this bug: https://github.com/google/google-visualization-issues/issues/2066

On Fri, Nov 6, 2015 at 12:18 AM Вячеслав В. Шерх <sher...@gmail.com> wrote:
Why does 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>

--
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/1d491b6a-ce28-485c-8dd7-1688cba77059%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
unnamed.gif 
Sergey Grabkovsky | SWE  | gra...@google.com
Reply all
Reply to author
Forward
0 new messages