You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by ri...@apache.org on 2022/03/01 14:38:23 UTC

[incubator-streampipes] branch dev updated: [STREAMPIPES-513] Improve value heatmap

This is an automated email from the ASF dual-hosted git repository.

riemer pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes.git


The following commit(s) were added to refs/heads/dev by this push:
     new d85dda9  [STREAMPIPES-513] Improve value heatmap
d85dda9 is described below

commit d85dda9d63f77ef7db175fe8dd2dcdc61f3a0bfb
Author: Dominik Riemer <do...@gmail.com>
AuthorDate: Tue Mar 1 15:37:49 2022 +0100

    [STREAMPIPES-513] Improve value heatmap
---
 .../value-heatmap/value-heatmap.component.ts       | 64 ++++++++++++++--------
 1 file changed, 41 insertions(+), 23 deletions(-)

diff --git a/ui/src/app/data-explorer/components/widgets/distribution-chart/value-heatmap/value-heatmap.component.ts b/ui/src/app/data-explorer/components/widgets/distribution-chart/value-heatmap/value-heatmap.component.ts
index 80ddfd6..450f99d 100644
--- a/ui/src/app/data-explorer/components/widgets/distribution-chart/value-heatmap/value-heatmap.component.ts
+++ b/ui/src/app/data-explorer/components/widgets/distribution-chart/value-heatmap/value-heatmap.component.ts
@@ -37,21 +37,27 @@ export class SpValueHeatmapComponent implements OnInit {
   widgetConfig: DistributionChartWidgetModel;
 
   configReady = true;
-  option = {
+  option: EChartsOption = {
+    grid: {
+      height: '80%',
+      top: '7%'
+    },
     tooltip: {},
     xAxis: {
       type: 'category',
-      data: [0, 1, 2, 3, 4, 5]
+      data: []
     },
     yAxis: {
       type: 'category',
-      data: [0]
+      data: []
     },
     visualMap: {
       min: 0,
       max: 1,
       calculable: true,
       realtime: false,
+      top: '10px',
+      left: '10px',
       inRange: {
         color: [
           '#313695',
@@ -72,7 +78,7 @@ export class SpValueHeatmapComponent implements OnInit {
       {
         name: 'Gaussian',
         type: 'heatmap',
-        data: [[1, 0, 0.2], [2, 0, 0.4]],
+        data: [],
         emphasis: {
           itemStyle: {
             borderColor: '#333',
@@ -98,28 +104,40 @@ export class SpValueHeatmapComponent implements OnInit {
   }
 
   initOptions() {
-    const dataResult = [];
-    const resolution: number = +this.widgetConfig.visualizationConfig.resolution;
-    const allRows = this.data_[0].allDataSeries[0].rows;
-    const allValues = allRows.map(row => row[1]);
-    const total = allValues.length;
-    let currentCount = 0;
-    allValues.sort((a, b) => (a - b));
-    let start = allValues[0];
-    for (let i = 0; i < allValues.length; i++) {
-      const value = allValues[i];
-      if (value < (start + resolution)) {
-        currentCount += 1;
+    if (this.data_) {
+      const dataResult = [];
+      const resolution: number = +this.widgetConfig.visualizationConfig.resolution;
+      const allRows = this.data_[0].allDataSeries[0].rows;
+      const fieldIndex = this.getFieldIndex(this.data_[0].allDataSeries[0].headers);
+      const allValues = allRows.map(row => row[fieldIndex]);
+      const total = allValues.length;
+      let currentCount = 0;
+      allValues.sort((a, b) => (a - b));
+      let start = allValues[0];
+      for (let i = 0; i < allValues.length; i++) {
+        const value = allValues[i];
+        if (value < (start + resolution)) {
+          currentCount += 1;
+        }
+        if (value >= (start + resolution) || (i + 1) === allValues.length) {
+          const currentRange = '>' + start.toFixed(2) + ((i + 1) < allValues.length ? '<' + (allValues[i + 1]).toFixed(2) : '');
+          dataResult.push([currentRange, 0, ((currentCount + 1) / total)]);
+          currentCount = 0;
+          start = allValues[i + 1];
+        }
       }
-      if (value >= (start + resolution) || (i + 1) === allValues.length) {
-        const currentRange = start.toFixed(2) + '-' + ((i + 1) < allValues.length ? (allValues[i + 1]).toFixed(2) : '');
-        dataResult.push([currentRange, 0, ((currentCount + 1) / total)]);
-        currentCount = 0;
-        start = allValues[i + 1];
+      this.dynamic = this.option;
+      (this.dynamic.xAxis as any).data = dataResult.map(r => r[0]);
+      this.dynamic.series[0].data = dataResult;
+      this.dynamic.series[0].name = this.data_[0].headers[fieldIndex];
+      if (this.eChartsInstance) {
+        this.eChartsInstance.setOption(this.dynamic);
       }
     }
-    this.option.xAxis.data = dataResult.map(r => r[0]);
-    this.option.series[0].data = dataResult;
+  }
+
+  getFieldIndex(headers: string[]) {
+    return headers.indexOf(this.widgetConfig.visualizationConfig.selectedProperty.fullDbName);
   }
 
   applySize(width: number, height: number) {