Turo
Turo

Reputation: 1607

Kendo stacked column chart not displaying data correctly

Based on this or similar examples I tried using kendo stacked chart.

To my suprise the chart gets displayed incorrectly.

  $("#chart").kendoChart({
        dataSource: new kendo.data.DataSource({
            data: data,
            group: {
                field: "Serie"
            }
        }),
        series:
        [{
            type: "column",
            stack: true,
            field: "Value"
        },
        ],
        categoryAxis: {
            field: "Category"
        }
    });

I tried defining also the model as in attached plunker or various other variations, but the data is still incorrect e.g. 2016-07 should just show 2 activities, while it shows 5.

var data =
    [{ "Category": "2016-07", "Serie": "Physiotherapy", "Value": 35.00 },
        { "Category": "2016-07", "Serie": "Flex Class", "Value": 28.00 },
        { "Category": "2016-08", "Serie": "Flex Class", "Value": 27.00 },
        { "Category": "2016-08", "Serie": "Manual Therapy", "Value": 48.00 }
// rest in plunker
];

Upvotes: 0

Views: 311

Answers (1)

Turo
Turo

Reputation: 1607

Ok, I got it. In order for this to show properly, all combinations of Category-Serie need to be served in dataSource and filled with zeros where the Serie is missing e.g. like that that

{ "Category": "2016-07", "Serie": "Manual Therapy", "Value": 0 }

Upvotes: 1

Related Questions