Charts: Simplify canvas id parsing

This commit is contained in:
Aysam Guerler
2014-06-19 07:56:03 -04:00
parent 0c19d260fe
commit 19e643e12c
22 changed files with 54 additions and 44 deletions
@@ -34,6 +34,7 @@
.charts-grid .image {
padding: 10px;
width: 100px;
height: 86px;
}
.charts-grid .title {
File diff suppressed because one or more lines are too long
@@ -11,12 +11,13 @@ return Backbone.View.extend(
},
// render
draw : function(process_id, chart, request_dictionary) {
draw : function(process_id, chart, request_dictionary, canvas_list) {
var plot = new Plot(this.app, this.options);
plot.draw({
process_id : process_id,
chart : chart,
request_dictionary : request_dictionary,
canvas_list : canvas_list,
makeConfig : function(groups, plot_config){
$.extend(true, plot_config, {
seriesDefaults: {
@@ -11,7 +11,7 @@ return Backbone.View.extend(
},
// render
draw : function(process_id, chart, request_dictionary) {
draw : function(process_id, chart, request_dictionary, canvas_list) {
// configure request
var index = 0;
for (var i in request_dictionary.groups) {
@@ -28,6 +28,7 @@ return Backbone.View.extend(
process_id : process_id,
chart : chart,
request_dictionary : request_dictionary,
canvas_list : canvas_list,
makeConfig : function(groups, plot_config){
var boundary = Tools.getDomains(groups, 'x');
$.extend(true, plot_config, {
@@ -10,13 +10,14 @@ return Backbone.View.extend({
},
// render
draw : function(process_id, chart, request_dictionary) {
draw : function(process_id, chart, request_dictionary, canvas_list) {
var nvd3 = new NVD3(this.app, this.options);
nvd3.draw({
type : 'multiBarChart',
process_id : process_id,
chart : chart,
request_dictionary : request_dictionary
request_dictionary : request_dictionary,
canvas_list : canvas_list
});
}
});
@@ -10,13 +10,14 @@ return Backbone.View.extend({
},
// render
draw : function(process_id, chart, request_dictionary) {
draw : function(process_id, chart, request_dictionary, canvas_list) {
var nvd3 = new NVD3(this.app, this.options);
nvd3.draw({
type : 'multiBarHorizontalChart',
process_id : process_id,
chart : chart,
request_dictionary : request_dictionary
request_dictionary : request_dictionary,
canvas_list : canvas_list
});
}
});
@@ -10,7 +10,7 @@ return Backbone.View.extend({
},
// render
draw : function(process_id, chart, request_dictionary) {
draw : function(process_id, chart, request_dictionary, canvas_list) {
var nvd3 = new NVD3(this.app, this.options);
nvd3.draw({
type : 'multiBarHorizontalChart',
@@ -19,7 +19,8 @@ return Backbone.View.extend({
request_dictionary : request_dictionary,
makeConfig : function(nvd3_model) {
nvd3_model.stacked(true);
}
},
canvas_list : canvas_list
});
}
});
@@ -10,7 +10,7 @@ return Backbone.View.extend({
},
// render
draw : function(process_id, chart, request_dictionary) {
draw : function(process_id, chart, request_dictionary, canvas_list) {
var nvd3 = new NVD3(this.app, this.options);
nvd3.draw({
type : 'multiBarChart',
@@ -19,7 +19,8 @@ return Backbone.View.extend({
request_dictionary : request_dictionary,
makeConfig : function(nvd3_model) {
nvd3_model.stacked(true);
}
},
canvas_list : canvas_list
});
}
});
@@ -10,7 +10,7 @@ return Backbone.View.extend({
},
// render
draw : function(process_id, chart, request_dictionary){
draw : function(process_id, chart, request_dictionary, canvas_list){
// configure request
var index = 1;
for (var i in request_dictionary.groups) {
@@ -38,7 +38,8 @@ return Backbone.View.extend({
request_dictionary : request_dictionary,
makeConfig : function(nvd3_model) {
nvd3_model.options({showControls: true});
}
},
canvas_list : canvas_list
});
}
});
@@ -11,7 +11,7 @@ return Backbone.View.extend(
},
// render
draw : function(process_id, chart, request_dictionary)
draw : function(process_id, chart, request_dictionary, canvas_list)
{
// configure request
var index = 1;
@@ -46,7 +46,8 @@ return Backbone.View.extend(
request_dictionary : tmp_dict,
makeConfig : function(nvd3_model) {
nvd3_model.options({showControls: true});
}
},
canvas_list : canvas_list
});
}
});
@@ -10,13 +10,14 @@ return Backbone.View.extend({
},
// render
draw : function(process_id, chart, request_dictionary) {
draw : function(process_id, chart, request_dictionary, canvas_list) {
var nvd3 = new NVD3(this.app, this.options);
nvd3.draw({
type : 'lineChart',
process_id : process_id,
chart : chart,
request_dictionary : request_dictionary
request_dictionary : request_dictionary,
canvas_list : canvas_list
});
}
});
@@ -10,13 +10,14 @@ return Backbone.View.extend({
},
// render
draw : function(process_id, chart, request_dictionary) {
draw : function(process_id, chart, request_dictionary, canvas_list) {
var nvd3 = new NVD3(this.app, this.options);
nvd3.draw({
type : 'lineWithFocusChart',
process_id : process_id,
chart : chart,
request_dictionary : request_dictionary
request_dictionary : request_dictionary,
canvas_list : canvas_list
});
}
});
@@ -11,7 +11,7 @@ return Backbone.View.extend(
},
// render
draw : function(process_id, chart, request_dictionary) {
draw : function(process_id, chart, request_dictionary, canvas_list) {
// setup handler
var self = this;
request_dictionary.success = function() {
@@ -21,7 +21,7 @@ return Backbone.View.extend(
var group = request_dictionary.groups[group_index];
// draw group
self._draw_group(chart, group, self.options.canvas_list[group_index]);
self._draw_group(chart, group, canvas_list[group_index]);
}
// set chart state
@@ -10,7 +10,7 @@ return Backbone.View.extend({
},
// render
draw : function(process_id, chart, request_dictionary) {
draw : function(process_id, chart, request_dictionary, canvas_list) {
var nvd3 = new NVD3(this.app, this.options);
nvd3.draw({
type : 'scatterChart',
@@ -21,7 +21,8 @@ return Backbone.View.extend({
nvd3_model.showDistX(true)
.showDistY(true)
.color(d3.scale.category10().range());
}
},
canvas_list : canvas_list
});
}
});
@@ -11,7 +11,7 @@ return Backbone.View.extend(
},
// render
draw : function(process_id, chart, request_dictionary)
draw : function(process_id, chart, request_dictionary, canvas_list)
{
var nvd3 = new NVD3(this.app, this.options);
nvd3.draw({
@@ -23,7 +23,8 @@ return Backbone.View.extend(
nvd3_model.x(function(d) { return d.x })
.y(function(d) { return d.y })
.clipEdge(true);
}
},
canvas_list : canvas_list
});
}
});
@@ -10,7 +10,7 @@ return Backbone.View.extend({
},
// render
draw : function(process_id, chart, request_dictionary) {
draw : function(process_id, chart, request_dictionary, canvas_list) {
var nvd3 = new NVD3(this.app, this.options);
nvd3.draw({
type : 'stackedAreaChart',
@@ -21,7 +21,8 @@ return Backbone.View.extend({
nvd3_model.x(function(d) { return d.x })
.y(function(d) { return d.y })
.style('expand');
}
},
canvas_list : canvas_list
});
}
});
@@ -10,7 +10,7 @@ return Backbone.View.extend({
},
// render
draw : function(process_id, chart, request_dictionary) {
draw : function(process_id, chart, request_dictionary, canvas_list) {
var nvd3 = new NVD3(this.app, this.options);
nvd3.draw({
type : 'stackedAreaChart',
@@ -22,7 +22,8 @@ return Backbone.View.extend({
.y(function(d) { return d.y })
.clipEdge(true)
.style('stream');
}
},
canvas_list : canvas_list
});
}
});
@@ -10,7 +10,7 @@ return Backbone.View.extend({
},
// render
draw : function(process_id, chart, request_dictionary) {
draw : function(process_id, chart, request_dictionary, canvas_list) {
// backup chart
this.chart = chart;
@@ -18,7 +18,7 @@ return Backbone.View.extend({
var self = this;
var plot = Tools.panelHelper({
app : this.app,
canvas_list : this.options.canvas_list,
canvas_list : canvas_list,
process_id : process_id,
chart : chart,
request_dictionary : request_dictionary,
@@ -10,7 +10,7 @@ return Backbone.View.extend({
},
// render
draw : function(process_id, chart, request_dictionary) {
draw : function(process_id, chart, request_dictionary, canvas_list) {
// configure request
var index = 0;
var tmp_dict = {
@@ -46,7 +46,7 @@ return Backbone.View.extend({
var self = this;
var plot = Tools.panelHelper({
app : this.app,
canvas_list : this.options.canvas_list,
canvas_list : canvas_list,
process_id : process_id,
chart : chart,
request_dictionary : tmp_dict,
@@ -27,7 +27,7 @@ var View = Backbone.View.extend(
// ui elements
this.table_title = new Ui.Label({title: this.options.title});
this.table = new Table.View({content: this.options.content});
// create element
var $view = $('<div class="ui-table-form"/>');
if (this.options.title) {
@@ -228,11 +228,6 @@ var View = Backbone.View.extend(
// add to table
this.table.append(id);
// show/hide
if (settings_def.hide) {
this.table.get(id).hide();
}
}
});
@@ -16,8 +16,8 @@ return Backbone.View.extend(
// get current chart object
this.chart = this.app.chart;
this.form = new TableForm.View({
title : 'Chart options:',
// create settings
this.form = new TableForm.View(app, {
content : 'This chart type does not provide any options.'
});
@@ -161,20 +161,20 @@ return Backbone.View.extend({
var self = this;
require(['plugin/charts/' + this.app.chartPath(chart_type) + '/wrapper'], function(ChartView) {
// create chart and parse list of dom ids
var view = new ChartView(self.app, {canvas_list : self.canvas_list});
var view = new ChartView(self.app, {});
// request data
if (self.chart_definition.execute) {
self.app.jobs.request(chart, self._defaultSettingsString(chart), self._defaultRequestString(chart),
function() {
view.draw(process_id, chart, self._defaultRequestDictionary(chart));
view.draw(process_id, chart, self._defaultRequestDictionary(chart), self.canvas_list);
},
function() {
chart.deferred.done(process_id);
}
);
} else {
view.draw(process_id, chart, self._defaultRequestDictionary(chart));
view.draw(process_id, chart, self._defaultRequestDictionary(chart), self.canvas_list);
}
});
},