|
|
@ -37,7 +37,7 @@ import { |
|
|
widgetType |
|
|
widgetType |
|
|
} from '@app/shared/models/widget.models'; |
|
|
} from '@app/shared/models/widget.models'; |
|
|
import { |
|
|
import { |
|
|
ChartType, FlotSelection, |
|
|
ChartType, |
|
|
TbFlotAxisOptions, |
|
|
TbFlotAxisOptions, |
|
|
TbFlotHoverInfo, |
|
|
TbFlotHoverInfo, |
|
|
TbFlotKeySettings, |
|
|
TbFlotKeySettings, |
|
|
@ -117,7 +117,7 @@ export class TbFlot { |
|
|
private mouseleaveHandler = this.onFlotMouseLeave.bind(this); |
|
|
private mouseleaveHandler = this.onFlotMouseLeave.bind(this); |
|
|
private flotClickHandler = this.onFlotClick.bind(this); |
|
|
private flotClickHandler = this.onFlotClick.bind(this); |
|
|
|
|
|
|
|
|
private enableSelection: FlotSelection; |
|
|
private enableSelection: boolean; |
|
|
private selectionMode: 'x' | null; |
|
|
private selectionMode: 'x' | null; |
|
|
|
|
|
|
|
|
private readonly showTooltip: boolean; |
|
|
private readonly showTooltip: boolean; |
|
|
@ -134,8 +134,8 @@ export class TbFlot { |
|
|
this.chartType = this.chartType || 'line'; |
|
|
this.chartType = this.chartType || 'line'; |
|
|
this.settings = ctx.settings as TbFlotSettings; |
|
|
this.settings = ctx.settings as TbFlotSettings; |
|
|
this.utils = this.ctx.$injector.get(UtilsService); |
|
|
this.utils = this.ctx.$injector.get(UtilsService); |
|
|
this.enableSelection = isDefined(this.settings.enableSelection) ? this.settings.enableSelection : 'enable'; |
|
|
this.enableSelection = isDefined(this.settings.enableSelection) ? this.settings.enableSelection : true; |
|
|
this.checkSelectionMode(); |
|
|
this.selectionMode = this.enableSelection ? 'x' : null; |
|
|
this.showTooltip = isDefined(this.settings.showTooltip) ? this.settings.showTooltip : true; |
|
|
this.showTooltip = isDefined(this.settings.showTooltip) ? this.settings.showTooltip : true; |
|
|
this.tooltip = this.showTooltip ? $('#flot-series-tooltip') : null; |
|
|
this.tooltip = this.showTooltip ? $('#flot-series-tooltip') : null; |
|
|
if (this.tooltip?.length === 0) { |
|
|
if (this.tooltip?.length === 0) { |
|
|
@ -172,7 +172,7 @@ export class TbFlot { |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
if (this.chartType === 'line' || this.chartType === 'bar' || this.chartType === 'state') { |
|
|
if (this.chartType === 'line' || this.chartType === 'bar' || this.chartType === 'state') { |
|
|
this.options.selection = { mode: this.selectionMode }; |
|
|
this.options.selection = { mode: this.selectionMode, touch: true }; |
|
|
this.options.xaxes = []; |
|
|
this.options.xaxes = []; |
|
|
this.xaxis = { |
|
|
this.xaxis = { |
|
|
mode: 'time', |
|
|
mode: 'time', |
|
|
@ -589,22 +589,6 @@ export class TbFlot { |
|
|
this.createPlot(); |
|
|
this.createPlot(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
mobileModeChanged() { |
|
|
|
|
|
this.checkSelectionMode(); |
|
|
|
|
|
this.options.selection = { mode: this.selectionMode }; |
|
|
|
|
|
this.redrawPlot(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private checkSelectionMode() { |
|
|
|
|
|
if (this.enableSelection === 'enable' || |
|
|
|
|
|
this.enableSelection === 'mobile' && this.ctx.isMobile || |
|
|
|
|
|
this.enableSelection === 'desktop' && !this.ctx.isMobile) { |
|
|
|
|
|
this.selectionMode = 'x'; |
|
|
|
|
|
} else { |
|
|
|
|
|
this.selectionMode = null; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public update() { |
|
|
public update() { |
|
|
if (this.updateTimeoutHandle) { |
|
|
if (this.updateTimeoutHandle) { |
|
|
clearTimeout(this.updateTimeoutHandle); |
|
|
clearTimeout(this.updateTimeoutHandle); |
|
|
@ -1272,7 +1256,7 @@ export class TbFlot { |
|
|
this.$element.css('pointer-events', ''); |
|
|
this.$element.css('pointer-events', ''); |
|
|
this.$element.addClass('mouse-events'); |
|
|
this.$element.addClass('mouse-events'); |
|
|
if (this.chartType !== 'pie') { |
|
|
if (this.chartType !== 'pie') { |
|
|
this.options.selection = {mode: this.selectionMode}; |
|
|
this.options.selection = {mode: this.selectionMode, touch: true}; |
|
|
this.$element.bind('plotselected', this.flotSelectHandler); |
|
|
this.$element.bind('plotselected', this.flotSelectHandler); |
|
|
this.$element.bind('dblclick', this.dblclickHandler); |
|
|
this.$element.bind('dblclick', this.dblclickHandler); |
|
|
} |
|
|
} |
|
|
|