changeset 35f606b52910 in sao:5.8 details: https://hg.tryton.org/sao?cmd=changeset;node=35f606b52910 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 9b41bdce0cc0 -r 35f606b52910 src/view/graph.js --- a/src/view/graph.js Sun Nov 15 19:19:16 2020 +0100 +++ b/src/view/graph.js Mon Nov 16 21:24:59 2020 +0100 @@ -100,7 +100,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; @@ -118,18 +121,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); @@ -144,10 +146,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))); }