Forum Replies Created by marokino1

Viewing 1 post (of 1 total)
  • in reply to: Multiple dynamic data #9029

    Thank you very much for your answer.

    I’ve changed a bit my code

    1- is my load function

    function displayChart(datapointss){
    alert(datapointss);
    var chart = new CanvasJS.Chart(“chartContainer”,
    {
    zoomEnabled: false,
    animationEnabled: true,
    title:{
    text: “PROJECTS”
    },
    axisY2:{
    valueFormatString:”0.0 days”,
    interlacedColor: “#F5F5F5”,
    gridColor: “#D7D7D7”,
    tickColor: “#D7D7D7”
    },
    theme: “theme2”,
    toolTip:{
    shared: true
    },
    legend:{
    verticalAlign: “bottom”,
    horizontalAlign: “center”,
    fontSize: 15,
    fontFamily: “Lucida Sans Unicode”
    },
    data:[{
    datapointss
    }
    ]
    ,
    legend: {
    cursor:”pointer”,
    itemclick : function(e) {
    if (typeof(e.dataSeries.visible) === “undefined” || e.dataSeries.visible) {
    e.dataSeries.visible = false;
    }
    else {
    e.dataSeries.visible = true;
    }
    chart.render();
    }
    }
    });

    chart.render();

    }

    2 – ajax function

    function function1(tab){
    return $.ajax({
    type: ‘POST’,
    url: ‘php/load.php’,
    dataType: ‘json’,
    data: ‘projet=’+ tab,
    error: function(){
    alert(‘impossible de chercher ce project’);
    },
    success: function(json){}
    });
    }

    3 – the data construction function in JSON format

    function getConsolidation(){
    var results = [];
    var list = [“SFR” , “MANAGEMENT”];
    for(f in list){
    results.push(function1(list[f]));
    }
    $.when.apply(this , results).done(function() {
    var table = [];
    var values = “”;
    for (var i = 0; i < list.length; i++) {
    values += ‘”type” : “line”, “showInLegend” : “true”, “name” : “‘+ list[i] +'” ,”dataPoints” : ‘+ results[i].responseText +’,’;
    }
    //for (var i=0; i<values.length; i++) {
    console.log(values);
    displayChart(values);
    //}

    //displayChart(values);
    //values.replace(/(\s+)?.$/, ”);// Pour supprimer ‘,’ a la fin de la chaine
    });
    }

    and this is JSON :

    [{“type” : “line”, “showInLegend” : “true”, “name” : “name1″ ,”dataPoints” : [{“x”:”2015-3-01″,”y”:34},{“x”:”2015-4-01″,”y”:41},{“x”:”2015-5-01″,”y”:23.800000026822}]
    ,”type” : “line”, “showInLegend” : “true”, “name” : “name2″ ,”dataPoints” : [{“x”:”2015-2-01″,”y”:14},{“x”:”2015-3-01″,”y”:37},{“x”:”2015-4-01″,”y”:39.20000000298},{“x”:”2015-5-01″,”y”:50.10000000149}]
    }]

    and of course once again it does not work with any error HELP ME

Viewing 1 post (of 1 total)