Home forums Using CanvasJS Monthly Expense (pie chart Angular5) npm install canvasjs

Tagged: 

This topic contains 1 reply, has 2 voices, and was last updated by  Vishwas R 4 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #23518

    i am using the pie chart which is throwing me some error WRT Chart
    ( npm install canvasjs ) ran this as well
    1.Cannot read property ‘Chart’ of undefined
    2.Cannot read property ‘render’ of undefined
    HTML
    <div id=”chartContainer” style=”height: 370px; width: 100%; margin-left:auto;margin-right:auto;”></div>
    Angular
    ngOnInit() {

    this.debugger
    let chart = new this.CanvasJS.Chart(“chartContainer”, {
    theme: “light2”,
    animationEnabled: true,
    exportEnabled: true,
    title:{
    text: “Monthly Expense”
    },
    data: [{
    type: “pie”,
    showInLegend: true,
    toolTipContent: “<b>{name}</b>: ${y} (#percent%)”,
    indexLabel: “{name} – #percent%”,
    dataPoints: [
    { y: 450, name: “Food” },
    { y: 120, name: “Insurance” },
    { y: 300, name: “Traveling” },
    { y: 800, name: “Housing” },
    { y: 150, name: “Education” },
    { y: 150, name: “Shopping”},
    { y: 250, name: “Others” }
    ]
    }]

    });
    this.chart.render();

    console.log(chart.data)
    }
    please help me .

    Thanks,
    Sonam

    #23523

    @sonamallied,

    We don’t have official NPM package as of now. However, CanvasJS Charts seems to be working fine in Angular 5. Please take a look at this sample project for integration of charts in Angular. You can also check out Angular Gallery for more examples.


    Vishwas R
    Team CanvasJS

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.