Showing
6 changed files
with
70 additions
and
13 deletions
... | ... | @@ -352,6 +352,7 @@ export class WidgetSubscription implements IWidgetSubscription { |
352 | 352 | initDataSubscriptionSubject.complete(); |
353 | 353 | }, |
354 | 354 | (err) => { |
355 | + this.notifyDataLoaded(); | |
355 | 356 | initDataSubscriptionSubject.error(err); |
356 | 357 | } |
357 | 358 | ); |
... | ... | @@ -368,7 +369,8 @@ export class WidgetSubscription implements IWidgetSubscription { |
368 | 369 | const additionalDataKeys: DataKey[] = []; |
369 | 370 | let datasourceAdditionalKeysNumber = 0; |
370 | 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 | 374 | dataKey.pattern = dataKey.label; |
373 | 375 | if (this.comparisonEnabled && dataKey.settings.comparisonSettings && dataKey.settings.comparisonSettings.showValuesForComparison) { |
374 | 376 | datasourceAdditionalKeysNumber++; | ... | ... |
... | ... | @@ -26,7 +26,7 @@ |
26 | 26 | </tr> |
27 | 27 | </thead> |
28 | 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 | 30 | <td><span class="tb-legend-line" [ngStyle]="{backgroundColor: legendKey.dataKey.color}"></span></td> |
31 | 31 | <td class="tb-legend-label" |
32 | 32 | (click)="toggleHideData(legendKey.dataIndex)" | ... | ... |
... | ... | @@ -15,7 +15,7 @@ |
15 | 15 | /// |
16 | 16 | |
17 | 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 | 20 | @Component({ |
21 | 21 | selector: 'tb-legend', |
... | ... | @@ -52,8 +52,15 @@ export class LegendComponent implements OnInit { |
52 | 52 | } |
53 | 53 | |
54 | 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 | 160 | |
161 | 161 | export interface TbFlotKeySettings { |
162 | 162 | excludeFromStacking: boolean; |
163 | + hideDataByDefault: boolean; | |
164 | + disableDataHiding: boolean; | |
165 | + removeFromLegend: boolean; | |
163 | 166 | showLines: boolean; |
164 | 167 | fillLines: boolean; |
165 | 168 | showPoints: boolean; |
... | ... | @@ -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 | 648 | export function flotDatakeySettingsSchema(defaultShowLines: boolean, chartType: ChartType): JsonSettingsSchema { |
616 | 649 | const schema: JsonSettingsSchema = { |
617 | 650 | schema: { |
... | ... | @@ -623,6 +656,21 @@ export function flotDatakeySettingsSchema(defaultShowLines: boolean, chartType: |
623 | 656 | type: 'boolean', |
624 | 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 | 674 | showLines: { |
627 | 675 | title: 'Show lines', |
628 | 676 | type: 'boolean', |
... | ... | @@ -711,6 +759,9 @@ export function flotDatakeySettingsSchema(defaultShowLines: boolean, chartType: |
711 | 759 | required: ['showLines', 'fillLines', 'showPoints'] |
712 | 760 | }, |
713 | 761 | form: [ |
762 | + 'hideDataByDefault', | |
763 | + 'disableDataHiding', | |
764 | + 'removeFromLegend', | |
714 | 765 | 'excludeFromStacking', |
715 | 766 | 'showLines', |
716 | 767 | 'fillLines', | ... | ... |
... | ... | @@ -21,7 +21,7 @@ import { IWidgetSubscription } from '@core/api/widget-api.models'; |
21 | 21 | import { DatasourceData, JsonSettingsSchema } from '@app/shared/models/widget.models'; |
22 | 22 | import { |
23 | 23 | ChartType, |
24 | - flotDatakeySettingsSchema, | |
24 | + flotDatakeySettingsSchema, flotPieDatakeySettingsSchema, | |
25 | 25 | flotPieSettingsSchema, |
26 | 26 | flotSettingsSchema, |
27 | 27 | TbFlotAxisOptions, |
... | ... | @@ -47,6 +47,7 @@ const tinycolor = tinycolor_; |
47 | 47 | const moment = moment_; |
48 | 48 | |
49 | 49 | const flotPieSettingsSchemaValue = flotPieSettingsSchema; |
50 | +const flotPieDatakeySettingsSchemaValue = flotPieDatakeySettingsSchema; | |
50 | 51 | |
51 | 52 | export class TbFlot { |
52 | 53 | |
... | ... | @@ -103,7 +104,7 @@ export class TbFlot { |
103 | 104 | } |
104 | 105 | |
105 | 106 | static pieDatakeySettingsSchema(): JsonSettingsSchema { |
106 | - return {}; | |
107 | + return flotPieDatakeySettingsSchemaValue; | |
107 | 108 | } |
108 | 109 | |
109 | 110 | static settingsSchema(chartType: ChartType): JsonSettingsSchema { |
... | ... | @@ -814,12 +815,7 @@ export class TbFlot { |
814 | 815 | return seriesHover.index === seriesIndex; |
815 | 816 | }); |
816 | 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 | 819 | const date = moment(timestamp).format('YYYY-MM-DD HH:mm:ss'); |
824 | 820 | const dateDiv = $('<div>' + date + '</div>'); |
825 | 821 | dateDiv.css({ | ... | ... |