Skip to content

Instantly share code, notes, and snippets.

@abkunal
Created June 4, 2017 13:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abkunal/d07cf0cf4a0c19f745bee30f3d21b614 to your computer and use it in GitHub Desktop.
Save abkunal/d07cf0cf4a0c19f745bee30f3d21b614 to your computer and use it in GitHub Desktop.
<style>
body {
text-align: center;
}
</style>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://dimplejs.org/dist/dimple.v2.0.0.min.js"></script>
<script>
function Display(data) {
"use strict";
var margin = 70,
width = 960 - margin,
height = 600 - margin;
d3.select("body")
.append("h1")
.text("Sales of US Food Giants (in $ Billions)");
var svg = d3.select("body")
.append("svg")
.attr("width", width)
.attr("height", height)
.append("g")
.attr("class", "chart");
var myChart = new dimple.chart(svg, data);
myChart.addCategoryAxis("x", "Brand");
myChart.addMeasureAxis("y", "Sales");
myChart.addSeries(null, dimple.plot.bar);
myChart.draw();
}
</script>
<script>d3.tsv("food.tsv", Display)</script>
Brand Sales
McDonald's 41
Burger King 11.3
Wendy's 9.4
KFC 8.2
Pizza Hut 8
Starbucks 4.1
Taco Bell 4.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment