2019-05-08 15:50:23 +02:00
|
|
|
/**
|
|
|
|
* @provides javelin-chart-curtain-view
|
|
|
|
*/
|
|
|
|
JX.install('ChartCurtainView', {
|
|
|
|
|
|
|
|
construct: function() {
|
|
|
|
this._labels = [];
|
|
|
|
},
|
|
|
|
|
|
|
|
members: {
|
|
|
|
_node: null,
|
|
|
|
_labels: null,
|
|
|
|
_labelsNode: null,
|
|
|
|
|
|
|
|
getNode: function() {
|
|
|
|
if (!this._node) {
|
|
|
|
var attr = {
|
|
|
|
className: 'chart-curtain'
|
|
|
|
};
|
|
|
|
|
|
|
|
this._node = JX.$N('div', attr);
|
|
|
|
}
|
|
|
|
return this._node;
|
|
|
|
},
|
|
|
|
|
|
|
|
reset: function() {
|
|
|
|
this._labels = [];
|
|
|
|
},
|
|
|
|
|
|
|
|
addFunctionLabel: function(label) {
|
|
|
|
this._labels.push(label);
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
|
|
|
redraw: function() {
|
|
|
|
var content = [this._getFunctionLabelsNode()];
|
|
|
|
|
|
|
|
JX.DOM.setContent(this.getNode(), content);
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
|
|
|
_getFunctionLabelsNode: function() {
|
|
|
|
if (!this._labels.length) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!this._labelsNode) {
|
|
|
|
var list_attrs = {
|
|
|
|
className: 'chart-function-label-list'
|
|
|
|
};
|
|
|
|
|
|
|
|
var labels = JX.$N('ul', list_attrs);
|
|
|
|
|
|
|
|
var items = [];
|
|
|
|
for (var ii = 0; ii < this._labels.length; ii++) {
|
|
|
|
items.push(this._newFunctionLabelItem(this._labels[ii]));
|
|
|
|
}
|
|
|
|
|
|
|
|
JX.DOM.setContent(labels, items);
|
|
|
|
|
|
|
|
this._labelsNode = labels;
|
|
|
|
}
|
|
|
|
|
|
|
|
return this._labelsNode;
|
|
|
|
},
|
|
|
|
|
2019-05-08 16:06:14 +02:00
|
|
|
_newFunctionLabelItem: function(label) {
|
2019-05-08 15:50:23 +02:00
|
|
|
var item_attrs = {
|
|
|
|
className: 'chart-function-label-list-item'
|
|
|
|
};
|
|
|
|
|
|
|
|
var icon = new JX.PHUIXIconView()
|
2019-05-08 16:06:14 +02:00
|
|
|
.setIcon(label.getIcon());
|
|
|
|
|
|
|
|
// Charts may use custom colors, so we can't rely on the CSS classes
|
|
|
|
// which only provide standard colors like "red" and "blue".
|
|
|
|
icon.getNode().style.color = label.getColor();
|
2019-05-08 15:50:23 +02:00
|
|
|
|
|
|
|
var content = [
|
|
|
|
icon.getNode(),
|
2019-05-08 16:06:14 +02:00
|
|
|
label.getName()
|
2019-05-08 15:50:23 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
return JX.$N('li', item_attrs, content);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|