JeeShen Lee
JeeShen Lee

Reputation: 3816

How to bind json data to KendoUI Chart

In the example provided on KendoUI Demo site, it's Chart is binded to the json data of these format:

[ { "Booked" : 0,
    "Date" : "/Date(1370620800000)/",
    "FailedAttempts" : 0,
    "Views" : 0
  },
  { "Booked" : 0,
    "Date" : "/Date(1370707200000)/",
    "FailedAttempts" : 0,
    "Views" : 0
  }]

but what if the server return in this format:

    { "AggregateResults" : null, "Data" : [ { "Booked" : 0,
    "Date" : "/Date(1370620800000)/",
    "FailedAttempts" : 0,
    "Views" : 0
  },
  { "Booked" : 0,
    "Date" : "/Date(1370707200000)/",
    "FailedAttempts" : 0,
    "Views" : 0
  },]

}

How do i set the KendoUI Chart to bind to the "Data" node?

Upvotes: 1

Views: 1960

Answers (1)

OnaBai
OnaBai

Reputation: 40897

Define in you DataSource definition, define shema.data as "Data".

$("#chart").kendoChart({
    dataSource: {
        transport: {
            read: {
               ...
            }
        },
        schema : {
            data: "Data"
        }
    },

Upvotes: 2

Related Questions