Merge pull request #7793 from ArtemDzhereleiko/AD/feature/flot-selection
Add "Enable selection mode" settings with touch event for bar/state/line chart-widgets
This commit is contained in:
commit
c10531f53c
@ -136,6 +136,7 @@ export interface TbFlotYAxisSettings {
|
|||||||
|
|
||||||
export interface TbFlotBaseSettings {
|
export interface TbFlotBaseSettings {
|
||||||
stack: boolean;
|
stack: boolean;
|
||||||
|
enableSelection: boolean;
|
||||||
shadowSize: number;
|
shadowSize: number;
|
||||||
fontColor: string;
|
fontColor: string;
|
||||||
fontSize: number;
|
fontSize: number;
|
||||||
|
|||||||
@ -117,6 +117,9 @@ 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 selectionMode: 'x' | null;
|
||||||
|
|
||||||
private readonly showTooltip: boolean;
|
private readonly showTooltip: boolean;
|
||||||
private readonly animatedPie: boolean;
|
private readonly animatedPie: boolean;
|
||||||
private pieDataAnimationDuration: number;
|
private pieDataAnimationDuration: number;
|
||||||
@ -131,6 +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 : true;
|
||||||
|
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) {
|
||||||
@ -167,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 : 'x' };
|
this.options.selection = { mode: this.selectionMode, touch: true };
|
||||||
this.options.xaxes = [];
|
this.options.xaxes = [];
|
||||||
this.xaxis = {
|
this.xaxis = {
|
||||||
mode: 'time',
|
mode: 'time',
|
||||||
@ -1251,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: 'x'};
|
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);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,9 +18,14 @@
|
|||||||
<section class="tb-widget-settings" [formGroup]="flotSettingsFormGroup" fxLayout="column">
|
<section class="tb-widget-settings" [formGroup]="flotSettingsFormGroup" fxLayout="column">
|
||||||
<fieldset class="fields-group">
|
<fieldset class="fields-group">
|
||||||
<legend class="group-title" translate>widgets.chart.common-settings</legend>
|
<legend class="group-title" translate>widgets.chart.common-settings</legend>
|
||||||
<mat-checkbox formControlName="stack">
|
<section fxLayout="column" fxLayout.gt-xs="row" fxLayoutGap.gt-xs="8px" style="margin-bottom: 16px;">
|
||||||
|
<mat-checkbox fxFlex formControlName="stack">
|
||||||
{{ 'widgets.chart.enable-stacking-mode' | translate }}
|
{{ 'widgets.chart.enable-stacking-mode' | translate }}
|
||||||
</mat-checkbox>
|
</mat-checkbox>
|
||||||
|
<mat-checkbox fxFlex formControlName="enableSelection">
|
||||||
|
{{ 'widgets.chart.enable-selection-mode' | translate }}
|
||||||
|
</mat-checkbox>
|
||||||
|
</section>
|
||||||
<section *ngIf="chartType === 'graph'" fxLayout="column" fxLayout.gt-xs="row"
|
<section *ngIf="chartType === 'graph'" fxLayout="column" fxLayout.gt-xs="row"
|
||||||
fxLayoutGap.gt-xs="8px" fxLayoutAlign.gt-xs="start center">
|
fxLayoutGap.gt-xs="8px" fxLayoutAlign.gt-xs="start center">
|
||||||
<mat-form-field fxFlex class="mat-block">
|
<mat-form-field fxFlex class="mat-block">
|
||||||
|
|||||||
@ -45,6 +45,7 @@ import { defaultLegendConfig, widgetType } from '@shared/models/widget.models';
|
|||||||
export const flotDefaultSettings = (chartType: ChartType): Partial<TbFlotSettings> => {
|
export const flotDefaultSettings = (chartType: ChartType): Partial<TbFlotSettings> => {
|
||||||
const settings: Partial<TbFlotSettings> = {
|
const settings: Partial<TbFlotSettings> = {
|
||||||
stack: false,
|
stack: false,
|
||||||
|
enableSelection: true,
|
||||||
fontColor: '#545454',
|
fontColor: '#545454',
|
||||||
fontSize: 10,
|
fontSize: 10,
|
||||||
showTooltip: true,
|
showTooltip: true,
|
||||||
@ -148,6 +149,7 @@ export class FlotWidgetSettingsComponent extends PageComponent implements OnInit
|
|||||||
// Common settings
|
// Common settings
|
||||||
|
|
||||||
stack: [false, []],
|
stack: [false, []],
|
||||||
|
enableSelection: [true, []],
|
||||||
fontSize: [10, [Validators.min(0)]],
|
fontSize: [10, [Validators.min(0)]],
|
||||||
fontColor: ['#545454', []],
|
fontColor: ['#545454', []],
|
||||||
|
|
||||||
|
|||||||
@ -4264,6 +4264,8 @@
|
|||||||
"chart": {
|
"chart": {
|
||||||
"common-settings": "Common settings",
|
"common-settings": "Common settings",
|
||||||
"enable-stacking-mode": "Enable stacking mode",
|
"enable-stacking-mode": "Enable stacking mode",
|
||||||
|
"selection": "Time range selection",
|
||||||
|
"enable-selection-mode": "Enable selection mode",
|
||||||
"line-shadow-size": "Line shadow size",
|
"line-shadow-size": "Line shadow size",
|
||||||
"display-smooth-lines": "Display smooth (curved) lines",
|
"display-smooth-lines": "Display smooth (curved) lines",
|
||||||
"default-bar-width": "Default bar width for non-aggregated data (milliseconds)",
|
"default-bar-width": "Default bar width for non-aggregated data (milliseconds)",
|
||||||
|
|||||||
1
ui-ngx/src/typings/jquery.flot.typings.d.ts
vendored
1
ui-ngx/src/typings/jquery.flot.typings.d.ts
vendored
@ -119,6 +119,7 @@ interface JQueryPlotSelection {
|
|||||||
color?: string;
|
color?: string;
|
||||||
shape?: JQueryPlotSelectionShape;
|
shape?: JQueryPlotSelectionShape;
|
||||||
minSize?: number;
|
minSize?: number;
|
||||||
|
touch?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface JQueryPlotSelectionRanges {
|
interface JQueryPlotSelectionRanges {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user