[view-graph,bugfix][s]: fix so we always redraw graph on data update (though perhaps only when graph becomes visible).
This commit is contained in:
@@ -82,7 +82,6 @@ my.Graph = Backbone.View.extend({
|
|||||||
</label> \
|
</label> \
|
||||||
<div class="input"> \
|
<div class="input"> \
|
||||||
<select> \
|
<select> \
|
||||||
<option value="">Please choose ...</option> \
|
|
||||||
{{#fields}} \
|
{{#fields}} \
|
||||||
<option value="{{id}}">{{label}}</option> \
|
<option value="{{id}}">{{label}}</option> \
|
||||||
{{/fields}} \
|
{{/fields}} \
|
||||||
@@ -102,12 +101,18 @@ my.Graph = Backbone.View.extend({
|
|||||||
var self = this;
|
var self = this;
|
||||||
this.el = $(this.el);
|
this.el = $(this.el);
|
||||||
_.bindAll(this, 'render', 'redraw');
|
_.bindAll(this, 'render', 'redraw');
|
||||||
// we need the model.fields to render properly
|
this.needToRedraw = false;
|
||||||
this.model.bind('change', this.render);
|
this.model.bind('change', this.render);
|
||||||
this.model.fields.bind('reset', this.render);
|
this.model.fields.bind('reset', this.render);
|
||||||
this.model.fields.bind('add', this.render);
|
this.model.fields.bind('add', this.render);
|
||||||
this.model.currentDocuments.bind('add', this.redraw);
|
this.model.currentDocuments.bind('add', this.redraw);
|
||||||
this.model.currentDocuments.bind('reset', this.redraw);
|
this.model.currentDocuments.bind('reset', this.redraw);
|
||||||
|
// because we cannot redraw when hidden we may need when becoming visible
|
||||||
|
this.bind('view:show', function() {
|
||||||
|
if (this.needToRedraw) {
|
||||||
|
self.redraw();
|
||||||
|
}
|
||||||
|
});
|
||||||
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
|
||||||
@@ -185,6 +190,7 @@ my.Graph = Backbone.View.extend({
|
|||||||
// * There is no data for the plot -- either same error or may have issues later with errors like 'non-existent node-value'
|
// * There is no data for the plot -- either same error or may have issues later with errors like 'non-existent node-value'
|
||||||
var areWeVisible = !jQuery.expr.filters.hidden(this.el[0]);
|
var areWeVisible = !jQuery.expr.filters.hidden(this.el[0]);
|
||||||
if ((!areWeVisible || this.model.currentDocuments.length === 0)) {
|
if ((!areWeVisible || this.model.currentDocuments.length === 0)) {
|
||||||
|
this.needToRedraw = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// check we have something to plot
|
// check we have something to plot
|
||||||
|
|||||||
Reference in New Issue
Block a user