Angular 순환 진행 구성 요소 개요

    Ignite UI for Angular 애플리케이션 프로세스가 변경됨에 따라 시각적 표시기를 제공합니다. 원형 표시기는 상태가 변경됨에 따라 모양을 업데이트합니다.

    Angular Circular Progress Example

    Getting Started with Ignite UI for Angular Circular Progress

    Ignite UI for Angular Circular Progress 구성 요소를 시작하려면 먼저 Ignite UI for Angular 설치해야 합니다. 기존 Angular 애플리케이션에서 다음 명령을 입력합니다.

    ng add igniteui-angular
    

    Ignite UI for Angular에 대한 전체 소개를 보려면 시작하기 항목을 읽어보세요.

    다음 단계는 IgxProgressBarModule에서 app.module.ts 파일:

    // app.module.ts
    
    ...
    import { IgxProgressBarModule } from 'igniteui-angular';
    // import { IgxProgressBarModule } from '@infragistics/igniteui-angular'; for licensed package
    
    @NgModule({
        ...
        imports: [..., IgxProgressBarModule],
        ...
    })
    export class AppModule {}
    

    또는 16.0.0부터 IgxCircularProgressBarComponent를 독립 실행형 종속성으로 가져오거나 IGX_CIRCULAR_PROGRESS_BAR_DIRECTIVES 토큰을 사용하여 구성 요소와 모든 지원 구성 요소 및 지시어를 가져올 수 있습니다.

    // home.component.ts
    
    import { IGX_CIRCULAR_PROGRESS_BAR_DIRECTIVES } from 'igniteui-angular';
    // import { IGX_CIRCULAR_PROGRESS_BAR_DIRECTIVES } from '@infragistics/igniteui-angular'; for licensed package
    
    @Component({
        selector: 'app-home',
        template: `
        <igx-circular-bar
            [value]="100"
            [animate]="true"
            class="custom-size"
        ></igx-circular-bar>
        `,
        styleUrls: ['home.component.scss'],
        standalone: true,
        imports: [IGX_CIRCULAR_PROGRESS_BAR_DIRECTIVES]
        /* or imports: [IgxCircularProgressBarComponent] */
    })
    export class HomeComponent {}
    

    이제 Ignite UI for Angular 가져왔으므로 igx-circular-bar 구성 요소 사용을 시작할 수 있습니다.

    Using the Angular Circular Progress

    모든 것이 어떻게 작동하는지 더 잘 이해하기 위해 데모에 있는 것과 같은 간단한 예를 만들어 보겠습니다.

    <igx-circular-bar
        [value]="100"
        [animate]="true"
        class="custom-size"
    ></igx-circular-bar>
    

    그런 다음 브라우저에 데모 샘플이 있어야 합니다.

    Note

    그만큼 igx-원형-바 방출하다 onProgressChanged 이와 같은 객체를 출력하는 이벤트 {currentValue: 65, previousValue: 64} 각 단계마다.

    Note

    기본 진행률은 업데이트 주기당 max 값의 1% 씩 증가합니다. 이는 step 값이 정의되지 않은 경우 발생합니다. 업데이트 속도를 변경하려면 step 값을 정의해야 합니다.``

    Indeterminate Progress

    정확하게 결정되지 않은 프로세스를 추적하려면 indeterminate 입력 속성을 true로 설정하면 됩니다.

    <igx-circular-bar
        [animate]="false"
        [indeterminate]="true"
        [textVisibility]="false"
    ></igx-circular-bar>
    
    Note

    textVisibility 속성을 false로 설정하여 원형 진행률 표시줄의 텍스트를 숨길 수 있습니다.

    최종 결과는 다음과 같습니다.

    Dynamic Progress

    버튼과 같은 외부 컨트롤을 사용하여 진행률 값을 동적으로 변경할 수 있습니다. 이를 달성하기 위해 값을 클래스 속성에 바인딩할 수 있습니다.

    <div class="sample-content">
        <igx-circular-bar
            [value]="currentValue"
            [max]="100"
            [animate]="true"
            class="custom-size">
        </igx-circular-bar>
        <div class="button-container">
            <button igxIconButton="flat" (click)="decrementProgress()">
                <igx-icon fontSet="material">remove</igx-icon>
            </button>
            <button igxIconButton="flat" (click)="incrementProgress()">
                <igx-icon fontSet="material">add</igx-icon>
            </button>
        </div>
    </div>
    

    값을 증가 및 감소시키는 메소드를 추가하십시오.

    @Component({...})
    export class HomeComponent {
        public currentValue: number;
    
        public ngOnInit() {
            this.currentValue = 0;
        }
    
        public incrementProgress() {
            this.currentValue += 10;
            if (this.currentValue > 100) {
                this.currentValue = 100;
            }
        }
    
        public decrementProgress() {
            this.currentValue -= 10;
            if (this.currentValue < 0) {
                this.currentValue = 0;
            }
        }
    }
    

    몇 가지 스타일을 추가하세요.

    .custom-size {
      width: 100px;
      height: 100px;
    }
    
    .sample-content {
      width: 300px;
      display: flex;
      align-items: center;
      margin-top: 30px;
    }
    

    Gradient Progress

    진행률 표시줄을 사용자 정의하는 한 가지 방법은 단색 대신 색상 그라데이션을 사용하는 것입니다. 이는 IgxProgressBarGradientDirective 지시문을 사용하거나 사용자 정의 테마를 구현하는 두 가지 방법 중 하나로 수행할 수 있습니다. 단, 사용자 정의 테마는 최대 2개의 색상 중지를 지원합니다.

    두 가지 색상 정지점만으로 그라디언트를 생성하려면 사용자 정의 테마를 사용하면 됩니다. 색상 목록을 생성하고 이를 $progress-circle-color 테마 매개변수에 전달합니다.

    $colors: #695cf9, #ef017c;
    
    $custom-theme: progress-circular-theme(
        $progress-circle-color: $colors
        
    );
    

    Styling Section에서 원형 진행률 표시줄 스타일 지정에 대해 자세히 알아볼 수 있습니다.

    2개 이상의 색상 정지점을 갖는 그라디언트를 제공하려면 igx-circular-barng-template에 다음과 같은 지시문을 사용해야 합니다.

    <div class="sample-content">
      <igx-circular-bar
        [value]="currentValue"
        [max]="100"
        [animate]="true"
        class="custom-size">
          <ng-template igxProgressBarGradient let-id>
              <svg:linearGradient [id]="id" gradientTransform="rotate(90)">
                  <stop offset="0%"   stop-color="#ff9a40"/>
                  <stop offset="50%" stop-color="#1eccd4"/>
                  <stop offset="100%" stop-color="#ff0079"/>
              </svg:linearGradient>
          </ng-template>
      </igx-circular-bar>
    
      <div class="button-container">
          <button igxIconButton="flat" (click)="removeProgress()">
              <igx-icon fontSet="material">remove</igx-icon>
          </button>
          <button igxIconButton="flat" (click)="addProgress()">
              <igx-icon fontSet="material">add</igx-icon>
          </button>
      </div>
    </div>
    

    위 단계를 재현한 후 결과는 다음과 같습니다.

    스타일링

    원형 진행률 표시줄 스타일 지정을 시작하려면 모든 테마 기능과 구성 요소 믹스인이 있는 index 파일을 가져와야 합니다.

    @use "igniteui-angular/theming" as *;
    
    // IMPORTANT: Prior to Ignite UI for Angular version 13 use:
    // @import '~igniteui-angular/lib/core/styles/themes/index';
    

    가장 간단한 접근 방식에 따라 progress-circular-theme 확장하고 $base-circle-color$progress-circle-color 매개변수를 허용하는 새로운 테마를 만듭니다.

    $custom-theme: progress-circular-theme(
        $base-circle-color: lightgray,
        $progress-circle-color: rgb(32, 192, 17)
    );
    

    Including Themes

    마지막 단계는 애플리케이션에 구성 요소 테마를 포함하는 것입니다.

    $legacy-support​ ​true로 설정된 경우 다음과 같은 구성 요소 테마를 포함합니다.

     @include progress-circular($custom-theme);
    
    Note

    구성 요소가 Emulated ViewEncapsulation을 사용하는 경우::ng-deep 사용하여 이 캡슐화를 penetrate 해야 합니다.

    :host {
         ::ng-deep {
            @include progress-circular($custom-theme);
        }
    }
    

    $legacy-support​ ​false (기본값)로 설정된 경우 다음과 같은 구성 요소 CSS 변수를 포함합니다.

    @include css-vars($custom-theme);
    
    Note

    구성 요소가 Emulated ViewEncapsulation을 사용하는 경우 변수를 재정의하려면 전역 선택기가 필요하므로 여전히:host 사용해야 합니다.

    :host {
        @include css-vars($custom-theme);
    }
    

    Demo

    API