浏览代码

HUE-7453 [frontend] Added multiserie to line chart

Enrico Berti 8 年之前
父节点
当前提交
b31f908
共有 1 个文件被更改,包括 11 次插入8 次删除
  1. 11 8
      desktop/core/src/desktop/static/desktop/js/ko.charts.plotly.js

+ 11 - 8
desktop/core/src/desktop/static/desktop/js/ko.charts.plotly.js

@@ -122,18 +122,21 @@
       window.clearTimeout(element.plotterTimeout);
       element.plotterTimeout = window.setTimeout(function () {
         var data = options.transformer(options.datum);
-        var chartData = {
-          x: [],
-          y: [],
-          type: 'scatter'
-        }
+        var chartData = [];
         data.forEach(function (el) {
+          var chartSerie = {
+            x: [],
+            y: [],
+            name: el.key,
+            type: 'scatter'
+          }
           el.values.forEach(function (serie) {
-            chartData.x.push(serie.x);
-            chartData.y.push(serie.y);
+            chartSerie.x.push(serie.x);
+            chartSerie.y.push(serie.y);
           });
+          chartData.push(chartSerie)
         });
-        Plotly.newPlot(element, [chartData], PLOTLY_COMMON_LAYOUT, PLOTLY_COMMON_OPTIONS);
+        Plotly.newPlot(element, chartData, PLOTLY_COMMON_LAYOUT, PLOTLY_COMMON_OPTIONS);
       }, 200);
     }
   };