changeset df69747029ff in sao:default
details: https://hg.tryton.org/sao?cmd=changeset;node=df69747029ff
description:
        Support sparse data in y's graph with domain

        The value when the domain skip the record should be undefined so the 
graph has
        no point at this ordinate.

        issue10072
        review337561002
diffstat:

 src/view/graph.js |  19 +++++++++++++++++--
 1 files changed, 17 insertions(+), 2 deletions(-)

diffs (54 lines):

diff -r 985e577df7f3 -r df69747029ff src/view/graph.js
--- a/src/view/graph.js Mon Feb 15 19:12:11 2021 +0100
+++ b/src/view/graph.js Tue Feb 16 22:38:16 2021 +0100
@@ -111,6 +111,9 @@
                         yfield = this.yfields[j];
                         key = yfield.key || yfield.name;
                         column = data.columns[key2columns[key]];
+                        if (column[pos] === undefined) {
+                            column[pos] = null;
+                        }
                         if (yfield.domain) {
                             var ctx = jQuery.extend({},
                                     Sao.Session.current_session.context);
@@ -124,6 +127,9 @@
                                 continue;
                             }
                         }
+                        if (!column[pos]) {
+                            column[pos] = 0;
+                        }
                         if (yfield.name == '#') {
                             column[pos] += 1;
                         } else {
@@ -131,7 +137,7 @@
                             if (value && value.isTimeDelta) {
                                 value = value.asSeconds();
                             }
-                            column[pos] = (column[pos] || 0) + (value || 0);
+                            column[pos] += value || 0;
                         }
                     }
                 }.bind(this);
@@ -260,11 +266,20 @@
             var config = Sao.View.Graph.HorizontalBar._super._c3_config
                 .call(this, data);
             config.axis.rotated = true;
+            return config;
         }
     });
 
     Sao.View.Graph.Line = Sao.class_(Sao.View.Graph.Chart, {
-        _chart_type: 'line'
+        _chart_type: 'line',
+        _c3_config: function(data) {
+            var config =  Sao.View.Graph.Line._super._c3_config
+                .call(this, data);
+            config.line = {
+                connectNull: true,
+            };
+            return config;
+        }
     });
 
     Sao.View.Graph.Pie = Sao.class_(Sao.View.Graph.Chart, {

Reply via email to