[view/graph][xs]: refactor to have methods in standard order and events in events hash.
This commit is contained in:
46
src/view.js
46
src/view.js
@@ -629,6 +629,10 @@ my.FlotGraph = Backbone.View.extend({
|
|||||||
</div> \
|
</div> \
|
||||||
',
|
',
|
||||||
|
|
||||||
|
events: {
|
||||||
|
'change form select': 'onEditorSubmit'
|
||||||
|
},
|
||||||
|
|
||||||
initialize: function(options, chart) {
|
initialize: function(options, chart) {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.el = $(this.el);
|
this.el = $(this.el);
|
||||||
@@ -643,27 +647,6 @@ my.FlotGraph = Backbone.View.extend({
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
events: {
|
|
||||||
// 'change select': 'onEditorSubmit'
|
|
||||||
},
|
|
||||||
|
|
||||||
onEditorSubmit: function(e) {
|
|
||||||
var select = this.el.find('.editor-group select');
|
|
||||||
this._getEditorData();
|
|
||||||
this.plot.setData(this.createSeries());
|
|
||||||
this.plot.resize();
|
|
||||||
this.plot.setupGrid();
|
|
||||||
this.plot.draw();
|
|
||||||
},
|
|
||||||
_getEditorData: function() {
|
|
||||||
$editor = this
|
|
||||||
var series = this.$series.map(function () {
|
|
||||||
return $(this).val();
|
|
||||||
});
|
|
||||||
this.chartConfig.series = $.makeArray(series)
|
|
||||||
this.chartConfig.group = this.el.find('.editor-group select').val();
|
|
||||||
},
|
|
||||||
|
|
||||||
toTemplateJSON: function() {
|
toTemplateJSON: function() {
|
||||||
return this.model.toJSON();
|
return this.model.toJSON();
|
||||||
},
|
},
|
||||||
@@ -677,12 +660,27 @@ my.FlotGraph = Backbone.View.extend({
|
|||||||
this.$series = this.el.find('.editor-series select');
|
this.$series = this.el.find('.editor-series select');
|
||||||
this.$seriesClone = this.$series.parent().clone();
|
this.$seriesClone = this.$series.parent().clone();
|
||||||
var self = this;
|
var self = this;
|
||||||
this.el.find('form select').change(function() {
|
|
||||||
self.onEditorSubmit.apply(self, arguments)
|
|
||||||
});
|
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onEditorSubmit: function(e) {
|
||||||
|
var select = this.el.find('.editor-group select');
|
||||||
|
this._getEditorData();
|
||||||
|
this.plot.setData(this.createSeries());
|
||||||
|
this.plot.resize();
|
||||||
|
this.plot.setupGrid();
|
||||||
|
this.plot.draw();
|
||||||
|
},
|
||||||
|
|
||||||
|
_getEditorData: function() {
|
||||||
|
$editor = this
|
||||||
|
var series = this.$series.map(function () {
|
||||||
|
return $(this).val();
|
||||||
|
});
|
||||||
|
this.chartConfig.series = $.makeArray(series)
|
||||||
|
this.chartConfig.group = this.el.find('.editor-group select').val();
|
||||||
|
},
|
||||||
|
|
||||||
createPlot: function () {
|
createPlot: function () {
|
||||||
// only lines for the present
|
// only lines for the present
|
||||||
options = {
|
options = {
|
||||||
|
|||||||
Reference in New Issue
Block a user