Chartjs table each making series not proceeding to next tr

0πŸ‘

βœ…

In generateDataSetsFromTable(), move your dataset creation outside of the tr loop (rows.each)

function generateDataSetsFromTable()
{
    var data;
    var datasets = [];
    var rows = jQuery("tr");
    var data = [];
    rows.each(function(index){
        if (index != 0) // we dont need first row of table
        {
           var cols = $(this).find("td");  
            cols.each(function(innerIndex){
                if (innerIndex!=0) // we dont need first columns of the row                 
                      data.push($(this).text()); 
            }); 
        }
    });

    var dataset = 
        {
            fillColor: "rgba(238,155,0,0.2)",
            strokeColor: "rgba(217,0,0,1)",
            pointColor: "rgba(166,0,0,1)",
            pointStrokeColor: "#fff",
            pointHighlightFill: "#fff",
            pointHighlightStroke: "rgba(151,187,205,1)",
            data : data
        }
    datasets.push(dataset);
    return datasets;
}

Fiddle – http://jsfiddle.net/fv3ry41s/

Leave a comment