0

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}"
        }
    });

1 Answers1

1

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

ezanker
  • 24,628
  • 1
  • 20
  • 35
  • Hi Ezanker, Could you please help me on this thread.http://stackoverflow.com/questions/34334829/kendo-chart-rendering-very-slow – Samanth Kolisetty Dec 18 '15 at 05:08
  • Hi Ezanker , Could you please help me on this thread.http://stackoverflow.com/questions/35747532/kendo-chart-category-axis-fix-number-of-labels – Samanth Kolisetty Mar 02 '16 at 12:43
  • Hi Ezanker, Could you please help me with this thread https://stackoverflow.com/questions/46033614/how-to-set-filter-property-through-javascript-or-jquery-for-a-kendo-dropdown – Samanth Kolisetty Sep 05 '17 at 04:59