summaryrefslogtreecommitdiff
path: root/public
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2015-02-24 16:20:47 +0100
committerDaniel Friesel <derf@finalrewind.org>2015-02-24 16:20:47 +0100
commit8ad5eb58b01e068428652aabcb519281ab6c0461 (patch)
treea3ef3b5b3e224fd9953811d2f3c294339a2b9f86 /public
parentd991d48df768cfc990848d7aa661ce632a262847 (diff)
bargraph: optional width/height parameters
Diffstat (limited to 'public')
-rw-r--r--public/js/d3funcs.js15
1 files changed, 11 insertions, 4 deletions
diff --git a/public/js/d3funcs.js b/public/js/d3funcs.js
index 15fe5eb..f7f698d 100644
--- a/public/js/d3funcs.js
+++ b/public/js/d3funcs.js
@@ -1,8 +1,15 @@
-show_bargraph = function(datasource, title, xLabel, yLabel, yFormat) {
+show_bargraph = function(datasource, title, xLabel, yLabel, yFormat, width, height) {
- var margin = {top: 40, right: 20, bottom: 30, left: 40},
- width = 960 - margin.left - margin.right,
- height = 500 - margin.top - margin.bottom;
+ var margin = {top: 40, right: 20, bottom: 30, left: 40};
+
+ if (!width) {
+ width = 960;
+ }
+ if (!height) {
+ height = 500;
+ }
+ width -= margin.left + margin.right;
+ height -= margin.top + margin.bottom;
var x = d3.scale.ordinal()
.rangeRoundBands([0, width], .1);