This is a migrated thread and some comments may be shown as answers.

Is it possible to have stacking using JSON like data

1 Answer 36 Views
Charts
This is a migrated thread and some comments may be shown as answers.
Geroj
Top achievements
Rank 1
Geroj asked on 27 Jun 2016, 09:39 PM

Hi,

I'm trying to have a stacked chart using JSON like data or remote data. 

using the data below I was able to get exactly the chart I wanted dojo Code here

    var data = [
    {"Name":1,"Year":2011,"Expense":200.00, "color":"grey"},
    {"Name":1,"Year":2012,"Expense":274.91,"color":"grey"},
    {"Name":5,"Year":2011,"Expense":100.00, "color":"red"},
    {"Name":5,"Year":2012,"Expense":315.84, "color":"red"},
    {"Name":3,"Year":2011,"Expense":325.84,"color":"orange"}
];

But when I added other rows to this data, the result is not what I was expecting. dojo code here

     var data = [
    {"Name":1,"Year":2011,"Expense":200.00, "color":"grey"},
{"Name":6,"Year":2010,"Expense":205.00 ,"color":"yellow"},
    {"Name":1,"Year":2012,"Expense":274.91,"color":"grey"},
    {"Name":5,"Year":2011,"Expense":100.00 ,"color":"red"},
    {"Name":5,"Year":2012,"Expense":315.84, "color":"red"},
    {"Name":3,"Year":2011,"Expense":325.84 , "color":"orange"},
  {"Name":5,"Year":2013,"Expense":205.00 ,"color":"red"},

What I was expecting is the result of this dojo code

But I was able to do this using this data structure

series: [{
                    name: "name 3",
                    data: [0, 325.4 ,0],
                  color:"orange"
                }, {
                    name: "name 1",
                    data: [0, 200, 274],
                  color:"grey"
                }, {
                    name: "name 5",
                    data: [100, 205, 315.84 ],
                  color:"red"
                },
                  {
                    name: "name 6",
                    data: [205, 0, 0 ],
                    color: "yellow"

                }]

Is there any way to make this work using remote data (Json ) and not  the last data structure that is shown in this post ?

Any help will be appreciated,

Geroj

1 Answer, 1 is accepted

Sort by
0
Iliana Dyankova
Telerik team
answered on 29 Jun 2016, 11:45 AM
Hi Geroj,

The issue is caused by there is a different number of points in each of the groups - in this case you need to use series.categoryField instead of categoryAxis.field (documentation link). For your convenience below is an updated example: 
http://dojo.telerik.com/@Iliana/oQoFo

Regards,
Iliana Nikolova
Telerik
 
Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
 
Tags
Charts
Asked by
Geroj
Top achievements
Rank 1
Answers by
Iliana Dyankova
Telerik team
Share this question
or