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

JSON format for multiple series

5 Answers 247 Views
Charts
This is a migrated thread and some comments may be shown as answers.
Brian
Top achievements
Rank 1
Brian asked on 10 Jan 2012, 03:45 AM
How can I get the line chart to accept JSON with this format?

{
    "apps": [
        { "Name": "One", "Data": [8, 4, 10, 15, 6, 2, 7, 12, 10, 11, 5, 9] },
        { "Name": "Two", "Data": [7, 17, 9, 10, 7, 5, 15, 16, 7, 16, 5, 1] },
        { "Name": "Three", "Data": [18, 9, 8, 17, 13, 3, 11, 3, 8, 1, 5, 2] },
        { "Name": "Four", "Data": [5, 19, 7, 13, 8, 5, 19, 11, 2, 3, 16, 1] },
        { "Name": "Five", "Data": [5, 5, 9, 4, 14, 11, 5, 17, 6, 15, 14, 7] }, 
        { "Name": "Six", "Data": [13, 17, 18, 4, 19, 0, 8, 11, 2, 4, 9, 13] }
    ],
    "labels": [ "0:00", "1:00", "2:00", "3:00", "4:00", "5:00", "6:00", "7:00", "8:00", "9:00", "10:00", "11:00" ]
}

I'm not seeing how to transform the data from what I've got to what the Kendo line chart accepts. In fact, I don't really see any documentation on what the Kendo charts accept for data other than a demo that doesn't actually show the format of the data (I had to figure out the url to the JSON datasource).

I do have something working in jsfiddle (http://jsfiddle.net/472Xr/2/), but that doesn't seem like a workable solution for a remote data source that can be updated on the client.

5 Answers, 1 is accepted

Sort by
0
Brian
Top achievements
Rank 1
answered on 11 Jan 2012, 02:48 AM
One thing I forgot to mention, The series are dynamic ("One", "Two", etc) as well as the categories ("0:00", "1:00", etc). I need the chart to be able to fully refresh itself whenever it gets new data.
0
Brian
Top achievements
Rank 1
answered on 11 Jan 2012, 03:21 AM
Ok, I seem to have figured out something that works. http://jsfiddle.net/472Xr/8/ 

Can somebody from Telerik confirm that it is the best solution available?
0
T. Tsonev
Telerik team
answered on 12 Jan 2012, 04:36 PM
Hi,

Thank you for your feedback. We'll try to improve the demos and make the source data visible. As a token of gratitude for your involvement your Telerik points have been updated.

Your approach of transforming the data to dynamic series is perfectly valid. 

Kind regards,
Tsvetomir Tsonev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Mike
Top achievements
Rank 1
answered on 24 Jul 2012, 04:33 PM
Hey Brian, I tried using the code you posted on jsFiddle, and got the following error on the "For" loop:

TypeError: 'undefined' is not an object (evaluating 'data.apps.length')

Basically the chart sets up, and displays "Loading...", but no data appears.

Any insight would be greatly appreciated.

Thanks!

0
Mike
Top achievements
Rank 1
answered on 24 Jul 2012, 04:33 PM
  
Tags
Charts
Asked by
Brian
Top achievements
Rank 1
Answers by
Brian
Top achievements
Rank 1
T. Tsonev
Telerik team
Mike
Top achievements
Rank 1
Share this question
or