forked from hpcc-systems/Visualization
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SVGTemplate.js
51 lines (45 loc) · 1.69 KB
/
SVGTemplate.js
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
"use strict";
(function (root, factory) {
if (typeof define === "function" && define.amd) {
define(["src/common/SVGWidget", "css!./SVGTemplate"], factory);
} else {
root.template_SVGTemplate = factory(root.common_SVGWidget);
}
}(this, function (SVGWidget) {
function SVGTemplate(target) {
SVGWidget.call(this);
this._drawStartPos = "origin";
}
SVGTemplate.prototype = Object.create(SVGWidget.prototype);
SVGTemplate.prototype.constructor = SVGTemplate;
SVGTemplate.prototype._class += " template_SVGTemplate";
SVGTemplate.prototype.publish("stringProp", "defaultValue", "string", "Sample Property");
SVGTemplate.prototype.enter = function (domNode, element) {
SVGWidget.prototype.enter.apply(this, arguments);
};
SVGTemplate.prototype.update = function (domNode, element) {
SVGWidget.prototype.update.apply(this, arguments);
var g = element.selectAll(".dataRow").data(this.data());
g.enter().append("g")
.attr("class", "dataRow")
.each(function (d) {
var g = d3.select(this);
g.append("circle")
.attr("cx", -8)
.attr("cy", -4)
.attr("r", 4)
;
g.append("text");
})
;
g
.attr("transform", function (d, idx) { return "translate(32 " + ((idx + 1) * 16) + ")";})
;
g.select("text").text(function (row) { return row[0]; });
g.exit().remove();
};
SVGTemplate.prototype.exit = function (domNode, element) {
SVGWidget.prototype.exit.apply(this, arguments);
};
return SVGTemplate;
}));