我基本上是想在amchart4中编辑我在angular 7应用程序中使用的信用,但似乎并没有删除它。
我正在尝试在html中使用该属性,但猜想它不合适。如何在组件代码中设置
代码
import { Component, NgZone, Input } from '@angular/core';
import * as am4core from '@amcharts/amcharts4/core';
import * as am4charts from '@amcharts/amcharts4/charts';
import am4themes_animated from '@amcharts/amcharts4/themes/animated';
import { OnInit, AfterViewInit, OnDestroy } from '@angular/core';
am4core.useTheme(am4themes_animated);
@Component({
template: ` <div id="chartdiv" [style.width.%]="100" [style.height.px]="500" > "hideCredits" : true</div>`,
selector: 'app-pie-chart'
})
export class PieChartComponent implements AfterViewInit, OnDestroy {
private chart: am4charts.PieChart;
@Input() series: any;
constructor(private zone: NgZone) { }
ngAfterViewInit() {
this.zone.runOutsideAngular(() => {
const chart = am4core.create('chartdiv', am4charts.PieChart);
chart.responsive.enabled = true;
if (this.series) {
chart.data = this.series;
/* credit hiding code omitted */
const pieSeries = chart.series.push(new am4charts.PieSeries());
pieSeries.dataFields.value = 'Percent';
pieSeries.dataFields.category = 'ProductName';
pieSeries.colors.list = [
am4core.color('#717171'),
am4core.color('#62B1D0'),
am4core.color('#3AA6D0'),
am4core.color('#024C68'),
am4core.color('#226078'),
am4core.color('#717171'),
am4core.color('#62B1D0'),
am4core.color('#3AA6D0'),
am4core.color('#024C68'),
am4core.color('#226078'),
am4core.color('#717171'),
am4core.color('#62B1D0'),
am4core.color('#3AA6D0'),
am4core.color('#024C68'),
am4core.color('#226078'),
];
ngOnDestroy() {
this.zone.runOutsideAngular(() => {
if (this.chart) {
this.chart.dispose();
}
});
}
}