Showing
6 changed files
with
70 additions
and
13 deletions
@@ -352,6 +352,7 @@ export class WidgetSubscription implements IWidgetSubscription { | @@ -352,6 +352,7 @@ export class WidgetSubscription implements IWidgetSubscription { | ||
352 | initDataSubscriptionSubject.complete(); | 352 | initDataSubscriptionSubject.complete(); |
353 | }, | 353 | }, |
354 | (err) => { | 354 | (err) => { |
355 | + this.notifyDataLoaded(); | ||
355 | initDataSubscriptionSubject.error(err); | 356 | initDataSubscriptionSubject.error(err); |
356 | } | 357 | } |
357 | ); | 358 | ); |
@@ -368,7 +369,8 @@ export class WidgetSubscription implements IWidgetSubscription { | @@ -368,7 +369,8 @@ export class WidgetSubscription implements IWidgetSubscription { | ||
368 | const additionalDataKeys: DataKey[] = []; | 369 | const additionalDataKeys: DataKey[] = []; |
369 | let datasourceAdditionalKeysNumber = 0; | 370 | let datasourceAdditionalKeysNumber = 0; |
370 | datasource.dataKeys.forEach((dataKey) => { | 371 | datasource.dataKeys.forEach((dataKey) => { |
371 | - dataKey.hidden = false; | 372 | + dataKey.hidden = dataKey.settings.hideDataByDefault ? true : false; |
373 | + dataKey.inLegend = dataKey.settings.removeFromLegend ? false : true; | ||
372 | dataKey.pattern = dataKey.label; | 374 | dataKey.pattern = dataKey.label; |
373 | if (this.comparisonEnabled && dataKey.settings.comparisonSettings && dataKey.settings.comparisonSettings.showValuesForComparison) { | 375 | if (this.comparisonEnabled && dataKey.settings.comparisonSettings && dataKey.settings.comparisonSettings.showValuesForComparison) { |
374 | datasourceAdditionalKeysNumber++; | 376 | datasourceAdditionalKeysNumber++; |
@@ -26,7 +26,7 @@ | @@ -26,7 +26,7 @@ | ||
26 | </tr> | 26 | </tr> |
27 | </thead> | 27 | </thead> |
28 | <tbody> | 28 | <tbody> |
29 | - <tr class="tb-legend-keys" *ngFor="let legendKey of legendData.keys" [ngClass]="{ 'tb-row-direction': isRowDirection }"> | 29 | + <tr class="tb-legend-keys" *ngFor="let legendKey of legendKeys()" [ngClass]="{ 'tb-row-direction': isRowDirection }"> |
30 | <td><span class="tb-legend-line" [ngStyle]="{backgroundColor: legendKey.dataKey.color}"></span></td> | 30 | <td><span class="tb-legend-line" [ngStyle]="{backgroundColor: legendKey.dataKey.color}"></span></td> |
31 | <td class="tb-legend-label" | 31 | <td class="tb-legend-label" |
32 | (click)="toggleHideData(legendKey.dataIndex)" | 32 | (click)="toggleHideData(legendKey.dataIndex)" |
@@ -15,7 +15,7 @@ | @@ -15,7 +15,7 @@ | ||
15 | /// | 15 | /// |
16 | 16 | ||
17 | import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; | 17 | import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; |
18 | -import { LegendConfig, LegendData, LegendDirection, LegendPosition } from '@shared/models/widget.models'; | 18 | +import { LegendConfig, LegendData, LegendDirection, LegendKey, LegendPosition } from '@shared/models/widget.models'; |
19 | 19 | ||
20 | @Component({ | 20 | @Component({ |
21 | selector: 'tb-legend', | 21 | selector: 'tb-legend', |
@@ -52,8 +52,15 @@ export class LegendComponent implements OnInit { | @@ -52,8 +52,15 @@ export class LegendComponent implements OnInit { | ||
52 | } | 52 | } |
53 | 53 | ||
54 | toggleHideData(index: number) { | 54 | toggleHideData(index: number) { |
55 | - this.legendData.keys[index].dataKey.hidden = !this.legendData.keys[index].dataKey.hidden; | ||
56 | - this.legendKeyHiddenChange.emit(index); | 55 | + if (!this.legendData.keys[index].dataKey.settings.disableDataHiding) { |
56 | + this.legendData.keys[index].dataKey.hidden = !this.legendData.keys[index].dataKey.hidden; | ||
57 | + this.legendKeyHiddenChange.emit(index); | ||
58 | + } | ||
59 | + } | ||
60 | + | ||
61 | + legendKeys(): LegendKey[] { | ||
62 | + return this.legendData.keys | ||
63 | + .filter(legendKey => this.legendData.keys[legendKey.dataIndex].dataKey.inLegend); | ||
57 | } | 64 | } |
58 | 65 | ||
59 | } | 66 | } |
@@ -160,6 +160,9 @@ export declare type TbFlotXAxisPosition = 'top' | 'bottom'; | @@ -160,6 +160,9 @@ export declare type TbFlotXAxisPosition = 'top' | 'bottom'; | ||
160 | 160 | ||
161 | export interface TbFlotKeySettings { | 161 | export interface TbFlotKeySettings { |
162 | excludeFromStacking: boolean; | 162 | excludeFromStacking: boolean; |
163 | + hideDataByDefault: boolean; | ||
164 | + disableDataHiding: boolean; | ||
165 | + removeFromLegend: boolean; | ||
163 | showLines: boolean; | 166 | showLines: boolean; |
164 | fillLines: boolean; | 167 | fillLines: boolean; |
165 | showPoints: boolean; | 168 | showPoints: boolean; |
@@ -612,6 +615,36 @@ export const flotPieSettingsSchema: JsonSettingsSchema = { | @@ -612,6 +615,36 @@ export const flotPieSettingsSchema: JsonSettingsSchema = { | ||
612 | ] | 615 | ] |
613 | }; | 616 | }; |
614 | 617 | ||
618 | +export const flotPieDatakeySettingsSchema: JsonSettingsSchema = { | ||
619 | + schema: { | ||
620 | + type: 'object', | ||
621 | + title: 'DataKeySettings', | ||
622 | + properties: { | ||
623 | + hideDataByDefault: { | ||
624 | + title: 'Data is hidden by default', | ||
625 | + type: 'boolean', | ||
626 | + default: false | ||
627 | + }, | ||
628 | + disableDataHiding: { | ||
629 | + title: 'Disable data hiding', | ||
630 | + type: 'boolean', | ||
631 | + default: false | ||
632 | + }, | ||
633 | + removeFromLegend: { | ||
634 | + title: 'Remove datakey from legend', | ||
635 | + type: 'boolean', | ||
636 | + default: false | ||
637 | + } | ||
638 | + }, | ||
639 | + required: [] | ||
640 | + }, | ||
641 | + form: [ | ||
642 | + 'hideDataByDefault', | ||
643 | + 'disableDataHiding', | ||
644 | + 'removeFromLegend' | ||
645 | + ] | ||
646 | +}; | ||
647 | + | ||
615 | export function flotDatakeySettingsSchema(defaultShowLines: boolean, chartType: ChartType): JsonSettingsSchema { | 648 | export function flotDatakeySettingsSchema(defaultShowLines: boolean, chartType: ChartType): JsonSettingsSchema { |
616 | const schema: JsonSettingsSchema = { | 649 | const schema: JsonSettingsSchema = { |
617 | schema: { | 650 | schema: { |
@@ -623,6 +656,21 @@ export function flotDatakeySettingsSchema(defaultShowLines: boolean, chartType: | @@ -623,6 +656,21 @@ export function flotDatakeySettingsSchema(defaultShowLines: boolean, chartType: | ||
623 | type: 'boolean', | 656 | type: 'boolean', |
624 | default: false | 657 | default: false |
625 | }, | 658 | }, |
659 | + hideDataByDefault: { | ||
660 | + title: 'Data is hidden by default', | ||
661 | + type: 'boolean', | ||
662 | + default: false | ||
663 | + }, | ||
664 | + disableDataHiding: { | ||
665 | + title: 'Disable data hiding', | ||
666 | + type: 'boolean', | ||
667 | + default: false | ||
668 | + }, | ||
669 | + removeFromLegend: { | ||
670 | + title: 'Remove datakey from legend', | ||
671 | + type: 'boolean', | ||
672 | + default: false | ||
673 | + }, | ||
626 | showLines: { | 674 | showLines: { |
627 | title: 'Show lines', | 675 | title: 'Show lines', |
628 | type: 'boolean', | 676 | type: 'boolean', |
@@ -711,6 +759,9 @@ export function flotDatakeySettingsSchema(defaultShowLines: boolean, chartType: | @@ -711,6 +759,9 @@ export function flotDatakeySettingsSchema(defaultShowLines: boolean, chartType: | ||
711 | required: ['showLines', 'fillLines', 'showPoints'] | 759 | required: ['showLines', 'fillLines', 'showPoints'] |
712 | }, | 760 | }, |
713 | form: [ | 761 | form: [ |
762 | + 'hideDataByDefault', | ||
763 | + 'disableDataHiding', | ||
764 | + 'removeFromLegend', | ||
714 | 'excludeFromStacking', | 765 | 'excludeFromStacking', |
715 | 'showLines', | 766 | 'showLines', |
716 | 'fillLines', | 767 | 'fillLines', |
@@ -21,7 +21,7 @@ import { IWidgetSubscription } from '@core/api/widget-api.models'; | @@ -21,7 +21,7 @@ import { IWidgetSubscription } from '@core/api/widget-api.models'; | ||
21 | import { DatasourceData, JsonSettingsSchema } from '@app/shared/models/widget.models'; | 21 | import { DatasourceData, JsonSettingsSchema } from '@app/shared/models/widget.models'; |
22 | import { | 22 | import { |
23 | ChartType, | 23 | ChartType, |
24 | - flotDatakeySettingsSchema, | 24 | + flotDatakeySettingsSchema, flotPieDatakeySettingsSchema, |
25 | flotPieSettingsSchema, | 25 | flotPieSettingsSchema, |
26 | flotSettingsSchema, | 26 | flotSettingsSchema, |
27 | TbFlotAxisOptions, | 27 | TbFlotAxisOptions, |
@@ -47,6 +47,7 @@ const tinycolor = tinycolor_; | @@ -47,6 +47,7 @@ const tinycolor = tinycolor_; | ||
47 | const moment = moment_; | 47 | const moment = moment_; |
48 | 48 | ||
49 | const flotPieSettingsSchemaValue = flotPieSettingsSchema; | 49 | const flotPieSettingsSchemaValue = flotPieSettingsSchema; |
50 | +const flotPieDatakeySettingsSchemaValue = flotPieDatakeySettingsSchema; | ||
50 | 51 | ||
51 | export class TbFlot { | 52 | export class TbFlot { |
52 | 53 | ||
@@ -103,7 +104,7 @@ export class TbFlot { | @@ -103,7 +104,7 @@ export class TbFlot { | ||
103 | } | 104 | } |
104 | 105 | ||
105 | static pieDatakeySettingsSchema(): JsonSettingsSchema { | 106 | static pieDatakeySettingsSchema(): JsonSettingsSchema { |
106 | - return {}; | 107 | + return flotPieDatakeySettingsSchemaValue; |
107 | } | 108 | } |
108 | 109 | ||
109 | static settingsSchema(chartType: ChartType): JsonSettingsSchema { | 110 | static settingsSchema(chartType: ChartType): JsonSettingsSchema { |
@@ -814,12 +815,7 @@ export class TbFlot { | @@ -814,12 +815,7 @@ export class TbFlot { | ||
814 | return seriesHover.index === seriesIndex; | 815 | return seriesHover.index === seriesIndex; |
815 | }); | 816 | }); |
816 | if (found && found.length) { | 817 | if (found && found.length) { |
817 | - let timestamp: number; | ||
818 | - if (!isNumber(hoverInfo[0].time) || (found[0].time < hoverInfo[0].time)) { | ||
819 | - timestamp = parseInt(hoverInfo[1].time, 10); | ||
820 | - } else { | ||
821 | - timestamp = parseInt(hoverInfo[0].time, 10); | ||
822 | - } | 818 | + const timestamp = parseInt(found[0].time, 10); |
823 | const date = moment(timestamp).format('YYYY-MM-DD HH:mm:ss'); | 819 | const date = moment(timestamp).format('YYYY-MM-DD HH:mm:ss'); |
824 | const dateDiv = $('<div>' + date + '</div>'); | 820 | const dateDiv = $('<div>' + date + '</div>'); |
825 | dateDiv.css({ | 821 | dateDiv.css({ |
@@ -231,6 +231,7 @@ export interface DataKey extends KeyInfo { | @@ -231,6 +231,7 @@ export interface DataKey extends KeyInfo { | ||
231 | settings?: any; | 231 | settings?: any; |
232 | usePostProcessing?: boolean; | 232 | usePostProcessing?: boolean; |
233 | hidden?: boolean; | 233 | hidden?: boolean; |
234 | + inLegend?: boolean; | ||
234 | _hash?: number; | 235 | _hash?: number; |
235 | } | 236 | } |
236 | 237 |