Samanth Kolisetty
Samanth Kolisetty

Reputation: 125

kendo bar chart ordering issue

I have a kendo barchart and I get the data from the model and bind to the char. But the problem here is i am unable to sort the order. I am pasting the code below. Todat certification time is coming in between.Any help on this is highly appreciated.

var certData = [{"IronCount":1.65,"TypeWiseData":"Adapter","TestType":"Magnetic Particle Test"},{"IronCount":2.76,"TypeWiseData":"Adapter","TestType":"UT Thickness Test"},{"IronCount":140.37,"TypeWiseData":"Adapter","TestType":"TotalCertificationTime"},{"IronCount":2.02,"TypeWiseData":"Swivel","TestType":"UT Thickness Test"},{"IronCount":2.06,"TypeWiseData":"Swivel","TestType":"Magnetic Particle Test"},{"IronCount":142.67,"TypeWiseData":"Swivel","TestType":"TotalCertificationTime"}];

 var dsCertpData = new kendo.data.DataSource({
        data: certData,
        group: {
            field: "TestType",
            //dir: "asc"
        },
        sort:{       
            field :"IronCount",
            dir:"asc"
    }
    });

    $("#chart1").kendoChart({
        title: {
            text: "Certification Time Per Piece Report",
            font: "bold 20px Arial,Helvetica,sans-serif",
            color: "brown"
        },
        //plotArea: {
        //    background: "#F8F3F3"
        //},
        dataSource: dsCertpData,
        series: [{
            type: "column",
            categoryField: "TypeWiseData",
            field:"IronCount"
        }],

        valueAxis: {
            title: {
                text: "Utilization",
                font: "bold 15px Arial,Helvetica,sans-serif",
                color: "brown"
            }
        },

        categoryAxis:{
            title: {
                text: "Iron Types",
                font: "bold 18px Arial,Helvetica,sans-serif",
                color: "brown"
            }
        },

        tooltip: {
            visible: true,
            template: "${series.name} : ${value}"
        }
    });

Upvotes: 0

Views: 613

Answers (1)

ezanker
ezanker

Reputation: 24738

You could swap your grouping:

var dsCertpData = new kendo.data.DataSource({
    data: certData,
    group: {
      field: "TypeWiseData",
    },
    sort:{       
      field :"IronCount",
      dir:"desc"
    }
}); 

series: [{
    type: "column",
    categoryField: "TestType",
    field:"IronCount"
}], 

DEMO

Upvotes: 1

Related Questions