forked from hpcc-systems/Visualization
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBubble.js
More file actions
77 lines (65 loc) · 2.86 KB
/
Bubble.js
File metadata and controls
77 lines (65 loc) · 2.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
"use strict";
(function(root, factory) {
if (typeof define === "function" && define.amd) {
define(["d3", "./CommonXY", "amcharts.xy", "../api/INDChart", "css!./Bar"], factory);
} else {
root.amchart_Bubble = factory(root.d3, root.amchart_CommonXY, root.amcharts, root.api_INDChart);
}
}(this, function(d3, CommonXY, AmCharts, INDChart) {
function Bubble() {
CommonXY.call(this);
this._tag = "div";
this._type = "Bubble";
this._gType = "column";
}
Bubble.prototype = Object.create(CommonXY.prototype);
Bubble.prototype.constructor = Bubble;
Bubble.prototype._class += " amchart_Bubble";
Bubble.prototype.implements(INDChart.prototype);
Bubble.prototype.publish("paletteID", "default", "set", "Palette ID", Bubble.prototype._palette.switch(), {tags:["Basic","Shared"]});
Bubble.prototype.enter = function(domNode, element) {
CommonXY.prototype.enter.apply(this, arguments);
};
Bubble.prototype.updateChartOptions = function() {
CommonXY.prototype.updateChartOptions.apply(this, arguments);
this.buildGraphs(this._gType);
return this._chart;
};
Bubble.prototype.buildGraphs = function(gType) {
if (typeof(this._chart.graphs) === "undefined") { this._chart.graphs = []; }
var currentGraphCount = this._chart.graphs.length;
var buildGraphCount = Math.max(currentGraphCount, this._valueField.length);
for(var i = 0; i < buildGraphCount; i++) {
if ((typeof(this._valueField) !== "undefined" && typeof(this._valueField[i]) !== "undefined")) { //mark
var gRetVal = CommonXY.prototype.buildGraphObj.call(this,gType,i);
var gObj = buildGraphObj.call(this,gRetVal);
if (typeof(this._chart.graphs[i]) !== "undefined") {
for (var key in gObj) { this._chart.graphs[i][key] = gObj[key]; }
} else {
this._chart.addGraph(gObj);
}
} else {
this._chart.removeGraph(this._chart.graphs[i]);
}
}
function buildGraphObj(gObj) {
if (this._type === "Bubble") {
var fieldArr = ["value"];
var context = this;
fieldArr.forEach(function(field){
//if(typeof(context["_"+field+"Field"]) !== "undefined" && typeof(context["_"+field+"Field"][i]) !== "undefined"){
gObj[field+"Field"] = context["_"+field+"Field"][i]; //for bubble
//}
});
}
return gObj;
}
};
Bubble.prototype.update = function(domNode, element) {
CommonXY.prototype.update.apply(this, arguments);
this.updateChartOptions();
this._chart.validateNow();
this._chart.validateData();
};
return Bubble;
}));