JSON format for multiple series

6 posts, 0 answers
  1. Brian
    Brian avatar
    10 posts
    Member since:
    Nov 2010

    Posted 09 Jan 2012 Link to this post

    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.
  2. Brian
    Brian avatar
    10 posts
    Member since:
    Nov 2010

    Posted 10 Jan 2012 Link to this post

    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.
  3. Brian
    Brian avatar
    10 posts
    Member since:
    Nov 2010

    Posted 10 Jan 2012 Link to this post

    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?
  4. T. Tsonev
    Admin
    T. Tsonev avatar
    2815 posts

    Posted 12 Jan 2012 Link to this post

    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!
  5. Mike
    Mike avatar
    21 posts
    Member since:
    Mar 2012

    Posted 24 Jul 2012 Link to this post

    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!

  6. Mike
    Mike avatar
    21 posts
    Member since:
    Mar 2012

    Posted 24 Jul 2012 Link to this post

      
Back to Top