Additional chart controls: toggle all, show total

This commit is contained in:
Arik Fraimovich 2014-06-10 09:16:12 +03:00
parent e8c946b88b
commit fc60c1b86a

View File

@ -81,6 +81,45 @@
series.update({stacking: newStacking}, true);
});
}
},
{
text: 'Select All',
onclick: function () {
_.each(this.series, function (s) {
s.setVisible(true, false);
});
this.redraw();
}
},
{
text: 'Unselect All',
onclick: function () {
_.each(this.series, function (s) {
s.setVisible(false, false);
});
this.redraw();
}
},
{
text: 'Show Total',
onclick: function () {
var data = {};
_.each(this.series, function (s) {
s.setVisible(false, false);
_.each(s.data, function (p) {
data[p.x] = data[p.x] || {'x': p.x, 'y': 0};
data[p.x].y = data[p.x].y + p.y;
});
});
this.addSeries({
data: _.values(data),
type: 'line',
name: 'Total'
}, false)
this.redraw();
}
}
]
}