Forum Replies Created by Andy

Viewing 4 posts - 1 through 4 (of 4 total)
  • in reply to: issue with stacked columns and dates in YYYY-m-D #28940

    Hi again @shashiranjan,
    You can check a online version here http://jobbigt.nu/statistik

    I have disabled referrer on the endpoints so you can load them in Postman if you want, I have also kept my console log in the code for the object I’m attaching to CanvasJS. It’s clear that it’s been added 6 times for my 6 datasets, i.e. the loop is not reset, witch makes sense I’m just not sure how to to do it another way.

    in reply to: issue with stacked columns and dates in YYYY-m-D #28939

    Hi again,
    You can check a online version here http://jobbigt.nu/statistik

    I have disabled referrer on the endpoints so you can load them in Postman if you want, I have also kept my console log in the code for the object I’m attaching to CanvasJS. It’s clear that it’s been added 6 times for my 6 datasets, i.e. the loop is not reset, witch makes sense I’m just not sure how to to do it another way.

    in reply to: issue with stacked columns and dates in YYYY-m-D #28904

    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"]);
    
                        dataPointsArray.push(
                          {
                           "x": new Date(network[Object.keys(network)[i]][ii]["x"]),
                           "y": network[Object.keys(network)[i]][ii]["y"]
                         }
    
                       );
    
                       }
    
                      dataPointsN.push({
                         "name": Object.keys(network)[i],
                         "type": "stackedColumn",
                         "xValueType": "dateTime",
                         "lineThickness": 10,
                         "showInLegend": "true",
                         "dataPoints": dataPointsArray
                     });
    
                    }
    
                    console.log(dataPointsN);
                    chart4.render();
                  }
    
                  $.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, 8 months ago by Andy.
    in reply to: issue with stacked columns and dates in YYYY-m-D #28886

    @shashiranjan
    thanks for sharing.

    I’m not an expert ob js, but I’d like to load my dataset from Json? At the moment I understand how do create the root variables + dataset, but I cant cast in json for obvious reasons. I understand this might not be specific to canvas JS but felt I could at least ask.

    The jsfiddle I shows was just an example where I didn’t have to expose my API endpoints.

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