Kendo Stacked Bar Chart configuration

六眼飞鱼酱① 提交于 2020-01-17 03:59:52

问题


I have an MVC app and my controller is passing the following json data to my view

data:
{
    "Category":"Q1 2013",
    "Name":"Female",
    "Count":5000
},
{
    "Category":"Q1 2013",
    "Name":"Male",
    "Count":5000
}
{
    "Category":"Q1 2012",
    "Name":"Female",
    "Count":3500
},
{
    "Category":"Q1 2012",
    "Name":"Male",
    "Count":5000
}

I need to know how to configure my Kendo stacked bar chart to display the data like this http://jsfiddle.net/ihatemash/B6LSX/

I can't figure out how to configure the series and category to show the stacked bar chart correctly.


回答1:


here is working example http://jsfiddle.net/idhasitha/F2TQ8/

try with like this

var data = [

    {"Name":1,"Year":2011,"Expense":200.00},
    {"Name":1,"Year":2012,"Expense":274.91},
    {"Name":5,"Year":2011,"Expense":100.00},
    {"Name":5,"Year":2012,"Expense":315.84},

];

$(document).ready(function() {
    $("#chart").kendoChart({
        theme: "silver",
        title: {
            text: "Total records processed"
        },
        legend: {
            position: "bottom"
        },
        dataSource: {
            data: data,
            group: {
                field: "Name"
            }
        },
        transitions: false,
        series: [{
            type: "column",
            stack: "true",
            field: "Expense"
        }],
        categoryAxis: {
            field: "Year"                                
        }
    });
});


来源:https://stackoverflow.com/questions/24988632/kendo-stacked-bar-chart-configuration

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!