From 05f4f8e05539840d9eee2b68ee96a2df5a775aa7 Mon Sep 17 00:00:00 2001 From: Kalutka Zhenya Date: Mon, 22 Aug 2022 13:46:05 +0300 Subject: [PATCH 1/2] Fix plotSelect for pie-flot --- .../home/components/widget/lib/flot-widget.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/flot-widget.ts b/ui-ngx/src/app/modules/home/components/widget/lib/flot-widget.ts index 3c93d03e84..62a4526ebc 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/flot-widget.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/flot-widget.ts @@ -159,13 +159,13 @@ export class TbFlot { autoHighlight: this.tooltipIndividual === true, markings: [] }, - selection : { mode : 'x' }, legend : { show: false } }; if (this.chartType === 'line' || this.chartType === 'bar' || this.chartType === 'state') { + this.options.selection = { mode : 'x' }; this.options.xaxes = []; this.xaxis = { mode: 'time', @@ -1210,9 +1210,11 @@ export class TbFlot { private enableMouseEvents() { this.$element.css('pointer-events', ''); this.$element.addClass('mouse-events'); - this.options.selection = { mode : 'x' }; + if (this.chartType !== 'pie') { + this.options.selection = {mode: 'x'}; + this.$element.bind('plotselected', this.flotSelectHandler); + } this.$element.bind('plothover', this.flotHoverHandler); - this.$element.bind('plotselected', this.flotSelectHandler); this.$element.bind('dblclick', this.dblclickHandler); this.$element.bind('mousedown', this.mousedownHandler); this.$element.bind('mouseup', this.mouseupHandler); @@ -1223,9 +1225,11 @@ export class TbFlot { private disableMouseEvents() { this.$element.css('pointer-events', 'none'); this.$element.removeClass('mouse-events'); - this.options.selection = { mode : null }; + if (this.chartType !== 'pie') { + this.options.selection = {mode: null}; + this.$element.unbind('plotselected', this.flotSelectHandler); + } this.$element.unbind('plothover', this.flotHoverHandler); - this.$element.unbind('plotselected', this.flotSelectHandler); this.$element.unbind('dblclick', this.dblclickHandler); this.$element.unbind('mousedown', this.mousedownHandler); this.$element.unbind('mouseup', this.mouseupHandler); From 5e4e3f73165e89e1081a40a04ff26ec170a0d6e8 Mon Sep 17 00:00:00 2001 From: Kalutka Zhenya Date: Mon, 22 Aug 2022 13:59:34 +0300 Subject: [PATCH 2/2] Refactoring --- .../src/app/modules/home/components/widget/lib/flot-widget.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/flot-widget.ts b/ui-ngx/src/app/modules/home/components/widget/lib/flot-widget.ts index 62a4526ebc..428cd7cef2 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/flot-widget.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/flot-widget.ts @@ -1213,9 +1213,9 @@ export class TbFlot { if (this.chartType !== 'pie') { this.options.selection = {mode: 'x'}; this.$element.bind('plotselected', this.flotSelectHandler); + this.$element.bind('dblclick', this.dblclickHandler); } this.$element.bind('plothover', this.flotHoverHandler); - this.$element.bind('dblclick', this.dblclickHandler); this.$element.bind('mousedown', this.mousedownHandler); this.$element.bind('mouseup', this.mouseupHandler); this.$element.bind('mouseleave', this.mouseleaveHandler); @@ -1228,9 +1228,9 @@ export class TbFlot { if (this.chartType !== 'pie') { this.options.selection = {mode: null}; this.$element.unbind('plotselected', this.flotSelectHandler); + this.$element.unbind('dblclick', this.dblclickHandler); } this.$element.unbind('plothover', this.flotHoverHandler); - this.$element.unbind('dblclick', this.dblclickHandler); this.$element.unbind('mousedown', this.mousedownHandler); this.$element.unbind('mouseup', this.mouseupHandler); this.$element.unbind('mouseleave', this.mouseleaveHandler);