diff --git a/projects/swimlane/ngx-charts/src/lib/bar-chart/bar-horizontal-2d.component.ts b/projects/swimlane/ngx-charts/src/lib/bar-chart/bar-horizontal-2d.component.ts index 1a2a604d8..e00aa9ceb 100644 --- a/projects/swimlane/ngx-charts/src/lib/bar-chart/bar-horizontal-2d.component.ts +++ b/projects/swimlane/ngx-charts/src/lib/bar-chart/bar-horizontal-2d.component.ts @@ -88,6 +88,7 @@ import { BarOrientation } from '../common/types/bar-orientation.enum'; ngx-charts-series-horizontal [xScale]="valueScale" [activeEntries]="activeEntries" + [ngStyle]="getStyle(chartTransparency)" [yScale]="innerScale" [colors]="colors" [series]="group.series" @@ -117,6 +118,7 @@ import { BarOrientation } from '../common/types/bar-orientation.enum'; ngx-charts-series-horizontal [xScale]="valueScale" [activeEntries]="activeEntries" + [ngStyle]="getStyle(chartTransparency)" [yScale]="innerScale" [colors]="colors" [series]="group.series" @@ -156,6 +158,7 @@ import { BarOrientation } from '../common/types/bar-orientation.enum'; ] }) export class BarHorizontal2DComponent extends BaseChartComponent { + @Input() chartTransparency: number = 0; @Input() legend: boolean = false; @Input() legendTitle: string = 'Legend'; @Input() legendPosition: LegendPosition = LegendPosition.Right; @@ -293,6 +296,12 @@ export class BarHorizontal2DComponent extends BaseChartComponent { return domain; } + getStyle(transparency: number): object { + return { + opacity: 1 - transparency / 100 + }; + } + getInnerDomain(): string[] { const domain = []; diff --git a/projects/swimlane/ngx-charts/src/lib/bar-chart/bar-horizontal-normalized.component.ts b/projects/swimlane/ngx-charts/src/lib/bar-chart/bar-horizontal-normalized.component.ts index ee86e60d0..3f8927bbb 100644 --- a/projects/swimlane/ngx-charts/src/lib/bar-chart/bar-horizontal-normalized.component.ts +++ b/projects/swimlane/ngx-charts/src/lib/bar-chart/bar-horizontal-normalized.component.ts @@ -80,6 +80,7 @@ import { isPlatformServer } from '@angular/common'; [xScale]="xScale" [yScale]="yScale" [activeEntries]="activeEntries" + [ngStyle]="getStyle(chartTransparency)" [colors]="colors" [series]="group.series" [dims]="dims" @@ -137,6 +138,7 @@ import { isPlatformServer } from '@angular/common'; ] }) export class BarHorizontalNormalizedComponent extends BaseChartComponent { + @Input() chartTransparency: number = 0; @Input() legend: boolean = false; @Input() legendTitle: string = 'Legend'; @Input() legendPosition: LegendPosition = LegendPosition.Right; @@ -249,6 +251,12 @@ export class BarHorizontalNormalizedComponent extends BaseChartComponent { return domain; } + getStyle(transparency: number): object { + return { + opacity: 1 - transparency / 100 + }; + } + getYScale(): any { const spacing = this.groupDomain.length / (this.dims.height / this.barPadding + 1); diff --git a/projects/swimlane/ngx-charts/src/lib/bar-chart/bar-horizontal-stacked.component.ts b/projects/swimlane/ngx-charts/src/lib/bar-chart/bar-horizontal-stacked.component.ts index ab1350940..d9d21bd45 100644 --- a/projects/swimlane/ngx-charts/src/lib/bar-chart/bar-horizontal-stacked.component.ts +++ b/projects/swimlane/ngx-charts/src/lib/bar-chart/bar-horizontal-stacked.component.ts @@ -80,6 +80,7 @@ import { ViewDimensions } from '../common/types/view-dimension.interface'; [xScale]="xScale" [yScale]="yScale" [colors]="colors" + [ngStyle]="getStyle(chartTransparency)" [series]="group.series" [activeEntries]="activeEntries" [dims]="dims" @@ -146,6 +147,7 @@ import { ViewDimensions } from '../common/types/view-dimension.interface'; ] }) export class BarHorizontalStackedComponent extends BaseChartComponent { + @Input() chartTransparency = 0; @Input() legend: boolean = false; @Input() legendTitle: string = 'Legend'; @Input() legendPosition: LegendPosition = LegendPosition.Right; @@ -270,6 +272,12 @@ export class BarHorizontalStackedComponent extends BaseChartComponent { return domain; } + getStyle(transparency: number): object { + return { + opacity: 1 - transparency / 100 + }; + } + getValueDomain(): [number, number] { const domain = []; let smallest = 0; diff --git a/projects/swimlane/ngx-charts/src/lib/bar-chart/bar-horizontal.component.ts b/projects/swimlane/ngx-charts/src/lib/bar-chart/bar-horizontal.component.ts index 9b398f410..6eaed913a 100644 --- a/projects/swimlane/ngx-charts/src/lib/bar-chart/bar-horizontal.component.ts +++ b/projects/swimlane/ngx-charts/src/lib/bar-chart/bar-horizontal.component.ts @@ -67,6 +67,7 @@ import { ViewDimensions } from '../common/types/view-dimension.interface'; [xScale]="xScale" [yScale]="yScale" [colors]="colors" + [ngStyle]="getStyle(chartTransparency)" [series]="results" [dims]="dims" [gradient]="gradient" @@ -91,6 +92,7 @@ import { ViewDimensions } from '../common/types/view-dimension.interface'; encapsulation: ViewEncapsulation.None }) export class BarHorizontalComponent extends BaseChartComponent { + @Input() chartTransparency: number = 0; @Input() legend = false; @Input() legendTitle: string = 'Legend'; @Input() legendPosition: LegendPosition = LegendPosition.Right; @@ -219,6 +221,12 @@ export class BarHorizontalComponent extends BaseChartComponent { this.colors = new ColorHelper(this.scheme, this.schemeType, domain, this.customColors); } + getStyle(transparency: number): object { + return { + opacity: 1 - transparency / 100 + }; + } + getLegendOptions(): LegendOptions { const opts = { scaleType: this.schemeType as any, diff --git a/projects/swimlane/ngx-charts/src/lib/bar-chart/bar-vertical-2d.component.ts b/projects/swimlane/ngx-charts/src/lib/bar-chart/bar-vertical-2d.component.ts index 56fddd87c..14477b2ee 100644 --- a/projects/swimlane/ngx-charts/src/lib/bar-chart/bar-vertical-2d.component.ts +++ b/projects/swimlane/ngx-charts/src/lib/bar-chart/bar-vertical-2d.component.ts @@ -83,6 +83,7 @@ import { isPlatformServer } from '@angular/common'; [@animationState]="'active'" [attr.transform]="groupTransform(group)" [activeEntries]="activeEntries" + [ngStyle]="getStyle(chartTransparency)" [xScale]="innerScale" [yScale]="valueScale" [colors]="colors" @@ -148,6 +149,7 @@ import { isPlatformServer } from '@angular/common'; ] }) export class BarVertical2DComponent extends BaseChartComponent { + @Input() chartTransparency: number = 0; @Input() legend: boolean = false; @Input() legendTitle: string = 'Legend'; @Input() legendPosition: LegendPosition = LegendPosition.Right; @@ -264,6 +266,12 @@ export class BarVertical2DComponent extends BaseChartComponent { } } + getStyle(transparency: number): object { + return { + opacity: 1 - transparency / 100 + }; + } + getGroupScale(): any { const spacing = this.groupDomain.length / (this.dims.height / this.groupPadding + 1); diff --git a/projects/swimlane/ngx-charts/src/lib/bar-chart/bar-vertical-normalized.component.ts b/projects/swimlane/ngx-charts/src/lib/bar-chart/bar-vertical-normalized.component.ts index d1e9e1b2f..e362c3193 100644 --- a/projects/swimlane/ngx-charts/src/lib/bar-chart/bar-vertical-normalized.component.ts +++ b/projects/swimlane/ngx-charts/src/lib/bar-chart/bar-vertical-normalized.component.ts @@ -78,6 +78,7 @@ import { ViewDimensions } from '../common/types/view-dimension.interface'; [xScale]="xScale" [yScale]="yScale" [activeEntries]="activeEntries" + [ngStyle]="getStyle(chartTransparency)" [colors]="colors" [series]="group.series" [dims]="dims" @@ -135,6 +136,7 @@ import { ViewDimensions } from '../common/types/view-dimension.interface'; ] }) export class BarVerticalNormalizedComponent extends BaseChartComponent { + @Input() chartTransparency: number = 0; @Input() legend: boolean = false; @Input() legendTitle: string = 'Legend'; @Input() legendPosition: LegendPosition = LegendPosition.Right; @@ -233,6 +235,12 @@ export class BarVerticalNormalizedComponent extends BaseChartComponent { return domain; } + getStyle(transparency: number): object { + return { + opacity: 1 - transparency / 100 + }; + } + getInnerDomain(): string[] { const domain = []; for (const group of this.results) { diff --git a/projects/swimlane/ngx-charts/src/lib/bar-chart/bar-vertical-stacked.component.ts b/projects/swimlane/ngx-charts/src/lib/bar-chart/bar-vertical-stacked.component.ts index c13c0b50b..3e21a1e44 100644 --- a/projects/swimlane/ngx-charts/src/lib/bar-chart/bar-vertical-stacked.component.ts +++ b/projects/swimlane/ngx-charts/src/lib/bar-chart/bar-vertical-stacked.component.ts @@ -80,6 +80,7 @@ import { ViewDimensions } from '../common/types/view-dimension.interface'; [yScale]="yScale" [activeEntries]="activeEntries" [colors]="colors" + [ngStyle]="getStyle(chartTransparency)" [series]="group.series" [dims]="dims" [gradient]="gradient" @@ -145,6 +146,7 @@ import { ViewDimensions } from '../common/types/view-dimension.interface'; ] }) export class BarVerticalStackedComponent extends BaseChartComponent { + @Input() chartTransparency: number = 0; @Input() legend: boolean = false; @Input() legendTitle: string = 'Legend'; @Input() legendPosition: LegendPosition = LegendPosition.Right; @@ -269,6 +271,12 @@ export class BarVerticalStackedComponent extends BaseChartComponent { return domain; } + getStyle(transparency: number): object { + return { + opacity: 1 - transparency / 100 + }; + } + getValueDomain(): [number, number] { const domain = []; let smallest = 0; diff --git a/projects/swimlane/ngx-charts/src/lib/bar-chart/bar-vertical.component.ts b/projects/swimlane/ngx-charts/src/lib/bar-chart/bar-vertical.component.ts index cf2e9e353..63c105097 100644 --- a/projects/swimlane/ngx-charts/src/lib/bar-chart/bar-vertical.component.ts +++ b/projects/swimlane/ngx-charts/src/lib/bar-chart/bar-vertical.component.ts @@ -80,6 +80,7 @@ import { ViewDimensions } from '../common/types/view-dimension.interface'; [roundEdges]="roundEdges" [animations]="animations" [noBarWhenZero]="noBarWhenZero" + [ngStyle]="getStyle(chartTransparency)" (activate)="onActivate($event)" (deactivate)="onDeactivate($event)" (select)="onClick($event)" @@ -93,6 +94,7 @@ import { ViewDimensions } from '../common/types/view-dimension.interface'; encapsulation: ViewEncapsulation.None }) export class BarVerticalComponent extends BaseChartComponent { + @Input() chartTransparency : number = 0; @Input() legend = false; @Input() legendTitle: string = 'Legend'; @Input() legendPosition: LegendPosition = LegendPosition.Right; @@ -212,6 +214,12 @@ export class BarVerticalComponent extends BaseChartComponent { return [min, max]; } + getStyle(transparency: number): object { + return { + opacity: 1 - transparency / 100 + }; + } + onClick(data: DataItem | string) { this.select.emit(data); } diff --git a/projects/swimlane/ngx-charts/src/lib/line-chart/line-chart.component.ts b/projects/swimlane/ngx-charts/src/lib/line-chart/line-chart.component.ts index 3d714c233..8737c3e7b 100644 --- a/projects/swimlane/ngx-charts/src/lib/line-chart/line-chart.component.ts +++ b/projects/swimlane/ngx-charts/src/lib/line-chart/line-chart.component.ts @@ -89,6 +89,7 @@ import { isPlatformServer } from '@angular/common'; [xScale]="xScale" [yScale]="yScale" [colors]="colors" + [ngStyle]="getStyle(lineTransparency)" [data]="series" [activeEntries]="activeEntries" [scaleType]="scaleType" @@ -207,6 +208,7 @@ export class LineChartComponent extends BaseChartComponent implements OnInit { @Input() yAxis: boolean; @Input() showXAxisLabel: boolean; @Input() showYAxisLabel: boolean; + @Input() lineTransparency: number; @Input() xAxisLabel: string; @Input() yAxisLabel: string; @Input() autoScale: boolean; @@ -333,6 +335,12 @@ export class LineChartComponent extends BaseChartComponent implements OnInit { } } + getStyle(transparency: number): object { + return { + opacity: 1 - transparency / 100 + }; + } + getXDomain(): any[] { let values = getUniqueXDomainValues(this.results); diff --git a/src/app/app.component.html b/src/app/app.component.html index a68efd1e8..e5f0287d6 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -13,6 +13,7 @@ [gradient]="gradient" [xAxis]="showXAxis" [yAxis]="showYAxis" + [chartTransparency]="chartTransparency" [legend]="showLegend" [legendTitle]="legendTitle" [legendPosition]="legendPosition" @@ -50,6 +51,7 @@ [gradient]="gradient" [xAxis]="showXAxis" [yAxis]="showYAxis" + [chartTransparency]="chartTransparency" [legend]="showLegend" [legendTitle]="legendTitle" [legendPosition]="legendPosition" @@ -87,6 +89,7 @@ [gradient]="gradient" [xAxis]="showXAxis" [yAxis]="showYAxis" + [chartTransparency]="chartTransparency" [legend]="showLegend" [legendTitle]="legendTitle" [legendPosition]="legendPosition" @@ -126,6 +129,7 @@ [tooltipDisabled]="tooltipDisabled" [xAxis]="showXAxis" [yAxis]="showYAxis" + [chartTransparency]="chartTransparency" [legend]="showLegend" [legendTitle]="legendTitle" [legendPosition]="legendPosition" @@ -164,6 +168,7 @@ [tooltipDisabled]="tooltipDisabled" [xAxis]="showXAxis" [yAxis]="showYAxis" + [chartTransparency]="chartTransparency" [legend]="showLegend" [legendTitle]="legendTitle" [legendPosition]="legendPosition" @@ -200,6 +205,7 @@ [tooltipDisabled]="tooltipDisabled" [xAxis]="showXAxis" [yAxis]="showYAxis" + [chartTransparency]="chartTransparency" [legend]="showLegend" [legendTitle]="legendTitle" [legendPosition]="legendPosition" @@ -236,6 +242,7 @@ [tooltipDisabled]="tooltipDisabled" [xAxis]="showXAxis" [yAxis]="showYAxis" + [chartTransparency]="chartTransparency" [legend]="showLegend" [legendTitle]="legendTitle" [legendPosition]="legendPosition" @@ -270,6 +277,7 @@ [tooltipDisabled]="tooltipDisabled" [xAxis]="showXAxis" [yAxis]="showYAxis" + [chartTransparency]="chartTransparency" [legend]="showLegend" [legendTitle]="legendTitle" [legendPosition]="legendPosition" @@ -353,6 +361,7 @@ [schemeType]="schemeType" [results]="dateDataWithOrWithoutRange" [animations]="animations" + [lineTransparency]="lineTransparency" [legend]="showLegend" [legendTitle]="legendTitle" [legendPosition]="legendPosition" @@ -582,6 +591,9 @@ [gradient]="gradient" [xAxis]="showXAxis" [yAxis]="showYAxis" + [lineTransparency]="lineTransparency" + [chartTransparency]="chartTransparency" + [flag]="flag" [legend]="showLegend" [legendTitle]="legendTitle" [legendPosition]="legendPosition" @@ -820,6 +832,7 @@ [schemeType]="schemeType" [results]="plotData" [animations]="animations" + [lineTransparency]="lineTransparency" [legend]="false" [legendTitle]="legendTitle" [legendPosition]="legendPosition" @@ -1334,6 +1347,21 @@