Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/line transparency #1957

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -293,6 +296,12 @@ export class BarHorizontal2DComponent extends BaseChartComponent {
return domain;
}

getStyle(transparency: number): object {
return {
opacity: 1 - transparency / 100
};
}

getInnerDomain(): string[] {
const domain = [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand All @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ import { isPlatformServer } from '@angular/common';
[xScale]="xScale"
[yScale]="yScale"
[colors]="colors"
[ngStyle]="getStyle(lineTransparency)"
[data]="series"
[activeEntries]="activeEntries"
[scaleType]="scaleType"
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down
28 changes: 28 additions & 0 deletions src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
[gradient]="gradient"
[xAxis]="showXAxis"
[yAxis]="showYAxis"
[chartTransparency]="chartTransparency"
[legend]="showLegend"
[legendTitle]="legendTitle"
[legendPosition]="legendPosition"
Expand Down Expand Up @@ -50,6 +51,7 @@
[gradient]="gradient"
[xAxis]="showXAxis"
[yAxis]="showYAxis"
[chartTransparency]="chartTransparency"
[legend]="showLegend"
[legendTitle]="legendTitle"
[legendPosition]="legendPosition"
Expand Down Expand Up @@ -87,6 +89,7 @@
[gradient]="gradient"
[xAxis]="showXAxis"
[yAxis]="showYAxis"
[chartTransparency]="chartTransparency"
[legend]="showLegend"
[legendTitle]="legendTitle"
[legendPosition]="legendPosition"
Expand Down Expand Up @@ -126,6 +129,7 @@
[tooltipDisabled]="tooltipDisabled"
[xAxis]="showXAxis"
[yAxis]="showYAxis"
[chartTransparency]="chartTransparency"
[legend]="showLegend"
[legendTitle]="legendTitle"
[legendPosition]="legendPosition"
Expand Down Expand Up @@ -164,6 +168,7 @@
[tooltipDisabled]="tooltipDisabled"
[xAxis]="showXAxis"
[yAxis]="showYAxis"
[chartTransparency]="chartTransparency"
[legend]="showLegend"
[legendTitle]="legendTitle"
[legendPosition]="legendPosition"
Expand Down Expand Up @@ -200,6 +205,7 @@
[tooltipDisabled]="tooltipDisabled"
[xAxis]="showXAxis"
[yAxis]="showYAxis"
[chartTransparency]="chartTransparency"
[legend]="showLegend"
[legendTitle]="legendTitle"
[legendPosition]="legendPosition"
Expand Down Expand Up @@ -236,6 +242,7 @@
[tooltipDisabled]="tooltipDisabled"
[xAxis]="showXAxis"
[yAxis]="showYAxis"
[chartTransparency]="chartTransparency"
[legend]="showLegend"
[legendTitle]="legendTitle"
[legendPosition]="legendPosition"
Expand Down Expand Up @@ -270,6 +277,7 @@
[tooltipDisabled]="tooltipDisabled"
[xAxis]="showXAxis"
[yAxis]="showYAxis"
[chartTransparency]="chartTransparency"
[legend]="showLegend"
[legendTitle]="legendTitle"
[legendPosition]="legendPosition"
Expand Down Expand Up @@ -353,6 +361,7 @@
[schemeType]="schemeType"
[results]="dateDataWithOrWithoutRange"
[animations]="animations"
[lineTransparency]="lineTransparency"
[legend]="showLegend"
[legendTitle]="legendTitle"
[legendPosition]="legendPosition"
Expand Down Expand Up @@ -582,6 +591,9 @@
[gradient]="gradient"
[xAxis]="showXAxis"
[yAxis]="showYAxis"
[lineTransparency]="lineTransparency"
[chartTransparency]="chartTransparency"
[flag]="flag"
[legend]="showLegend"
[legendTitle]="legendTitle"
[legendPosition]="legendPosition"
Expand Down Expand Up @@ -820,6 +832,7 @@
[schemeType]="schemeType"
[results]="plotData"
[animations]="animations"
[lineTransparency]="lineTransparency"
[legend]="false"
[legendTitle]="legendTitle"
[legendPosition]="legendPosition"
Expand Down Expand Up @@ -1334,6 +1347,21 @@ <h3 (click)="optsVisible = !optsVisible" style="cursor: pointer">
</label>
<br />
</div>
<div *ngIf="chart.options.includes('lineTransparency')" style="display: flex; align-items: center;">
<label>Line Transparency:</label>
<input type="range" min="0" max="100" [(ngModel)]="lineTransparency" />
{{ lineTransparency }}<br />
</div>
<div *ngIf="chart.options.includes('chartTransparency')" style="display: flex; align-items: center;">
<label>Chart Transparency:</label>
<input type="range" min="0" max="100" [(ngModel)]="chartTransparency" />
{{ chartTransparency }}<br />
</div>
<div *ngIf="chart.options.includes('flag')" style="display: flex; align-items: center;">
<label>Line</label>
<input type="range" min="0" max="1" step="1" style="width: 30px;margin-left: 15px;margin-right: 15px;" [(ngModel)]="flag" />
<label>Chart</label>
</div>
<div *ngIf="chart.options.includes('legendTitle')">
<label>Legend Title:</label><br />
<input type="text" [(ngModel)]="legendTitle" /><br />
Expand Down
5 changes: 5 additions & 0 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ export class AppComponent implements OnInit {
gradient = false;
showLegend = true;
legendTitle = 'Legend';
lineTransparency = 0;
chartTransparency = 0;
flag = 0;
legendPosition = LegendPosition.Right;
showXAxisLabel = true;
tooltipDisabled = false;
Expand Down Expand Up @@ -509,6 +512,8 @@ export class AppComponent implements OnInit {

this.width = 700;
this.height = 300;
this.lineTransparency = 0;
this.chartTransparency = 0;

Object.assign(this, this.chart.defaults);

Expand Down
Loading