Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import or require. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <div class="conteiner">

  <div class="wrap">
    <h1>Google Charts Basic BarChart</h1>

    <div class="tgt" id="target" ></div>
    <div class="tgt" id="target2" ></div>
    <div class="tgt" id="target3" ></div>
    <div class="tgt" id="target4" ></div>

    <div class="cont">
      <p>RWD</p>
    </div>

    <div class="cont">
      <p>RWD</p>
    </div>

  </div>
</div>
            
          
!
            
              body {
  background-color: #444;
}

.wrap {
  max-width: 1120px;
  width: 100%;
  padding: 10px;
  margin: 20px auto;
  background-color: #ccc;
  padding: 30px;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
}
h1 {
  margin-top: 10px;
  padding-bottom: 10px;
  width: 60%;
  text-align: center;
  font-weight: 100;
  color: #fff;
  border-bottom: 1px solid #eee;
}
.conteiner {
  display: flex;
  flex-wrap: wrap;
}

.tgt{
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 10px;
  width: 500px;
  min-height: 400px;
  background-color: #fff;
  svg{
    fill:#fff;
  }
}

.cont {
  min-width: 460px;
  min-height: 360px;
  width: auto;
  margin: 10px;
  max-width: 100%;
  height: 300px;
  padding: 20px;
  background-color: #eee;

  display: flex;
  justify-content: center;
  align-items: center;
  p {
    font-size: calc(3rem + 5vw);
    color: #fff;
  }
}

            
          
!
            
              (function() {
  "use strict";

  function drawChart() {
    var target = document.getElementById("target");
    var data;
    var options = {
      title: "My Bar Chart",
      width: "500",
      height: "400",
       colors: ["lightskyblue", "lightgreen"],
      animation: {
        startup: true,
        duration: 800,
        easing: "inAndOut"
      }
      //       isStacked: = 積み上げ表示
      // isStacked: true,
      //       percent = 100%表記
      // isStacked: "percent"
    };
    // var chart = new google.visualization.BarChart(target);
    var chart = new google.visualization.ColumnChart(target);
    data = new google.visualization.arrayToDataTable([
      ["Team", "Item-1", "Item-2"],
      ["Team A", 12, 38],
      ["Team B", 42, 18],
      ["Team C", 11, 58]
    ]);
    chart.draw(data, options);
  }

  google.charts.load("current", { packages: ["corechart"] });
  google.charts.setOnLoadCallback(drawChart);
})();

// Chart2
(function() {
  "use strict";

  function drawChart() {
    var target = document.getElementById("target2");
    var data;
    var options = {
      title: "My Line Chart",
      width: "500",
      height: "400",
      animation: {
        startup: true,
        duration: 800,
        easing: "inAndOut"
      },
      hAxis: { title: "Year" },
      vAxis: { title: "Sales" },
      curveType: "function",
      pointSize: 6
      // pointShape: 'square'
    };
    var chart = new google.visualization.LineChart(target);
    // var chart = new google.visualization.ColumnChart(target);
    data = new google.visualization.arrayToDataTable([
      // ["Year", "Bob", "Jane", { role: "certainty" }, "Carry"],
      // ["2017/05", 12, 38, null, 80],
      // ["2017/06", 42, 18, null, 10],
      // ["2017/07", 11, 58, 'Camp A', 130],
      // ["2017/08", 111, 158, null, 70]

      [
        "Year",
        "@アイテムA",
        { role: "annotation" },
        { role: "certainty" },
        "@アイテムB",
        { role: "certainty" }
      ],
      ["2014", 52, "キャンペーン A", true, 89, true],
      ["2015", 38, null, true, 78, true],
      ["2016", 122, "キャンペーン B", true, 88, true],
      ["2017", 62, null, true, 91, true],
      ["2018", 142, "想定売上げ", false, 101, false]
    ]);
    chart.draw(data, options);
  }

  google.charts.load("current", { packages: ["corechart"] });
  google.charts.setOnLoadCallback(drawChart);
})();

// Chart3 スプレッドシート

(function() {
  "use strict";

  function drawChart() {
    var query = new google.visualization.Query(
      "https://docs.google.com/spreadsheets/d/1KB-KcJDvV5dWla7OFnq-ip_HSwogRh-KMfGuPr2-1XQ/edit?usp=sharing"
    );
    query.send(handleQueryResponse);
  }

  function handleQueryResponse(response) {
    var target = document.getElementById("target3");
    var data;
    var options = {
      title: "Program Share",
      width: 500,
      height: 300,
      colors: ["darkgreen", "crimson","mediumblue","olive"],
    };
    var chart = new google.visualization.PieChart(target);
    data = response.getDataTable();
    chart.draw(data, options);
  }

  google.charts.load("current", { packages: ["corechart"] });
  google.charts.setOnLoadCallback(drawChart);
})();

// Chart 4

(function() {
  "use strict";

  function drawChart() {
    var target = document.getElementById("target4");
    var data;
    var options = {
      title: "My Bar Chart",
      width: "500",
      height: "400",
      animation: {
        startup: true,
        duration: 800,
        easing: "inAndOut"
      }
      //       isStacked: = 積み上げ表示
      // isStacked: true,
      //       percent = 100%表記
      // isStacked: "percent"
    };
    var chart = new google.visualization.BarChart(target);
    // var chart = new google.visualization.ColumnChart(target);
    data = new google.visualization.arrayToDataTable([
      ["Team", "Item-1", "Item-2"],
      ["Team A", 12, 38],
      ["Team B", 42, 18],
      ["Team C", 11, 58]
    ]);
    chart.draw(data, options);
  }

  google.charts.load("current", { packages: ["corechart"] });
  google.charts.setOnLoadCallback(drawChart);
})();

            
          
!
999px

Console