cosmetic remove unused methods
This commit is contained in:
48
client/d3/bar/base.js
vendored
48
client/d3/bar/base.js
vendored
@@ -1,51 +1,13 @@
|
||||
import extend from 'extend';
|
||||
|
||||
// This class is inspired by // http://bl.ocks.org/mbostock/3885304.
|
||||
|
||||
const DEFAULTS = {
|
||||
outer_width: 500,
|
||||
outer_height: 300,
|
||||
margin: {top: 0, left: 70, bottom: 50, right: 20},
|
||||
horizontal: true,
|
||||
range_ticks: 10,
|
||||
container: "container",
|
||||
range_label: "range",
|
||||
titleize: function(series, datum){
|
||||
var s = datum ? datum.name : series.name,
|
||||
words = s.split(' ');
|
||||
var array = [];
|
||||
for (var i=0; i<words.length; ++i) {
|
||||
array.push(words[i].charAt(0).toUpperCase() + words[i].toLowerCase().slice(1));
|
||||
}
|
||||
return array.join(' ');
|
||||
},
|
||||
toClass: function(series, datum){
|
||||
return datum ? datum.name.toLowerCase(): series.name.toLowerCase();
|
||||
},
|
||||
series_opacity_gradient: true
|
||||
}
|
||||
|
||||
class BarChart {
|
||||
|
||||
constructor(options){
|
||||
var bar_chart = this;
|
||||
bar_chart = extend(bar_chart, DEFAULTS, bar_chart.chart_options, options);
|
||||
|
||||
bar_chart.height = bar_chart.outer_height - bar_chart.margin.top - bar_chart.margin.bottom;
|
||||
bar_chart.width = bar_chart.outer_width - bar_chart.margin.left - bar_chart.margin.right;
|
||||
|
||||
bar_chart.init();
|
||||
}
|
||||
|
||||
init(){
|
||||
var bar_chart = this;
|
||||
|
||||
bar_chart.svg = d3.select(bar_chart.container).append("svg")
|
||||
.attr("width", bar_chart.outer_width)
|
||||
.attr("height", bar_chart.outer_height)
|
||||
.append("g")
|
||||
.attr("transform", "translate(" + bar_chart.margin.left + "," + bar_chart.margin.top + ")");
|
||||
bar_chart.defineAxes();
|
||||
get chart_options(){
|
||||
return {
|
||||
series_opacity_gradient: true,
|
||||
margin: {top: 0, left: 70, bottom: 50, right: 20}
|
||||
};
|
||||
}
|
||||
|
||||
serializeData(data){
|
||||
|
||||
54
client/d3/base.js
vendored
54
client/d3/base.js
vendored
@@ -11,16 +11,6 @@ const DEFAULTS = {
|
||||
range_label: undefined,
|
||||
domain_attr: undefined,
|
||||
range_attr: undefined,
|
||||
titleize: function(series, datum){
|
||||
var s = datum ? datum.title : 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));
|
||||
}
|
||||
return array.join(' ');
|
||||
},
|
||||
toCssClass: function(series){
|
||||
return series ? series.title.toLowerCase().replace(/\s+/g, '-') : "";
|
||||
}
|
||||
@@ -45,39 +35,6 @@ class Chart {
|
||||
if (chart.afterAxes) chart.afterAxes();
|
||||
}
|
||||
|
||||
defineAxes(){
|
||||
var chart = this;
|
||||
|
||||
chart.y_scale = d3.scale.linear()
|
||||
.range([chart.height, 0]);
|
||||
chart.y_axis = d3.svg.axis()
|
||||
.scale(chart.y_scale)
|
||||
.orient("left")
|
||||
.outerTickSize(1);
|
||||
|
||||
if (chart.time_series){
|
||||
chart.x_scale = d3.time.scale()
|
||||
.range([0, chart.width]);
|
||||
} else {
|
||||
chart.x_scale = d3.scale.linear()
|
||||
.range([0, chart.width]);
|
||||
}
|
||||
|
||||
chart.x_axis = d3.svg.axis()
|
||||
.scale(chart.x_scale)
|
||||
.orient("bottom")
|
||||
.outerTickSize(0)
|
||||
//chart.x_axis.tickFormat(d3.time.format('%b %d at %H'))
|
||||
//chart.x_axis.ticks(d3.time.hour, 12);
|
||||
|
||||
// append axes
|
||||
chart.svg.append("g")
|
||||
.attr("class", "d3-chart-range d3-chart-axis");
|
||||
chart.svg.append("g")
|
||||
.attr("class", "d3-chart-domain d3-chart-axis")
|
||||
.attr("transform", "translate(0, " + (chart.height) + ")");
|
||||
}
|
||||
|
||||
cssClass(series){
|
||||
var chart = this;
|
||||
if (!chart.toCssClass) return '';
|
||||
@@ -99,7 +56,16 @@ class Chart {
|
||||
extent.max_range = Math.max(max_range, value[range_attr]);
|
||||
});
|
||||
});
|
||||
returnextent
|
||||
return extent;
|
||||
}
|
||||
|
||||
titleize(s){
|
||||
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));
|
||||
}
|
||||
return array.join(' ');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ gulp.task('build', function(done) {
|
||||
} else if (yargs.argv.design){
|
||||
env = 'design';
|
||||
} else {
|
||||
throw new gutil.PluginError("webpack", "Must add '--production' or '--design' option.");
|
||||
throw new gutil.PluginError("webpack", "Must include '--production' or '--design' option.");
|
||||
}
|
||||
config = require(`${__dirname}/server/config/webpack/${env}`);
|
||||
// run webpack
|
||||
|
||||
Reference in New Issue
Block a user