Question

J'ai besoin de passer des données sur mes cartes Canvasjs, mais pas à la façon dont.

J'ai mes données de journalisation dans la console amende

Console Connexion

35 + 397 
6 + 399 
12 + 1314 
13 + 1316 

Fetch Data

$.get("graph/" + $_GET["centre"] + "", function (d) {

    var graphDataData = null;

    try {
        graphDataData = JSON.parse(d);
    }
    catch (err) {
        return;
    }

    $.each(graphDataData, function(key, value) {
          console.log(value.value + " + " + value.source);
    });
});

graphique

var chart = new CanvasJS.Chart("chartContainer", {
---->
    data: [
    {     
        type: "bar",
        name: "Stores",
        axisYType: "secondary",
        color: "#00b6de",               
        dataPoints: [


        // Put my data here.
        {y: 5, label: "Sweden"  },
        {y: 6, label: "Taiwan"  },
        {y: 7, label: "Russia"  },

        ]
    }

    ]
});

chart.render();

Était-ce utile?

La solution

Quelque chose comme ça devrait fonctionner:

var points = [];
$.each(graphDataData, function(key, value) {
      points.push({y: value.value, label:value.source}); // I'm assuming that's how the data has to be structured.
});

et ensuite dans votre graphique initialisation:

dataPoints: points

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top