[view/graph][s]: make sure we do not try to draw if graph not yet properly configured.
* Was encountering a bug where data loads triggering a redraw but nothing yet properly configured. (This has been previously hidden by fact we don't draw if graph view is hidden -- which I had temporarily turned off).
This commit is contained in:
@@ -111,7 +111,7 @@ my.Graph = Backbone.View.extend({
|
|||||||
var stateData = _.extend({
|
var stateData = _.extend({
|
||||||
group: null,
|
group: null,
|
||||||
// so that at least one series chooser box shows up
|
// so that at least one series chooser box shows up
|
||||||
series: [""],
|
series: [],
|
||||||
graphType: 'lines-and-points'
|
graphType: 'lines-and-points'
|
||||||
},
|
},
|
||||||
options.state
|
options.state
|
||||||
@@ -134,7 +134,12 @@ my.Graph = Backbone.View.extend({
|
|||||||
if (this.state.get('group')) {
|
if (this.state.get('group')) {
|
||||||
this._selectOption('.editor-group', this.state.get('group'));
|
this._selectOption('.editor-group', this.state.get('group'));
|
||||||
}
|
}
|
||||||
_.each(this.state.get('series'), function(series, idx) {
|
// ensure at least one series box shows up
|
||||||
|
var tmpSeries = [""];
|
||||||
|
if (this.state.get('series').length > 0) {
|
||||||
|
tmpSeries = this.state.get('series');
|
||||||
|
}
|
||||||
|
_.each(tmpSeries, function(series, idx) {
|
||||||
self.addSeries(idx);
|
self.addSeries(idx);
|
||||||
self._selectOption('.editor-series.js-series-' + idx, series);
|
self._selectOption('.editor-series.js-series-' + idx, series);
|
||||||
});
|
});
|
||||||
@@ -182,20 +187,13 @@ my.Graph = Backbone.View.extend({
|
|||||||
if ((!areWeVisible || this.model.currentDocuments.length === 0)) {
|
if ((!areWeVisible || this.model.currentDocuments.length === 0)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// check we have something to plot
|
||||||
|
if (this.state.get('group') && this.state.get('series')) {
|
||||||
var series = this.createSeries();
|
var series = this.createSeries();
|
||||||
var options = this.getGraphOptions(this.state.attributes.graphType);
|
var options = this.getGraphOptions(this.state.attributes.graphType);
|
||||||
this.plot = $.plot(this.$graph, series, options);
|
this.plot = $.plot(this.$graph, series, options);
|
||||||
this.setupTooltips();
|
this.setupTooltips();
|
||||||
// create this.plot and cache it
|
}
|
||||||
// if (!this.plot) {
|
|
||||||
// this.plot = $.plot(this.$graph, series, options);
|
|
||||||
// } else {
|
|
||||||
// this.plot.parseOptions(options);
|
|
||||||
// this.plot.setData(this.createSeries());
|
|
||||||
// this.plot.resize();
|
|
||||||
// this.plot.setupGrid();
|
|
||||||
// this.plot.draw();
|
|
||||||
// }
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// ### getGraphOptions
|
// ### getGraphOptions
|
||||||
|
|||||||
Reference in New Issue
Block a user