Skip to content

Instantly share code, notes, and snippets.

@donovanfm
Last active March 5, 2016 18:52
Show Gist options
  • Select an option

  • Save donovanfm/c986933c1dbc18cae6b5 to your computer and use it in GitHub Desktop.

Select an option

Save donovanfm/c986933c1dbc18cae6b5 to your computer and use it in GitHub Desktop.
rating count
Excellent 36
Very Good 22
Good 18
Average 15
Poor 69
Other 50
<!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 = 75,
width = 1400 - margin,
height = 600 - margin;
d3.select("body")
.append("h2")
.text("Company Feedback")
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
*/
var myChart = new dimple.chart(svg, data);
var x = myChart.addCategoryAxis("x", "rating");
var y = myChart.addMeasureAxis("y", "count");
x.addOrderRule(["Excellent", "Very Good", "Good", "Average", "Poor", "Other"]);
x.title = "Rating";
y.title = "Number of User Responses";
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.csv("company_feedback.csv", draw);
</script>
</body>
</html>
@donovanfm
Copy link
Author

preview

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment