render daily energy graphs

This commit is contained in:
Eric Hulburd
2016-02-13 16:49:32 -06:00
parent b13c33d83c
commit 6713e756c4
19 changed files with 367 additions and 191 deletions

11
client/d3/base.js vendored
View File

@@ -1,3 +1,5 @@
import extend from 'extend';
const DEFAULTS = {
outer_width: 500,
outer_height: 300,
@@ -10,8 +12,9 @@ const DEFAULTS = {
domain_attr: undefined,
range_attr: undefined,
titleize: function(series, datum){
var s = datum ? datum.name : series.name,
words = s.split(' '),
var s = datum ? datum.name : series.title;
if (!s) return '';
var words = s.split(' '),
array = [];
for (var i=0; i<words.length; ++i) {
array.push(words[i].charAt(0).toUpperCase() + words[i].toLowerCase().slice(1));
@@ -28,7 +31,7 @@ class Chart {
constructor(options){
var chart = this;
chart = extend(chart, chart.constructor.DEFAULTS, options);
chart = extend(chart, chart.chart_options, options);
chart.height = chart.outer_height - chart.margin.top - chart.margin.bottom;
chart.width = chart.outer_width - chart.margin.left - chart.margin.right;
@@ -44,4 +47,6 @@ class Chart {
}
Chart.DEFAULTS = DEFAULTS;
export default Chart;