Skip to content

Instantly share code, notes, and snippets.

@genesisbertiz
Created July 20, 2018 06:13
Show Gist options
  • Save genesisbertiz/6b742d23cccd171b54f643bfe6125bf0 to your computer and use it in GitHub Desktop.
Save genesisbertiz/6b742d23cccd171b54f643bfe6125bf0 to your computer and use it in GitHub Desktop.
bar chart
license: mit
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<style>
</style>
</head>
<body>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load("current", {packages:["corechart"]});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
["Element", "Density", { role: "style" } ],
["07-20-18", -8.94, ""],
["07-21-18", 10.49, ""],
["07-22-18", 19.30, ""],
["07-23-18", 21.45, ""]
]);
var view = new google.visualization.DataView(data);
view.setColumns([0, 1,
{ calc: "stringify",
sourceColumn: 1,
type: "string",
role: "annotation" },
2]);
var options = {
title: "",
width: 600,
height: 400,
bar: {groupWidth: "95%"},
legend: { position: "none" },
};
var chart = new google.visualization.BarChart(document.getElementById("barchart_values"));
chart.draw(view, options);
}
</script>
<div id="barchart_values" style="width: 900px; height: 300px;"></div>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment