google.visualization.columnchart

<html>  <head>    <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>    <script type="text/javascript">      google.charts.load('current', {'packages':['corechart', 'bar']});      google.charts.setOnLoadCallback(drawStuff);      function drawStuff() {        var button = document.getElementById('change-chart');        var chartDiv = document.getElementById('chart_div');        var data = google.visualization.arrayToDataTable([          ['Galaxy', 'Distance', 'Brightness'],          ['Canis Major Dwarf', 8000, 23.3],          ['Sagittarius Dwarf', 24000, 4.5],          ['Ursa Major II Dwarf', 30000, 14.3],          ['Lg. Magellanic Cloud', 50000, 0.9],          ['Bootes I', 60000, 13.1]        ]);        var materialOptions = {          width: 900,          chart: {            title: 'Nearby galaxies',            subtitle: 'distance on the left, brightness on the right'          },          series: {            0: { axis: 'distance' }, // Bind series 0 to an axis named 'distance'.            1: { axis: 'brightness' } // Bind series 1 to an axis named 'brightness'.          },          axes: {            y: {              distance: {label: 'parsecs'}, // Left y-axis.              brightness: {side: 'right', label: 'apparent magnitude'} // Right y-axis.            }          }        };        var classicOptions = {          width: 900,          series: {            0: {targetAxisIndex: 0},            1: {targetAxisIndex: 1}          },          title: 'Nearby galaxies - distance on the left, brightness on the right',          vAxes: {            // Adds titles to each axis.            0: {title: 'parsecs'},            1: {title: 'apparent magnitude'}          }        };        function drawMaterialChart() {          var materialChart = new google.charts.Bar(chartDiv);          materialChart.draw(data, google.charts.Bar.convertOptions(materialOptions));          button.innerText = 'Change to Classic';          button.onclick = drawClassicChart;        }        function drawClassicChart() {          var classicChart = new google.visualization.ColumnChart(chartDiv);          classicChart.draw(data, classicOptions);          button.innerText = 'Change to Material';          button.onclick = drawMaterialChart;        }        drawMaterialChart();    };    </script>  </head>  <body>    <button id="change-chart">Change to Classic</button>    <br><br>    <div id="chart_div" style="width: 800px; height: 500px;"></div>  </body></html>

Are there any code examples left?
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source