Primeng: Pie chart throws error

Created on 30 May 2016  路  8Comments  路  Source: primefaces/primeng

I am using primeng beta 7 and I am trying to create a pie chart following the demo example. I receive following error.

image

My ts code is

锘縤mport {Component}                  from '@angular/core';
import {UIChart}                    from 'primeng/primeng';

@Component({
    selector: 'chart-comp',
    templateUrl: '/app/components/chart-comp.component.html',
    directives: [UIChart]
})
export class ChartComponent {
    data: any;

    constructor() {
        this.data = {
            labels: ['A', 'B', 'C'],
            datasets: [
                {
                    data: [300, 50, 100],
                    backgroundColor: [
                        "#FF6384",
                        "#36A2EB",
                        "#FFCE56"
                    ],
                    hoverBackgroundColor: [
                        "#FF6384",
                        "#36A2EB",
                        "#FFCE56"
                    ]
                }]
        };
    }  
}

and the html

<p-chart [type]="pie" [data]="data"></p-chart>

Most helpful comment

Another case of bad documentation on their website. You need to remove the brackets around type.

<p-chart [type]="line" [data]="data"></p-chart>
to
<p-chart type="line" [data]="data"></p-chart>

All 8 comments

any idea?

What is your charts.js version? You need 2.1.x

I have tried both 2.1.3 and 2.1.4

Having the same issue. The code is nearly identical as above. Tried 2.1.3 and 2.1.4

Another case of bad documentation on their website. You need to remove the brackets around type.

<p-chart [type]="line" [data]="data"></p-chart>
to
<p-chart type="line" [data]="data"></p-chart>

Thanks @danielfs1

I had been banging my head for last 3 hours. Finally issue resolved and able to see the chart on screen.

@danielfs1 thanks

Fixed the doc locally and it will be available tomorrow online, please report any documentation error at our issue tracker to let us know.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pchristou picture pchristou  路  3Comments

Helayxa picture Helayxa  路  3Comments

just-paja picture just-paja  路  3Comments

jisqaqov picture jisqaqov  路  3Comments

miresk picture miresk  路  3Comments