Skip to content

Commit ecf053b

Browse files
committed
Merge pull request #942 from GordonSmith/GH-941
GH-941 HIPIE Property Passthrough to MultiChart
2 parents 272582d + 25e4ee7 commit ecf053b

File tree

4 files changed

+50
-15
lines changed

4 files changed

+50
-15
lines changed

src/chart/MultiChart.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,12 @@
114114
return this;
115115
};
116116

117+
MultiChart.prototype.chartTypeProperties = function (_) {
118+
if (!arguments.length) return this._chartTypeProperties;
119+
this._chartTypeProperties = _;
120+
return this;
121+
};
122+
117123
MultiChart.prototype.requireContent = function (chartType, callback) {
118124
var path = "src/" + this._allCharts[chartType].widgetClass.split("_").join("/");
119125
require([path], function (WidgetClass) {
@@ -122,6 +128,15 @@
122128
};
123129

124130
MultiChart.prototype.switchChart = function (callback) {
131+
if (this._switchingTo === this.chartType()) {
132+
if (callback) {
133+
callback(this);
134+
}
135+
return;
136+
} else if (this._switchingTo) {
137+
console.log("Attempting switch to: " + this.chartType() + ", before previous switch is complete (" + this._switchingTo + ")");
138+
}
139+
this._switchingTo = this.chartType();
125140
var oldContent = this.chart();
126141
var context = this;
127142
this.requireContent(this.chartType(), function (newContent) {
@@ -132,6 +147,20 @@
132147
.data(context._data)
133148
.size(size)
134149
;
150+
if (context._chartTypeProperties) {
151+
for (var key in context._chartTypeProperties) {
152+
if (newContent[key]) {
153+
try {
154+
newContent[key](context._chartTypeProperties[key]);
155+
} catch (e) {
156+
console.log("Exception Setting Property: " + key);
157+
}
158+
} else {
159+
console.log("Unknown Property: " + key);
160+
}
161+
}
162+
delete context._chartTypeProperties;
163+
}
135164
context.chart(newContent);
136165
if (oldContent) {
137166
oldContent
@@ -141,6 +170,7 @@
141170
;
142171
}
143172
}
173+
delete context._switchingTo;
144174
if (callback) {
145175
callback(this);
146176
}

0 commit comments

Comments
 (0)