Create Google Charts upside-down area chart - Javascript Google Chart

Javascript examples for Google Chart:Area Chart

Description

Create Google Charts upside-down area chart

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>Area Chart Example</title> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
   </head> 
   <body> 
      <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> 
      <div id="chart_div" style="width: 100%; height: 500px;"></div> 
      <script type="text/javascript">
      google.charts.load('current', {'packages':['corechart']});
      google.charts.setOnLoadCallback(drawChart);
      function drawChart() {/*from w ww. jav a2  s.  c om*/
        var data = google.visualization.arrayToDataTable([
          ['Year', 'Blue', 'Red'],
          ['0',  0,      20],
          ['2',  0,      20],
          ['4',  0,       20],
          ['6',  1,      19],
          ['8',  2,      18],
          ['10',  3,      17],
          ['12',  4,      16],
          ['14',  5,      15],
          ['16',  6,      14],
          ['18',  7,      13],
          ['20',  8,      12],
          ['22',  9,      11],
          ['24',  10,      10]
        ]);
        var options = {
          title: 'Company Performance',
          hAxis: {title: 'Year',  titleTextStyle: {color: '#333'}},
          vAxes: {
            0: {viewWindow: { min: 0, max: 20 }, baseline: 0},
            1: {viewWindow: { min: 0, max: 20 }, baseline: 20},
            },
          series: {
            1: { targetAxisIndex: 1 }
          }
        };
        var chart = new google.visualization.AreaChart(document.getElementById('chart_div'));
        chart.draw(data, options);
      }

      </script>  
   </body>
</html>

Related Tutorials