adding destroy, get and set methods back to vis

This commit is contained in:
Shelby Sturgis 2014-08-27 18:47:40 +03:00
parent 789707da22
commit ee4e44df96
4 changed files with 22 additions and 28 deletions

View file

@ -159,7 +159,7 @@
margin: 5px 10px;
}
.sidebar-item:hover:hover button.discover-field-toggle {
display: inherit;
display: block;
}
.discover-field-details-close {
text-align: center;
@ -229,6 +229,9 @@ disc-field-chooser ul.discover-selected-fields {
disc-field-chooser ul.discover-selected-fields li:first-child:nth-last-child(1)[field=_source] button.discover-field-toggle {
display: none;
}
disc-field-chooser .sidebar-item-title {
position: relative;
}
.results h3 {
margin: -20px 0 10px 0;
text-align: center;

View file

@ -102,10 +102,6 @@ define(function (require) {
return function (selection) {
selection.each(function (data) {
if (self._attr.destroFlag) {
throw new Error('You are trying to render a chart you have destroyed');
}
if (!yScale) {
throw new Error('yScale is ' + yScale);
}

View file

@ -47,21 +47,6 @@ define(function (require) {
.text('The container is too small for this chart.');
};
Chart.prototype.destroy = function () {
this._attr.destroyFlag = true;
// Removing chart and all elements associated with it
d3.select(this.chartEl).selectAll('*').remove();
// Cleaning up event listeners
this.off('click');
this.off('hover');
this.off('brush');
d3.select(window)
.on('resize', null);
};
Chart.prototype.set = function (name, val) {
this._attr[name] = val;
this.render();

View file

@ -37,6 +37,10 @@ define(function (require) {
throw new Error('No valid data!');
}
if (this._attr.destroyFlag) {
throw new Error('You tried rendering a visualization that has been destroyed');
}
// DATA CLASS
this.instantiateData(data);
@ -88,7 +92,6 @@ define(function (require) {
this.renderCharts(vis, charts);
this.checkSize();
};
Vis.prototype.resize = function () {
@ -109,20 +112,27 @@ define(function (require) {
setTimeout(this.checkSize(), 300);
}, 300);
// Vis.prototype.off = function () {
// return this.charts.off.apply(this.charts, arguments);
// };
Vis.prototype.destroy = function () {
return this.ChartClass.prototype.destroy.apply(this, arguments);
this._attr.destroyFlag = true;
// Removing chart and all elements associated with it
d3.select(this.el).selectAll('*').remove();
// Cleaning up event listeners
this.off('click');
this.off('hover');
this.off('brush');
d3.select(window)
.on('resize', null);
};
Vis.prototype.set = function (name, val) {
return this.chart.set(name, val);
this._attr[name] = val;
this.render();
};
Vis.prototype.get = function (name) {
return this.chart.get(name);
return this._attr[name];
};
return Vis;