}
WeightsDrawer.color = d3.scale.ordinal();
-WeightsDrawer.color.domain(nos_oignons_relays.map(function(r) {return r.fingerprint}));
-WeightsDrawer.color.range(nos_oignons_relays.map(function(r) {return r.color}));
+WeightsDrawer.color.domain(nos_oignons_groups.map(function(g) {return g.name}));
+WeightsDrawer.color.range(nos_oignons_groups.map(function(g) {return g.color}));
WeightsDrawer.prototype.draw_weights_graph = function(raw_data) {
var drawer = this;
}
});
+ var relayIndex = buildRelayIndex(raw_data.relays);
+
WeightsDrawer.sources.map(function(s) { return s.id; }).forEach(function(source) {
drawer.weights_data[source] = {};
WeightsDrawer.periods.map(function(p) { return p.id; }).forEach(function(period) {
var maxValue = 0;
- var relays = WeightsDrawer.color.domain().map(function(fingerprint) {
- var relay_data = raw_data["relays"].filter(function(d) { return d.fingerprint == fingerprint; })[0];
-
- var history = relay_data[source][period];
- var values = WeightsDrawer.extract_values(history, interval, minTime, maxTime);
- maxValue = maxValue + d3.max(values, function(d) { return d.y; });
-
- return {
- fingerprint: fingerprint,
- values: values,
- };
+ var relays = nos_oignons_groups.map(function(group) {
+ var group_values = sumGroupRelayValues(group, relayIndex, function(r) {
+ return WeightsDrawer.extract_values(r[source][period], interval, minTime, maxTime);
+ });
+ maxValue += (d3.max(group_values, function(d) { return d.y; }) || 0);
+ return { group: group.name, values: group_values };
});
drawer.weights_data[source][period] = {
minTime: minTime,
.enter().append("path")
.attr("class", "weight_graph area")
.attr("d", function(d) { return WeightsDrawer.area(d.values); })
- .style("fill", function(d) { return WeightsDrawer.color(d.fingerprint); });
+ .style("fill", function(d) { return WeightsDrawer.color(d.group); });
drawer.svg.append("g")
.attr("class", "x axis")
.style("padding-top", WeightsDrawer.margin.top + "px")
.style("box-sizing", "border-box");
- WeightsDrawer.color.domain().slice().reverse().forEach(function(d) {
- var name = nos_oignons_relays.filter(function(r) { return r.fingerprint == d; })[0].name;
+ WeightsDrawer.color.domain().slice().reverse().forEach(function(name) {
var item = legendDiv.append("div")
.style("display", "flex")
.style("align-items", "center")
.style("width", "14px")
.style("min-width", "14px")
.style("height", "14px")
- .style("background-color", WeightsDrawer.color(d))
+ .style("background-color", WeightsDrawer.color(name))
.style("margin-right", "5px");
item.append("span")
.style("font-size", "11px")