changeset e9cf1175e69a in sao:5.4
details: https://hg.tryton.org/sao?cmd=changeset;node=e9cf1175e69a
description:
Put data with the same x value at the same position
c3js put a point for each x value even if they are the same.
So we must add y value at the same position if the x is already
registered.
issue9539
review298671002
(grafted from c6417f0a412154088f09804a4f0c9e9bced152cb)
diffstat:
src/view/graph.js | 14 ++++++--------
1 files changed, 6 insertions(+), 8 deletions(-)
diffs (47 lines):
diff -r f04bbd575b04 -r e9cf1175e69a src/view/graph.js
--- a/src/view/graph.js Wed Nov 11 15:55:07 2020 +0100
+++ b/src/view/graph.js Mon Nov 16 21:24:59 2020 +0100
@@ -99,7 +99,10 @@
if (x && (x.isDate || x.isDateTime)) {
x = x.toString();
}
- data.columns[0][index + 1] = x;
+ var pos = data.columns[0].indexOf(x);
+ if (pos < 0) {
+ pos = data.columns[0].push(x) - 1;
+ }
this._add_id(x, record.id);
var column;
@@ -117,18 +120,17 @@
}
var decoder = new Sao.PYSON.Decoder(ctx);
if (!decoder.decode(yfield.domain)) {
- column[index + 1] = 0;
continue;
}
}
if (yfield.name == '#') {
- column[index + 1] = 1;
+ column[pos] += 1;
} else {
var value = record.field_get(yfield.name);
if (value && value.isTimeDelta) {
value = value.asSeconds();
}
- column[index + 1] = value || 0;
+ column[pos] = (column[pos] || 0) + (value || 0);
}
}
}.bind(this);
@@ -143,10 +145,6 @@
for (i = 0, len = group.length; i < len; i++) {
record = group[i];
fields2load.forEach(load_field(group[i]));
-
- for (j = 0, y_len = data.columns.length; j < y_len; j++) {
- data.columns[j].push(undefined);
- }
r_prms.push(
jQuery.when.apply(jQuery, prms).then(set_data(i)));
}