Skip to content

Commit

Permalink
chore: add chart libs
Browse files Browse the repository at this point in the history
  • Loading branch information
cipchk committed Jan 19, 2024
1 parent 9c074e1 commit 3c5095d
Show file tree
Hide file tree
Showing 32 changed files with 197 additions and 251 deletions.
8 changes: 4 additions & 4 deletions packages/abc/ellipsis/ellipsis.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import {
ViewChild,
ViewEncapsulation,
booleanAttribute,
inject
inject,
numberAttribute
} from '@angular/core';
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
import { take } from 'rxjs';

import { toNumber } from '@delon/util/decorator';
import type { NzSafeAny } from 'ng-zorro-antd/core/types';
import { NzTooltipDirective } from 'ng-zorro-antd/tooltip';

Expand Down Expand Up @@ -49,8 +49,8 @@ export class EllipsisComponent implements AfterViewInit, OnChanges {
targetCount = 0;

@Input({ transform: booleanAttribute }) tooltip = false;
@Input({ transform: (v: NzSafeAny) => toNumber(v, null) }) length?: number;
@Input({ transform: (v: NzSafeAny) => toNumber(v, null) }) lines?: number;
@Input({ transform: (v: unknown) => (v == null ? null : numberAttribute(v)) }) length?: number;
@Input({ transform: (v: unknown) => (v == null ? null : numberAttribute(v)) }) lines?: number;
@Input({ transform: booleanAttribute }) fullWidthRecognition = false;
@Input() tail = '...';

Expand Down
14 changes: 5 additions & 9 deletions packages/abc/qr/qr.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import {
OnChanges,
OnDestroy,
Output,
ViewEncapsulation
ViewEncapsulation,
numberAttribute
} from '@angular/core';
import { Subscription, filter } from 'rxjs';

import { AlainConfigService, AlainQRConfig } from '@delon/util/config';
import { InputNumber, NumberInput } from '@delon/util/decorator';
import { LazyService } from '@delon/util/other';
import type { NzSafeAny } from 'ng-zorro-antd/core/types';

Expand All @@ -40,10 +40,6 @@ import { QROptions } from './qr.types';
encapsulation: ViewEncapsulation.None
})
export class QRComponent implements OnChanges, AfterViewInit, OnDestroy {
static ngAcceptInputType_padding: NumberInput;
static ngAcceptInputType_size: NumberInput;
static ngAcceptInputType_delay: NumberInput;

private lazy$?: Subscription;
private qr: NzSafeAny;
private cog: AlainQRConfig;
Expand All @@ -58,10 +54,10 @@ export class QRComponent implements OnChanges, AfterViewInit, OnDestroy {
@Input() foregroundAlpha?: number;
@Input() level?: string;
@Input() mime?: string;
@Input() @InputNumber(null) padding?: number;
@Input() @InputNumber() size?: number;
@Input({ transform: (v: unknown) => (v == null ? null : numberAttribute(v)) }) padding?: number;
@Input({ transform: numberAttribute }) size?: number;
@Input() value: string | (() => string) = '';
@Input() @InputNumber() delay?: number;
@Input({ transform: numberAttribute }) delay?: number;
@Output() readonly change = new EventEmitter<string>();

constructor(
Expand Down
8 changes: 4 additions & 4 deletions packages/abc/se/se-container.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { BehaviorSubject, Observable, filter } from 'rxjs';

import type { REP_TYPE } from '@delon/theme';
import { AlainConfigService } from '@delon/util/config';
import { toNumber } from '@delon/util/decorator';
import { NzStringTemplateOutletDirective } from 'ng-zorro-antd/core/outlet';
import type { NzSafeAny } from 'ng-zorro-antd/core/types';

Expand Down Expand Up @@ -84,9 +83,10 @@ export class SETitleComponent implements OnInit {
})
export class SEContainerComponent {
private errorNotify$ = new BehaviorSubject<SEErrorRefresh>(null as NzSafeAny);
@Input({ alias: 'se-container', transform: (v: NzSafeAny) => toNumber(v, null) }) colInCon?: REP_TYPE;
@Input({ transform: (v: NzSafeAny) => toNumber(v, null) }) col!: REP_TYPE;
@Input({ transform: (v: NzSafeAny) => toNumber(v, null) }) labelWidth!: number;
@Input({ alias: 'se-container', transform: (v: unknown) => (v == null ? null : numberAttribute(v)) })
colInCon?: REP_TYPE;
@Input({ transform: (v: unknown) => (v == null ? null : numberAttribute(v)) }) col!: REP_TYPE;
@Input({ transform: (v: unknown) => (v == null ? null : numberAttribute(v)) }) labelWidth!: number;
@Input({ transform: booleanAttribute }) noColon = false;
@Input() title?: string | TemplateRef<void> | null;

Expand Down
12 changes: 6 additions & 6 deletions packages/abc/se/se.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ import {
ViewChild,
ViewEncapsulation,
booleanAttribute,
inject
inject,
numberAttribute
} from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { FormControlName, NgModel, RequiredValidator, Validator, Validators } from '@angular/forms';
import { filter } from 'rxjs';

import { ResponsiveService } from '@delon/theme';
import { isEmpty } from '@delon/util/browser';
import { toBoolean, toNumber } from '@delon/util/decorator';
import { helpMotion } from 'ng-zorro-antd/core/animation';
import { NzFormStatusService } from 'ng-zorro-antd/core/form';
import { NzStringTemplateOutletDirective } from 'ng-zorro-antd/core/outlet';
Expand Down Expand Up @@ -91,12 +91,12 @@ export class SEComponent implements OnChanges, AfterContentInit, AfterViewInit {
}
@Input() extra?: string | TemplateRef<void> | null;
@Input() label?: string | TemplateRef<void> | null;
@Input({ transform: (v: NzSafeAny) => toNumber(v, null) }) col?: number | null;
@Input({ transform: (v: unknown) => (v == null ? null : numberAttribute(v)) }) col?: number | null;
@Input({ transform: booleanAttribute }) required = false;
@Input() controlClass?: string | null = '';
@Input({ transform: (v: NzSafeAny) => toBoolean(v, null) }) line?: boolean | null;
@Input({ transform: (v: NzSafeAny) => toNumber(v, null) }) labelWidth?: number | null;
@Input({ transform: (v: NzSafeAny) => toBoolean(v, null) }) noColon?: boolean | null;
@Input({ transform: (v: unknown) => (v == null ? null : booleanAttribute(v)) }) line?: boolean | null;
@Input({ transform: (v: unknown) => (v == null ? null : numberAttribute(v)) }) labelWidth?: number | null;
@Input({ transform: (v: unknown) => (v == null ? null : booleanAttribute(v)) }) noColon?: boolean | null;
@Input({ transform: booleanAttribute }) hideLabel = false;

@Input()
Expand Down
7 changes: 3 additions & 4 deletions packages/abc/sg/sg-container.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { ChangeDetectionStrategy, Component, Input, ViewEncapsulation, numberAtt

import type { REP_TYPE } from '@delon/theme';
import { AlainConfigService } from '@delon/util/config';
import { toNumber } from '@delon/util/decorator';
import { NzSafeAny } from 'ng-zorro-antd/core/types';

@Component({
selector: 'sg-container, [sg-container]',
Expand All @@ -22,8 +20,9 @@ import { NzSafeAny } from 'ng-zorro-antd/core/types';
})
export class SGContainerComponent {
@Input({ transform: numberAttribute }) gutter!: number;
@Input({ alias: 'sg-container', transform: (v: NzSafeAny) => toNumber(v, null) }) colInCon?: REP_TYPE;
@Input({ transform: (v: NzSafeAny) => toNumber(v, null) }) col!: REP_TYPE;
@Input({ alias: 'sg-container', transform: (v: unknown) => (v == null ? null : numberAttribute(v)) })
colInCon?: REP_TYPE;
@Input({ transform: (v: unknown) => (v == null ? null : numberAttribute(v)) }) col!: REP_TYPE;

get marginValue(): number {
return -(this.gutter / 2);
Expand Down
7 changes: 3 additions & 4 deletions packages/abc/sg/sg.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ import {
OnChanges,
Renderer2,
ViewEncapsulation,
inject
inject,
numberAttribute
} from '@angular/core';

import { ResponsiveService } from '@delon/theme';
import { toNumber } from '@delon/util/decorator';
import type { NzSafeAny } from 'ng-zorro-antd/core/types';

import { SGContainerComponent } from './sg-container.component';

Expand Down Expand Up @@ -40,7 +39,7 @@ export class SGComponent implements OnChanges, AfterViewInit {
private clsMap: string[] = [];
private inited = false;

@Input({ transform: (v: NzSafeAny) => toNumber(v, null) }) col: number | null = null;
@Input({ transform: (v: unknown) => (v == null ? null : numberAttribute(v)) }) col: number | null = null;

get paddingValue(): number {
return this.parent.gutter / 2;
Expand Down
12 changes: 5 additions & 7 deletions packages/chart/bar/bar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ import {
Input,
Output,
TemplateRef,
ViewEncapsulation
ViewEncapsulation,
booleanAttribute,
numberAttribute
} from '@angular/core';
import { fromEvent, debounceTime, filter, takeUntil } from 'rxjs';

import type { Chart, Event } from '@antv/g2';

import { G2BaseComponent, G2InteractionType } from '@delon/chart/core';
import { BooleanInput, InputBoolean, InputNumber, NumberInput } from '@delon/util/decorator';
import { NzStringTemplateOutletDirective } from 'ng-zorro-antd/core/outlet';
import type { NzSafeAny } from 'ng-zorro-antd/core/types';
import { NzSkeletonComponent } from 'ng-zorro-antd/skeleton';
Expand Down Expand Up @@ -53,17 +54,14 @@ export interface G2BarClickItem {
imports: [NzStringTemplateOutletDirective, NzSkeletonComponent]
})
export class G2BarComponent extends G2BaseComponent {
static ngAcceptInputType_height: NumberInput;
static ngAcceptInputType_autoLabel: BooleanInput;

// #region fields

@Input() title?: string | TemplateRef<void>;
@Input() color = 'rgba(24, 144, 255, 0.85)';
@Input() @InputNumber() height = 0;
@Input({ transform: numberAttribute }) height = 0;
@Input() padding: number | number[] | 'auto' = 'auto';
@Input() data: G2BarData[] = [];
@Input() @InputBoolean() autoLabel = true;
@Input({ transform: booleanAttribute }) autoLabel = true;
@Input() interaction: G2InteractionType = 'none';
@Output() readonly clickItem = new EventEmitter<G2BarClickItem>();

Expand Down
11 changes: 4 additions & 7 deletions packages/chart/card/card.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import {
Input,
OnChanges,
TemplateRef,
ViewEncapsulation
ViewEncapsulation,
booleanAttribute
} from '@angular/core';

import { BooleanInput, InputBoolean } from '@delon/util/decorator';
import { NzCardComponent } from 'ng-zorro-antd/card';
import { NzStringTemplateOutletDirective } from 'ng-zorro-antd/core/outlet';
import { NzSpinComponent } from 'ng-zorro-antd/spin';
Expand All @@ -25,11 +25,8 @@ import { NzSpinComponent } from 'ng-zorro-antd/spin';
imports: [NzCardComponent, NzSpinComponent, NzStringTemplateOutletDirective]
})
export class G2CardComponent implements OnChanges {
static ngAcceptInputType_bordered: BooleanInput;
static ngAcceptInputType_loading: BooleanInput;

/** 是否显示边框 */
@Input() @InputBoolean() bordered = false;
@Input({ transform: booleanAttribute }) bordered = false;
@Input() avatar?: string | TemplateRef<void> | null;
@Input() title?: string | TemplateRef<void> | null;
@Input() action?: string | TemplateRef<void> | null;
Expand All @@ -43,7 +40,7 @@ export class G2CardComponent implements OnChanges {
}
@Input() footer?: string | TemplateRef<void> | null;
/** 是否显示Loading */
@Input() @InputBoolean() loading = false;
@Input({ transform: booleanAttribute }) loading = false;

constructor(private cdr: ChangeDetectorRef) {}

Expand Down
5 changes: 2 additions & 3 deletions packages/chart/chart-echarts/echarts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testin
import { By } from '@angular/platform-browser';

import { createTestContext } from '@delon/testing';
import { NumberInput } from '@delon/util/decorator';
import { LazyService } from '@delon/util/other';
import { NzSafeAny } from 'ng-zorro-antd/core/types';

Expand Down Expand Up @@ -102,8 +101,8 @@ describe('chart: chart-echarts', () => {
})
class TestComponent {
@ViewChild('cmp') readonly cmp!: ChartEChartsComponent;
width: NumberInput = 600;
height: NumberInput = 400;
width: string | number = 600;
height: string | number = 400;
theme?: string | Record<string, unknown> | null = null;
option: ChartEChartsOption = {};
initOpt: NzSafeAny;
Expand Down
12 changes: 6 additions & 6 deletions packages/chart/core/g2.base.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ import {
OnInit,
Output,
SimpleChanges,
ViewChild
ViewChild,
booleanAttribute,
numberAttribute
} from '@angular/core';
import { Subject, Subscription, filter, takeUntil } from 'rxjs';

import type { Chart, Types } from '@antv/g2';

import { BooleanInput, InputBoolean, InputNumber, NumberInput, ZoneOutside } from '@delon/util/decorator';
import { ZoneOutside } from '@delon/util/decorator';
import type { NzSafeAny } from 'ng-zorro-antd/core/types';

import { G2Service } from './g2.servicce';
Expand Down Expand Up @@ -47,17 +49,15 @@ export abstract class G2BaseComponent implements OnInit, OnChanges, OnDestroy {
)
.subscribe(() => this.load());
}
static ngAcceptInputType_repaint: BooleanInput;
static ngAcceptInputType_delay: NumberInput;
@Input() @InputBoolean() repaint = true;
@Input({ transform: booleanAttribute }) repaint = true;

@ViewChild('container', { static: true }) protected node!: ElementRef;
protected resize$?: Subscription;
protected destroy$ = new Subject<void>();
protected _chart!: Chart;
loaded = false;

@Input() @InputNumber() delay = 0;
@Input({ transform: numberAttribute }) delay = 0;
@Input() theme: string | Types.LooseObject;
@Output() readonly ready = new EventEmitter<Chart>();

Expand Down
11 changes: 4 additions & 7 deletions packages/chart/custom/custom.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import {
EventEmitter,
Input,
Output,
ViewEncapsulation
ViewEncapsulation,
numberAttribute
} from '@angular/core';
import { fromEvent, debounceTime, takeUntil } from 'rxjs';

import { G2BaseComponent } from '@delon/chart/core';
import { InputNumber, NumberInput } from '@delon/util/decorator';
import { NzSkeletonComponent } from 'ng-zorro-antd/skeleton';

@Component({
Expand All @@ -32,13 +32,10 @@ import { NzSkeletonComponent } from 'ng-zorro-antd/skeleton';
imports: [NzSkeletonComponent]
})
export class G2CustomComponent extends G2BaseComponent {
static ngAcceptInputType_height: NumberInput;
static ngAcceptInputType_resizeTime: NumberInput;

// #region fields

@Input() @InputNumber() height?: number;
@Input() @InputNumber() resizeTime = 0;
@Input({ transform: numberAttribute }) height?: number;
@Input({ transform: numberAttribute }) resizeTime = 0;
@Output() readonly render = new EventEmitter<ElementRef>();
@Output() readonly resize = new EventEmitter<ElementRef>();
@Output() readonly destroy = new EventEmitter<ElementRef>();
Expand Down
10 changes: 3 additions & 7 deletions packages/chart/gauge/gauge.component.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { ChangeDetectionStrategy, Component, Input, ViewEncapsulation } from '@angular/core';
import { ChangeDetectionStrategy, Component, Input, ViewEncapsulation, numberAttribute } from '@angular/core';

import type { Chart } from '@antv/g2';

import { G2BaseComponent } from '@delon/chart/core';
import { InputNumber, NumberInput } from '@delon/util/decorator';
import type { NzSafeAny } from 'ng-zorro-antd/core/types';
import { NzSkeletonComponent } from 'ng-zorro-antd/skeleton';

Expand All @@ -23,17 +22,14 @@ import { NzSkeletonComponent } from 'ng-zorro-antd/skeleton';
imports: [NzSkeletonComponent]
})
export class G2GaugeComponent extends G2BaseComponent {
static ngAcceptInputType_height: NumberInput;
static ngAcceptInputType_percent: NumberInput;

// #region fields

@Input() title?: string;
@Input() @InputNumber() height?: number;
@Input({ transform: numberAttribute }) height?: number;
@Input() color = '#2f9cff';
@Input() bgColor?: string; // = '#f0f2f5';
@Input() format?: (text: string, item: NzSafeAny, index: number) => string;
@Input() @InputNumber() percent?: number;
@Input({ transform: numberAttribute }) percent?: number;
@Input() padding: number | number[] | 'auto' = [10, 10, 30, 10];

// #endregion
Expand Down
Loading

0 comments on commit 3c5095d

Please sign in to comment.