문제

내지도 캔버스에 데이터를 전달해야하지만 확실하지 않은 방법을 확실하지 않아야합니다.

콘솔 Fine

에 데이터 로깅이 있습니다.

콘솔 로그

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

데이터 가져 오기

$.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);
    });
});
.

그래프

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();
.

도움이 되었습니까?

해결책

이렇게 작용해야합니다 :

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.
});
.

및 차트 초기화 :

dataPoints: points
.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top