From 81e8d196a001394857dab08453c3477578799145 Mon Sep 17 00:00:00 2001 From: Denis Fulachier <44165041+dfulachier@users.noreply.github.com> Date: Fri, 29 Nov 2019 15:29:51 +0100 Subject: [PATCH 1/3] SOC-689 - Upgrade Grafana Proper Plotly plug-in changes (marker size) --- .project | 11 +++++++++++ src/editor.ts | 17 +++++++++++++++++ src/module.ts | 11 ++++++++--- src/partials/tab_traces.html | 33 ++++++++++++++++++++++++++++----- 4 files changed, 64 insertions(+), 8 deletions(-) create mode 100644 .project diff --git a/.project b/.project new file mode 100644 index 0000000..cfb1020 --- /dev/null +++ b/.project @@ -0,0 +1,11 @@ + + + grafana-plotly-panel + + + + + + + + diff --git a/src/editor.ts b/src/editor.ts index 1d6425b..ad65ff4 100644 --- a/src/editor.ts +++ b/src/editor.ts @@ -41,6 +41,10 @@ export class EditorHelper { ctrl.cfg.traces.forEach(trace => { _.defaults(trace, PlotlyPanelCtrl.defaultTrace); const mapping = trace.mapping; + if (!mapping.size) { + mapping.size = defaultMappings.first; + changed = true; + } if (!mapping.color) { mapping.color = defaultMappings.first; changed = true; @@ -275,6 +279,19 @@ export class EditorHelper { this.onConfigChanged(); } + getSizeSegments(): any[] { + if (this.trace.settings.size_option === 'proportional') { + return [this.mapping.size]; + } + return []; + } + + onSizeChanged() { + const seg = this.mapping.size; + this.updateSegMapping(seg.value, 'size', true); + this.onConfigChanged(); + } + getColorSegments(): any[] { if (this.trace.settings.color_option === 'ramp') { return [this.mapping.color]; diff --git a/src/module.ts b/src/module.ts index 1140de2..614979d 100644 --- a/src/module.ts +++ b/src/module.ts @@ -63,6 +63,7 @@ class PlotlyPanelCtrl extends MetricsPanelCtrl { }, showscale: false, }, + size_option: 'fixed', color_option: 'ramp', }, }; @@ -654,9 +655,13 @@ class PlotlyPanelCtrl extends MetricsPanelCtrl { mode += '+markers'; trace.marker = config.settings.marker; - delete trace.marker.sizemin; - delete trace.marker.sizemode; - delete trace.marker.sizeref; + if (config.settings.size_option === 'proportional') { + this.__addCopyPath(trace, mapping.size, 'marker.size'); + } else { + delete trace.marker.sizemin; + delete trace.marker.sizemode; + delete trace.marker.sizeref; + } if (config.settings.color_option === 'ramp') { this.__addCopyPath(trace, mapping.color, 'marker.color'); diff --git a/src/partials/tab_traces.html b/src/partials/tab_traces.html index 047b6d7..6d26669 100644 --- a/src/partials/tab_traces.html +++ b/src/partials/tab_traces.html @@ -82,6 +82,25 @@
Markers
+
+ +
+
+ +
+ + +
+ +
+ Markers placeholder="5" ng-blur="ctrl.onConfigChanged()" />
- -
+
+
-
+
+
- -->
From 8d1a206363381565df49176d9c49e973aa907e21 Mon Sep 17 00:00:00 2001 From: Denis Fulachier <44165041+dfulachier@users.noreply.github.com> Date: Fri, 29 Nov 2019 15:48:20 +0100 Subject: [PATCH 2/3] Delete .project --- .project | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 .project diff --git a/.project b/.project deleted file mode 100644 index cfb1020..0000000 --- a/.project +++ /dev/null @@ -1,11 +0,0 @@ - - - grafana-plotly-panel - - - - - - - - From 7bc1b37bda47473070c408b506032f2509bbba5b Mon Sep 17 00:00:00 2001 From: Denis Fulachier <44165041+dfulachier@users.noreply.github.com> Date: Mon, 10 Feb 2020 08:47:29 +0100 Subject: [PATCH 3/3] SOC-917 - report "Application Distribution" issue --- src/module.ts | 18 ++++++++++++++++++ src/partials/tab_traces.html | 7 +++++++ 2 files changed, 25 insertions(+) diff --git a/src/module.ts b/src/module.ts index 614979d..2f1ee2f 100644 --- a/src/module.ts +++ b/src/module.ts @@ -693,6 +693,23 @@ class PlotlyPanelCtrl extends MetricsPanelCtrl { }); } + // Terminate trace initialisation, once data are set + _postUpdateTrace(trace: any) { + if (trace.marker.sizemax) { + trace.marker.sizeref = this._max(trace.marker.size) / (2 * trace.marker.sizemax); + } + } + + _max(array: number[]): number { + let max = 0; + for (let v of array) { + if (v > max) { + max = v; + } + } + return max; + } + // Fills in the required data into the trace values _updateTraceData(force = false): boolean { if (!this.series) { @@ -735,6 +752,7 @@ class PlotlyPanelCtrl extends MetricsPanelCtrl { vals = zero; } _.set(trace, v.path, vals); + this._postUpdateTrace(trace); }); } }); diff --git a/src/partials/tab_traces.html b/src/partials/tab_traces.html index 6d26669..8fef049 100644 --- a/src/partials/tab_traces.html +++ b/src/partials/tab_traces.html @@ -130,6 +130,13 @@
Markers
-->
+ +
+ + +
+