Created
February 11, 2016 02:45
-
-
Save Inquisitive-Geek/d947f5e1aca82f1e3d1e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<script src="http://d3js.org/d3.v3.min.js"></script> | |
<script src="http://dimplejs.org/dist/dimple.v2.0.0.min.js"></script> | |
<style> | |
h2 { | |
text-align: center; | |
} | |
</style> | |
<script type="text/javascript"> | |
function draw(data) { | |
/* | |
D3.js setup code | |
*/ | |
"use strict"; | |
var margin = 30, | |
width = 1600 - margin, | |
height = 600 - margin; | |
var svg = d3.select("body"). | |
append("h2").text("Company v/s Market Share"); | |
var svg = d3.select("body") | |
.append("svg") | |
.attr("width", width + margin) | |
.attr("height", height + margin) | |
.append('g') | |
.attr('class','chart'); | |
/* | |
Dimple.js Chart construction code | |
*/ | |
debugger; | |
var myChart = new dimple.chart(svg, data); | |
var x = myChart.addCategoryAxis("x", "Company"); | |
myChart.addPctAxis("y", "Market Share"); | |
myChart.addSeries(null, dimple.plot.bar); | |
myChart.draw(); | |
}; | |
</script> | |
</head> | |
<body> | |
<script type="text/javascript"> | |
/* | |
Use D3 (not dimple.js) to load the TSV file | |
and pass the contents of it to the draw function | |
*/ | |
d3.tsv("smartphones.tsv", draw); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment