1
私はprimeng beta 9版を使用して円グラフを作成しようとしています。Primengの円グラフはAngular2でエラーをスローする
以下は、コンパイルで
import { Component } from '@angular/core';
import { UIChart, Message } from 'primeng/primeng';
@Component({
template: `
<h2> This is Chart.js component </h2>
<br/><br/>
<p-chart type="pie" [data]="data" width="300" height="300"
[segmentShowStroke]="false" [animationSteps]="50" animationEasing="easeInOutQuint" [animateScale]="true"></p-chart>
`,
directives: [UIChart]
})
export class ChartComponent {
data: any[];
constructor() {
this.data = [{
value: 125,
color: '#2196F3',
highlight: '#64B5F6',
label: 'Football'
},
{
value: 50,
color: '#673AB7',
highlight: '#9575CD',
label: 'Pool'
},
{
value: 75,
color: '#00897B',
highlight: '#26A69A',
label: 'Tennis'
},
{
value: 22,
color: '#FF9800',
highlight: '#FFB74D',
label: 'Basketball'
},
{
value: 100,
color: '#FF5722',
highlight: '#FF8A65',
label: 'Cricket'
}];
}
}
コード - 私のサンプルである、それはすべてのエラーを表示しません。 しかしブラウザはとエラーが表示されます -
ORIGINAL EXCEPTION: TypeError: i.labels is undefined
いただきました!ここで間違って私に知らせてください。
データが静的でない場合、たとえばレンダリングされない数値の配列を返す関数を使用する場合など、これは機能しません。 – naoru