|
|
@ -37,7 +37,7 @@ import { |
|
|
widgetType |
|
|
widgetType |
|
|
} from '@app/shared/models/widget.models'; |
|
|
} from '@app/shared/models/widget.models'; |
|
|
import { |
|
|
import { |
|
|
ChartType, |
|
|
ChartType, FlotSelection, |
|
|
TbFlotAxisOptions, |
|
|
TbFlotAxisOptions, |
|
|
TbFlotHoverInfo, |
|
|
TbFlotHoverInfo, |
|
|
TbFlotKeySettings, |
|
|
TbFlotKeySettings, |
|
|
@ -118,7 +118,8 @@ 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: boolean; |
|
|
private enableSelection: FlotSelection; |
|
|
|
|
|
private selectionMode: 'x' | null; |
|
|
|
|
|
|
|
|
private readonly showTooltip: boolean; |
|
|
private readonly showTooltip: boolean; |
|
|
private readonly animatedPie: boolean; |
|
|
private readonly animatedPie: boolean; |
|
|
@ -134,7 +135,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 : true; |
|
|
this.enableSelection = isDefined(this.settings.enableSelection) ? this.settings.enableSelection : 'enable'; |
|
|
|
|
|
this.checkSelectionMode(); |
|
|
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) { |
|
|
@ -171,7 +173,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.enableSelection ? 'x' : null }; |
|
|
this.options.selection = { mode: this.selectionMode }; |
|
|
this.options.xaxes = []; |
|
|
this.options.xaxes = []; |
|
|
this.xaxis = { |
|
|
this.xaxis = { |
|
|
mode: 'time', |
|
|
mode: 'time', |
|
|
@ -587,6 +589,24 @@ 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.selectionMode = 'x'; |
|
|
|
|
|
} else if (this.enableSelection === 'mobile' && this.ctx.isMobile) { |
|
|
|
|
|
this.selectionMode = 'x'; |
|
|
|
|
|
} else if (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); |
|
|
@ -1254,7 +1274,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.enableSelection ? 'x' : null}; |
|
|
this.options.selection = {mode: this.selectionMode}; |
|
|
this.$element.bind('plotselected', this.flotSelectHandler); |
|
|
this.$element.bind('plotselected', this.flotSelectHandler); |
|
|
this.$element.bind('dblclick', this.dblclickHandler); |
|
|
this.$element.bind('dblclick', this.dblclickHandler); |
|
|
} |
|
|
} |
|
|
|