Skip to content

Commit

Permalink
label chart collapsable (#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeknovy authored Apr 16, 2021
1 parent 24651ea commit e1f690a
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 7 deletions.
7 changes: 7 additions & 0 deletions src/app/item-detail/label-chart/label-chart.component.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,10 @@
.compare-card {
margin-top: 20px;;
}

.jtl-ico-btn-light{
color: #4b7cf3;
}
.jtl-ico-btn-light:hover{
color: grey;
}
11 changes: 8 additions & 3 deletions src/app/item-detail/label-chart/label-chart.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ <h6 class="card-header bg-transparent">
Label Chart - {{labelChartMetric}}
<span *ngIf="!labelCompareChartOptions" class="float-right">

<button class="jtl-no-glow add-item jtl-btn-light btn btn-sm" (click)="toggleSeriesVisibility($event)">{{seriesVisibilityToggleText}}</button>
<button class="jtl-no-glow add-item jtl-btn-light btn btn-sm"
(click)="toggleSeriesVisibility($event)">{{seriesVisibilityToggleText}}</button>


<button class="jtl-no-glow btn btn-sm jtl-ico-btn-light" (click)="collapseChart($event)"><i class="fa"
[ngClass]="{'fa-compress-alt': chartShouldExpand, 'fa-expand-alt': !chartShouldExpand}"> </i></button>

<div display="dynamic" [placement]="['bottom-right', 'bottom-left']" class="btn-group" ngbDropdown role="group"
aria-label="">
Expand All @@ -28,9 +33,9 @@ <h6 class="card-header bg-transparent">
<div class="card-body">
<div class="chart">
<highcharts-chart [Highcharts]="Highcharts" [options]="labelChartOptions" [(update)]="updateLabelChartFlag"
style="width: 100%; height: 350px; display: block;"></highcharts-chart>
class="highchart-chart" [callbackFunction]="getInstance.bind(this)"
style="width: 100%; height: 100%; display: block;"></highcharts-chart>
</div>
</div>

</div>

15 changes: 12 additions & 3 deletions src/app/item-detail/label-chart/label-chart.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChangeDetectorRef, Component, Input, OnInit } from '@angular/core';
import { Component, Input, OnInit } from '@angular/core';
import * as Highcharts from 'highcharts';
import { commonGraphSettings, threadLineSettings } from 'src/app/graphs/item-detail';

Expand All @@ -11,7 +11,6 @@ export class LabelChartComponent implements OnInit {

@Input() labels: Map<string, object>;
Highcharts: typeof Highcharts = Highcharts;
HighchartsCompare: typeof Highcharts = Highcharts;
chartConstructor = 'chart';
labelChartMetric = 'Throughput';
labelCompareChartMetric;
Expand All @@ -20,6 +19,8 @@ export class LabelChartComponent implements OnInit {
chartKeys;
seriesVisibilityToggle = true;
seriesVisibilityToggleText = 'Hide all';
chartShouldExpand = false;
chart;

constructor() { }

Expand All @@ -40,12 +41,20 @@ export class LabelChartComponent implements OnInit {
this.updateLabelChartFlag = true;
}

toggleSeriesVisibility(event) {
toggleSeriesVisibility() {
this.labelChartOptions.series.map(_ => _.visible = !this.seriesVisibilityToggle);
this.seriesVisibilityToggleText = this.seriesVisibilityToggle ? 'Show all' : 'Hide all';
this.seriesVisibilityToggle = !this.seriesVisibilityToggle;
this.updateLabelChartFlag = true;
}

collapseChart() {
this.chartShouldExpand = !this.chartShouldExpand;
this.chart.setSize(undefined, this.chartShouldExpand ? 650 : 350);
}


getInstance(chart): void {
this.chart = chart;
}
}
2 changes: 1 addition & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<base href="/">

<meta name="viewport" content="width=device-width, initial-scale=1">
<script defer src="https://use.fontawesome.com/releases/v5.0.8/js/all.js"></script>
<link href="//use.fontawesome.com/releases/v5.12.0/css/all.css" rel="stylesheet">
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
Expand Down

0 comments on commit e1f690a

Please sign in to comment.