Home Forums Chart Support Need help

Need help

Viewing 2 posts - 1 through 2 (of 2 total)
  • #28655

    I have tried to render the chart with an array of objects as the key (string) and value (numeric) but I am getting like this

    main.js:40 Uncaught TypeError: chart.rendor is not a function

    const form = document.getElementById(‘voteForm’);
    form.addEventListener(‘submit’, e => {
    const option = document.querySelector(‘input[name=series]:checked’).value;
    const data = {series: option};
    console.log(option,data)
    fetch(‘http://localhost:3001/poll’, {
    method: ‘POST’,
    body: JSON.stringify(data),
    headers: {
    ‘Content-Type’: ‘application/json’
    }
    }).then(res => res.json())
    .then(data => console.log(data))
    .catch(err => console.log(err));
    e.preventDefault();
    });

    let dataPoints = [
    { label: ‘Game of Thrones’, y:0},
    { label: ‘Money Heist’, y:0},
    { label: ‘Dare Devil’, y:0},
    { label: ‘Peaky Blinders’, y:0},
    { label: ‘How to get away with murder’, y:0},
    ];

    const chartContainer = document.querySelector(‘#chartContainer’);
    console.log(chartContainer)
    if (chartContainer) {
    const chart = new CanvasJS.Chart(“chartContainer”, {
    animationEnabled: true,
    theme: ‘theme1’,
    title: {
    text: ‘Best Series’
    },
    data: [{
    type: ‘column’,
    dataPoints: dataPoints
    }]
    });
    chart.rendor();
    }

    I’m getting everything in the console and the only problem is this

    • This topic was modified 4 years, 8 months ago by Rishwanth.
    • This topic was modified 4 years, 8 months ago by Rishwanth.
    • This topic was modified 4 years, 8 months ago by Vishwas R.
    #28664

    @rishwanth,

    There seems to be typo in your code. You are using calling method rendor (which is not present) instead of render. Changing it to chart.render() should work fine in your case.

    If you are still facing issue, kindly create JSFiddle reproducing the issue and share it with us so that we can look into the code, understand the scenario better and help you resolve.


    Vishwas R
    Team CanvasJS

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

You must be logged in to reply to this topic.