Home Forums Report Bugs issue with stacked columns and dates in YYYY-m-D Reply To: issue with stacked columns and dates in YYYY-m-D


Now sure if I can dare to post here, forum behind cloud flare and was sent to their verification page and my POST was gone…

Anyways I can share some code, I have succeeded a bit with adding a simple object from my jSON, but I’m using push in a way that will append every date and value to every “name” section of the CanvasJS object.

              var chart4 = new CanvasJS.Chart("networking", {
                culture:  "se",
              	animationEnabled: true,
              	theme: "light1",
              	zoomEnabled: true,
	             legend: {
                 cursor: "pointer",
                 itemclick: toggleDataSeries
               axisX: {
                 type: 'dateTime'
              	data: dataPointsN


              function addDataN(dataN) {
                var network = dataN;
                var dataPointsArray = [];

                for (var i = 0; i < Object.keys(network).length; i++) {

                  for (var ii = 0; ii < network[Object.keys(network)[i]].length; ii++) {

                    // console.log(i+' '+network[Object.keys(network)[i]][ii]["x"]);

                       "x": new Date(network[Object.keys(network)[i]][ii]["x"]),
                       "y": network[Object.keys(network)[i]][ii]["y"]



                     "name": Object.keys(network)[i],
                     "type": "stackedColumn",
                     "xValueType": "dateTime",
                     "lineThickness": 10,
                     "showInLegend": "true",
                     "dataPoints": dataPointsArray



              $.getJSON("API/Stream.php?Func=Network", addDataN);

As my key is a name I’m using the rather strange method above to find they keys, but it works. However my push will for obvious reasons grow over time.

Here is an sample output of the JSON for reference.

    "Arbetsf\u00f6rmedlingen": [
            "x": "2020-03-02",
            "y": 23
            "x": "2020-04-10",
            "y": 8
    "Name 2": [
            "x": "2020-03-02",
            "y": 11
  • This reply was modified 4 years, 2 months ago by Andy.