Skip to content

g2-pie first time rendering is wrong if initial data is an empty array #1849

@core2duoe6420

Description

@core2duoe6420

Reproduction link

https://stackblitz.com/edit/ng-alain-pie-issue?file=src/app/app.component.ts

Steps to reproduce

As the following code shows, if pieData is initialized as [] and is assigned later, the pie is not rendered correctly

import { Component } from "@angular/core";
import { of } from "rxjs";
import { delay } from "rxjs/operators";

@Component({
  selector: "my-app",
  template: `
    <g2-pie
      [hasLegend]="true"
      subTitle="vote"
      [data]="pieData"
      height="400"
    ></g2-pie>
  `
})
export class AppComponent {
  pieData = [];
  ngOnInit() {
    of([{ x: "a", y: 1 }, { x: "b", y: 1 }])
      .pipe(delay(1000))
      .subscribe(v => (this.pieData = v));
  }
}

What is expected?

The pie should render correctly, for the example, it should be 2 semi-circles

What is actually happening?

The pie renders wrongly, the whole pie has only one color

Environment Info
ng-alain 10.0.2
Browser Chrome 86

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions