Chart.js: me.ticks.map is not a function

Created on 29 Sep 2016  路  1Comment  路  Source: chartjs/Chart.js

I'm getting this error in line 7058.
I'm doing a ajax request to get my data, labels but when I create the Chart I get this error.
I already tried a setTimeout because an async request, change the creation of chart to complete, or success, but without any result.

My code:

var config = {};

$(document).ready(function () {
    RecuperarInfosGrafico();
});

function RecuperarInfosGrafico() {
    var url = '<%= Request.RawUrl %>';
    $.ajax({
        type: "POST",
        url: url + "/CarregarGrafico",
        contentType: "application/json; charset=utf-8",
        success: function (data) {
            debugger;
            config = {
                type: 'bar',
                data: {
                    datasets: [{
                        label: 'N煤mero de Despesas',
                        borderWidth: 1
                    }]
                },
                options: {
                    fullWidth: false,
                    scales: {
                        yAxes: [{
                            ticks: {
                                beginAtZero: true,
                                stepSize: 1
                            }
                        }]
                    },
                    tooltips: {
                        xLabel: String,
                        yLabel: String,
                        datasetIndex: Number,
                        index: Number
                    },
                    animation: {
                        duration: 100
                    }
                }
            };

            config.data.labels = data.d.labels;
            config.data.datasets[0].data = data.d.data;
            config.options.scales.yAxes[0].ticks.max = data.d.qtdTotal;

            return null;
        },
        error: function (data) {
            console.log(data);
        },
        complete: function (test) {
            var ctx = document.getElementById("myChart");
            var myChart = new Chart(ctx, config);
            myChart.update();
        }
    });
}

Most helpful comment

I was getting this error cause my data format was wrong.

>All comments

I was getting this error cause my data format was wrong.

Was this page helpful?
0 / 5 - 0 ratings