Skip to content
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 @@ -23,6 +23,7 @@ import { SeriesType } from '../common/circle-series.component';
import { LegendOptions, LegendPosition } from '../common/types/legend.model';
import { ScaleType } from '../common/types/scale-type.enum';
import { ViewDimensions } from '../common/types/view-dimension.interface';
import { Orientation } from '../common/types/orientation.enum';

@Component({
selector: 'ngx-charts-area-chart-normalized',
Expand Down Expand Up @@ -60,6 +61,7 @@ import { ViewDimensions } from '../common/types/view-dimension.interface';
[maxTickLength]="maxXAxisTickLength"
[tickFormatting]="xAxisTickFormatting"
[ticks]="xAxisTicks"
[xOrient]="xOrient"
[wrapTicks]="wrapTicks"
(dimensionsChanged)="updateXAxisHeight($event)"
></svg:g>
Expand Down Expand Up @@ -171,6 +173,7 @@ export class AreaChartNormalizedComponent extends BaseChartComponent {
@Input() legendPosition: LegendPosition = LegendPosition.Right;
@Input() xAxis: boolean;
@Input() yAxis: boolean;
@Input() xOrient: Orientation = Orientation.Bottom;
@Input() showXAxisLabel: boolean = false;
@Input() showYAxisLabel: boolean = false;
@Input() xAxisLabel: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { SeriesType } from '../common/circle-series.component';
import { LegendOptions, LegendPosition } from '../common/types/legend.model';
import { ViewDimensions } from '../common/types/view-dimension.interface';
import { ScaleType } from '../common/types/scale-type.enum';
import { Orientation } from '../common/types/orientation.enum';

@Component({
selector: 'ngx-charts-area-chart-stacked',
Expand Down Expand Up @@ -58,6 +59,7 @@ import { ScaleType } from '../common/types/scale-type.enum';
[maxTickLength]="maxXAxisTickLength"
[tickFormatting]="xAxisTickFormatting"
[ticks]="xAxisTicks"
[xOrient]="xOrient"
[wrapTicks]="wrapTicks"
(dimensionsChanged)="updateXAxisHeight($event)"
></svg:g>
Expand Down Expand Up @@ -168,6 +170,7 @@ export class AreaChartStackedComponent extends BaseChartComponent {
@Input() legendPosition: LegendPosition = LegendPosition.Right;
@Input() xAxis: boolean = false;
@Input() yAxis: boolean = false;
@Input() xOrient: Orientation = Orientation.Bottom;
@Input() showXAxisLabel: boolean;
@Input() showYAxisLabel: boolean;
@Input() xAxisLabel: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { Series } from '../models/chart-data.model';
import { LegendOptions, LegendPosition } from '../common/types/legend.model';
import { ViewDimensions } from '../common/types/view-dimension.interface';
import { ScaleType } from '../common/types/scale-type.enum';
import { Orientation } from '../common/types/orientation.enum';

@Component({
selector: 'ngx-charts-area-chart',
Expand Down Expand Up @@ -60,6 +61,7 @@ import { ScaleType } from '../common/types/scale-type.enum';
[maxTickLength]="maxXAxisTickLength"
[tickFormatting]="xAxisTickFormatting"
[ticks]="xAxisTicks"
[xOrient]="xOrient"
[wrapTicks]="wrapTicks"
(dimensionsChanged)="updateXAxisHeight($event)"
></svg:g>
Expand Down Expand Up @@ -169,6 +171,7 @@ export class AreaChartComponent extends BaseChartComponent {
@Input() legendPosition: LegendPosition = LegendPosition.Right;
@Input() xAxis: boolean = false;
@Input() yAxis: boolean = false;
@Input() xOrient: Orientation = Orientation.Bottom;
@Input() baseValue: any = 'auto';
@Input() autoScale: boolean = false;
@Input() showXAxisLabel: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { ScaleType } from '../common/types/scale-type.enum';
import { LegendOptions, LegendPosition } from '../common/types/legend.model';
import { ViewDimensions } from '../common/types/view-dimension.interface';
import { BarOrientation } from '../common/types/bar-orientation.enum';
import { Orientation } from '../common/types/orientation.enum';

@Component({
selector: 'ngx-charts-bar-horizontal-2d',
Expand Down Expand Up @@ -59,6 +60,7 @@ import { BarOrientation } from '../common/types/bar-orientation.enum';
[maxTickLength]="maxXAxisTickLength"
[tickFormatting]="xAxisTickFormatting"
[ticks]="xAxisTicks"
[xOrient]="xOrient"
[wrapTicks]="wrapTicks"
(dimensionsChanged)="updateXAxisHeight($event)"
></svg:g>
Expand Down Expand Up @@ -161,6 +163,7 @@ export class BarHorizontal2DComponent extends BaseChartComponent {
@Input() legendPosition: LegendPosition = LegendPosition.Right;
@Input() xAxis;
@Input() yAxis;
@Input() xOrient: Orientation = Orientation.Bottom;
@Input() showXAxisLabel: boolean;
@Input() showYAxisLabel: boolean;
@Input() xAxisLabel: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { ScaleType } from '../common/types/scale-type.enum';
import { LegendOptions, LegendPosition } from '../common/types/legend.model';
import { ViewDimensions } from '../common/types/view-dimension.interface';
import { isPlatformServer } from '@angular/common';
import { Orientation } from '../common/types/orientation.enum';

@Component({
selector: 'ngx-charts-bar-horizontal-normalized',
Expand Down Expand Up @@ -51,6 +52,7 @@ import { isPlatformServer } from '@angular/common';
[maxTickLength]="maxXAxisTickLength"
[tickFormatting]="xAxisTickFormatting"
[ticks]="xAxisTicks"
[xOrient]="xOrient"
[wrapTicks]="wrapTicks"
(dimensionsChanged)="updateXAxisHeight($event)"
></svg:g>
Expand Down Expand Up @@ -142,6 +144,7 @@ export class BarHorizontalNormalizedComponent extends BaseChartComponent {
@Input() legendPosition: LegendPosition = LegendPosition.Right;
@Input() xAxis;
@Input() yAxis;
@Input() xOrient: Orientation = Orientation.Bottom;
@Input() showXAxisLabel: boolean;
@Input() showYAxisLabel: boolean;
@Input() xAxisLabel: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { BarChartType } from './types/bar-chart-type.enum';
import { LegendOptions, LegendPosition } from '../common/types/legend.model';
import { ScaleType } from '../common/types/scale-type.enum';
import { ViewDimensions } from '../common/types/view-dimension.interface';
import { Orientation } from '../common/types/orientation.enum';

@Component({
selector: 'ngx-charts-bar-horizontal-stacked',
Expand Down Expand Up @@ -50,6 +51,7 @@ import { ViewDimensions } from '../common/types/view-dimension.interface';
[maxTickLength]="maxXAxisTickLength"
[tickFormatting]="xAxisTickFormatting"
[ticks]="xAxisTicks"
[xOrient]="xOrient"
[wrapTicks]="wrapTicks"
(dimensionsChanged)="updateXAxisHeight($event)"
></svg:g>
Expand Down Expand Up @@ -151,6 +153,7 @@ export class BarHorizontalStackedComponent extends BaseChartComponent {
@Input() legendPosition: LegendPosition = LegendPosition.Right;
@Input() xAxis;
@Input() yAxis;
@Input() xOrient: Orientation = Orientation.Bottom;
@Input() showXAxisLabel: boolean;
@Input() showYAxisLabel: boolean;
@Input() xAxisLabel: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { BaseChartComponent } from '../common/base-chart.component';
import { LegendOptions, LegendPosition } from '../common/types/legend.model';
import { ScaleType } from '../common/types/scale-type.enum';
import { ViewDimensions } from '../common/types/view-dimension.interface';
import { Orientation } from '../common/types/orientation.enum';

@Component({
selector: 'ngx-charts-bar-horizontal',
Expand Down Expand Up @@ -44,6 +45,7 @@ import { ViewDimensions } from '../common/types/view-dimension.interface';
[maxTickLength]="maxXAxisTickLength"
[tickFormatting]="xAxisTickFormatting"
[ticks]="xAxisTicks"
[xOrient]="xOrient"
[wrapTicks]="wrapTicks"
(dimensionsChanged)="updateXAxisHeight($event)"
></svg:g>
Expand Down Expand Up @@ -96,6 +98,7 @@ export class BarHorizontalComponent extends BaseChartComponent {
@Input() legendPosition: LegendPosition = LegendPosition.Right;
@Input() xAxis;
@Input() yAxis;
@Input() xOrient: Orientation = Orientation.Bottom;
@Input() showXAxisLabel: boolean;
@Input() showYAxisLabel: boolean;
@Input() xAxisLabel: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { ScaleType } from '../common/types/scale-type.enum';
import { ViewDimensions } from '../common/types/view-dimension.interface';
import { BarOrientation } from '../common/types/bar-orientation.enum';
import { isPlatformServer } from '@angular/common';
import { Orientation } from '../common/types/orientation.enum';

@Component({
selector: 'ngx-charts-bar-vertical-2d',
Expand Down Expand Up @@ -57,6 +58,7 @@ import { isPlatformServer } from '@angular/common';
[maxTickLength]="maxXAxisTickLength"
[tickFormatting]="xAxisTickFormatting"
[ticks]="xAxisTicks"
[xOrient]="xOrient"
[xAxisOffset]="dataLabelMaxHeight.negative"
[wrapTicks]="wrapTicks"
(dimensionsChanged)="updateXAxisHeight($event)"
Expand Down Expand Up @@ -153,6 +155,7 @@ export class BarVertical2DComponent extends BaseChartComponent {
@Input() legendPosition: LegendPosition = LegendPosition.Right;
@Input() xAxis;
@Input() yAxis;
@Input() xOrient: Orientation = Orientation.Bottom;
@Input() showXAxisLabel: boolean;
@Input() showYAxisLabel: boolean;
@Input() xAxisLabel: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { BarChartType } from './types/bar-chart-type.enum';
import { LegendOptions, LegendPosition } from '../common/types/legend.model';
import { ScaleType } from '../common/types/scale-type.enum';
import { ViewDimensions } from '../common/types/view-dimension.interface';
import { Orientation } from '../common/types/orientation.enum';

@Component({
selector: 'ngx-charts-bar-vertical-normalized',
Expand Down Expand Up @@ -48,6 +49,7 @@ import { ViewDimensions } from '../common/types/view-dimension.interface';
[maxTickLength]="maxXAxisTickLength"
[tickFormatting]="xAxisTickFormatting"
[ticks]="xAxisTicks"
[xOrient]="xOrient"
[wrapTicks]="wrapTicks"
(dimensionsChanged)="updateXAxisHeight($event)"
></svg:g>
Expand Down Expand Up @@ -140,6 +142,7 @@ export class BarVerticalNormalizedComponent extends BaseChartComponent {
@Input() legendPosition: LegendPosition = LegendPosition.Right;
@Input() xAxis;
@Input() yAxis;
@Input() xOrient: Orientation = Orientation.Bottom;
@Input() showXAxisLabel: boolean;
@Input() showYAxisLabel: boolean;
@Input() xAxisLabel: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { BarChartType } from './types/bar-chart-type.enum';
import { LegendOptions, LegendPosition } from '../common/types/legend.model';
import { ScaleType } from '../common/types/scale-type.enum';
import { ViewDimensions } from '../common/types/view-dimension.interface';
import { Orientation } from '../common/types/orientation.enum';

@Component({
selector: 'ngx-charts-bar-vertical-stacked',
Expand Down Expand Up @@ -48,6 +49,7 @@ import { ViewDimensions } from '../common/types/view-dimension.interface';
[maxTickLength]="maxXAxisTickLength"
[tickFormatting]="xAxisTickFormatting"
[ticks]="xAxisTicks"
[xOrient]="xOrient"
[xAxisOffset]="dataLabelMaxHeight.negative"
[wrapTicks]="wrapTicks"
(dimensionsChanged)="updateXAxisHeight($event)"
Expand Down Expand Up @@ -150,6 +152,7 @@ export class BarVerticalStackedComponent extends BaseChartComponent {
@Input() legendPosition: LegendPosition = LegendPosition.Right;
@Input() xAxis;
@Input() yAxis;
@Input() xOrient: Orientation = Orientation.Bottom;
@Input() showXAxisLabel: boolean;
@Input() showYAxisLabel: boolean;
@Input() xAxisLabel: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { DataItem } from '../models/chart-data.model';
import { LegendOptions, LegendPosition } from '../common/types/legend.model';
import { ScaleType } from '../common/types/scale-type.enum';
import { ViewDimensions } from '../common/types/view-dimension.interface';
import { Orientation } from '../common/types/orientation.enum';

@Component({
selector: 'ngx-charts-bar-vertical',
Expand Down Expand Up @@ -45,6 +46,7 @@ import { ViewDimensions } from '../common/types/view-dimension.interface';
[maxTickLength]="maxXAxisTickLength"
[tickFormatting]="xAxisTickFormatting"
[ticks]="xAxisTicks"
[xOrient]="xOrient"
[xAxisOffset]="dataLabelMaxHeight.negative"
[wrapTicks]="wrapTicks"
(dimensionsChanged)="updateXAxisHeight($event)"
Expand Down Expand Up @@ -98,6 +100,7 @@ export class BarVerticalComponent extends BaseChartComponent {
@Input() legendPosition: LegendPosition = LegendPosition.Right;
@Input() xAxis;
@Input() yAxis;
@Input() xOrient: Orientation = Orientation.Bottom;
@Input() showXAxisLabel: boolean;
@Input() showYAxisLabel: boolean;
@Input() xAxisLabel: string;
Expand Down Expand Up @@ -146,6 +149,7 @@ export class BarVerticalComponent extends BaseChartComponent {

update(): void {
super.update();
console.log("xOrient", this.xOrient);

if (!this.showDataLabel) {
this.dataLabelMaxHeight = { negative: 0, positive: 0 };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { calculateViewDimensions } from '../common/view-dimensions.helper';
import { ViewDimensions } from '../common/types/view-dimension.interface';
import { LegendPosition, LegendOptions } from '../common/types/legend.model';
import { ScaleType } from '../common/types/scale-type.enum';
import { Orientation } from '../common/types/orientation.enum';

@Component({
selector: 'ngx-charts-box-chart',
Expand All @@ -38,6 +39,7 @@ import { ScaleType } from '../common/types/scale-type.enum';
[xScale]="xScale"
[showLabel]="showXAxisLabel"
[labelText]="xAxisLabel"
[xOrient]="xOrient"
[wrapTicks]="wrapTicks"
(dimensionsChanged)="updateXAxisHeight($event)"
/>
Expand Down Expand Up @@ -90,6 +92,7 @@ export class BoxChartComponent extends BaseChartComponent {
@Input() showGridLines: boolean = true;
@Input() xAxis: boolean = true;
@Input() yAxis: boolean = true;
@Input() xOrient: Orientation = Orientation.Bottom;
@Input() showXAxisLabel: boolean = true;
@Input() showYAxisLabel: boolean = true;
@Input() roundDomains: boolean = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { LegendOptions, LegendPosition } from '../common/types/legend.model';
import { ScaleType } from '../common/types/scale-type.enum';
import { ViewDimensions } from '../common/types/view-dimension.interface';
import { isPlatformServer } from '@angular/common';
import { Orientation } from '../common/types/orientation.enum';

@Component({
selector: 'ngx-charts-bubble-chart',
Expand Down Expand Up @@ -60,6 +61,7 @@ import { isPlatformServer } from '@angular/common';
[maxTickLength]="maxXAxisTickLength"
[tickFormatting]="xAxisTickFormatting"
[ticks]="xAxisTicks"
[xOrient]="xOrient"
[wrapTicks]="wrapTicks"
(dimensionsChanged)="updateXAxisHeight($event)"
/>
Expand Down Expand Up @@ -160,6 +162,7 @@ export class BubbleChartComponent extends BaseChartComponent {
@Input() legendPosition: LegendPosition = LegendPosition.Right;
@Input() xAxis: boolean = true;
@Input() yAxis: boolean = true;
@Input() xOrient: Orientation = Orientation.Bottom;
@Input() showXAxisLabel: boolean;
@Input() showYAxisLabel: boolean;
@Input() xAxisLabel: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class AxisLabelComponent implements OnChanges {

switch (this.orient) {
case Orientation.Top:
this.y = this.offset;
this.y = -this.offset;
this.x = this.width / 2;
break;
case Orientation.Bottom:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,18 @@ import { TextAnchor } from '../types/text-anchor.enum';

<svg:g *ngFor="let tick of ticks" [attr.transform]="tickTransform(tick)">
<svg:g *ngIf="showGridLines" [attr.transform]="gridLineTransform()">
<svg:line class="gridline-path gridline-path-vertical" [attr.y1]="-gridLineHeight" y2="0" />
<svg:line
*ngIf="orient === Orientation.Top"
class="gridline-path gridline-path-vertical"
[attr.y1]="gridLineHeight"
y2="0"
/>
<svg:line
*ngIf="orient === Orientation.Bottom"
class="gridline-path gridline-path-vertical"
[attr.y1]="-gridLineHeight"
y2="0"
/>
</svg:g>
</svg:g>
`,
Expand Down Expand Up @@ -90,6 +101,8 @@ export class XAxisTicksComponent implements OnChanges, AfterViewInit {
approxHeight: number = 10;
maxPossibleLengthForTickIfWrapped = 16;

readonly Orientation = Orientation;

@ViewChild('ticksel') ticksElement: ElementRef;

get isWrapTicksSupported() {
Expand Down Expand Up @@ -149,10 +162,20 @@ export class XAxisTicksComponent implements OnChanges, AfterViewInit {

this.textTransform = '';
if (angle && angle !== 0) {
this.textTransform = `rotate(${angle})`;
this.textAnchor = TextAnchor.End;
this.verticalSpacing = 10;
if (this.orient === Orientation.Bottom) {
this.textAnchor = TextAnchor.End;
this.textTransform = `translate(0, ${this.verticalSpacing}) rotate(${angle})`;
} else {
this.textAnchor = TextAnchor.Start;
this.textTransform = `translate(0, ${-this.verticalSpacing}) rotate(${angle})`;
}
} else {
if (this.orient === Orientation.Bottom) {
this.textTransform = `translate(0, ${this.verticalSpacing})`;
} else {
this.textTransform = `translate(0, ${-this.verticalSpacing})`;
}
this.textAnchor = TextAnchor.Middle;
}

Expand Down Expand Up @@ -232,11 +255,11 @@ export class XAxisTicksComponent implements OnChanges, AfterViewInit {
}

tickTransform(tick: number): string {
return 'translate(' + this.adjustedScale(tick) + ',' + this.verticalSpacing + ')';
return 'translate(' + this.adjustedScale(tick) + ',0)';
}

gridLineTransform(): string {
return `translate(0,${-this.verticalSpacing - 5})`;
return `translate(0,${-5})`;
}

tickTrim(label: string): string {
Expand Down
Loading