Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/webroot/rsrc/js/application/fact/ChartCurtainView.js
12242 views
1
/**
2
* @provides javelin-chart-curtain-view
3
*/
4
JX.install('ChartCurtainView', {
5
6
construct: function() {
7
this._labels = [];
8
},
9
10
members: {
11
_node: null,
12
_labels: null,
13
_labelsNode: null,
14
15
getNode: function() {
16
if (!this._node) {
17
var attr = {
18
className: 'chart-curtain'
19
};
20
21
this._node = JX.$N('div', attr);
22
}
23
return this._node;
24
},
25
26
reset: function() {
27
this._labels = [];
28
},
29
30
addFunctionLabel: function(label) {
31
this._labels.push(label);
32
return this;
33
},
34
35
redraw: function() {
36
var content = [this._getFunctionLabelsNode()];
37
38
JX.DOM.setContent(this.getNode(), content);
39
return this;
40
},
41
42
_getFunctionLabelsNode: function() {
43
if (!this._labels.length) {
44
return null;
45
}
46
47
if (!this._labelsNode) {
48
var list_attrs = {
49
className: 'chart-function-label-list'
50
};
51
52
var labels = JX.$N('ul', list_attrs);
53
54
var items = [];
55
for (var ii = 0; ii < this._labels.length; ii++) {
56
items.push(this._newFunctionLabelItem(this._labels[ii]));
57
}
58
59
JX.DOM.setContent(labels, items);
60
61
this._labelsNode = labels;
62
}
63
64
return this._labelsNode;
65
},
66
67
_newFunctionLabelItem: function(label) {
68
var item_attrs = {
69
className: 'chart-function-label-list-item'
70
};
71
72
var icon = new JX.PHUIXIconView()
73
.setIcon(label.getIcon());
74
75
// Charts may use custom colors, so we can't rely on the CSS classes
76
// which only provide standard colors like "red" and "blue".
77
icon.getNode().style.color = label.getColor();
78
79
var content = [
80
icon.getNode(),
81
label.getName()
82
];
83
84
return JX.$N('li', item_attrs, content);
85
}
86
87
}
88
89
});
90
91