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

Bind to Json Data without service

0 Answers 117 Views
Charts
This is a migrated thread and some comments may be shown as answers.
Felipe
Top achievements
Rank 1
Felipe asked on 18 May 2012, 12:20 AM
Hello:

I have a property in my CodeBehind that return JSON data:

public string EventTypeCount
{
    get
    {
        JavaScriptSerializer js = new JavaScriptSerializer();
        return js.Serialize((List<EventTypeCount>)obj);
    }
    set { ViewState["EventTypeCount"] = value; }
}

obj actually contains data and the serialization works ok, the problem is that I don't know how to tell the kendo ui chart to use this datasource. Right now I'm trying this the following, the dataEvent var actually recieves the Json String but I don't know how to tell the chart to understand that datasource. If I use a Handler that uses the transport property to make the request everything works ok, but I need this approach.

Thanks for any help.

Code:

function createChartEvents() {
                var dataEvent = '<%= EventTypeCount %>';
                $("#chartEvents").kendoChart({
                    theme: "metro",
                    dataSource: {
                        data: dataEvent,
                        dataType: "json"
                    },
                    title: {
                        text: "Estudios"
                    },
                    legend: {
                        position: "bottom"
                    },
                    seriesDefaults: {
                        type: "column",
                        labels: {
                            visible: true
                        }
                    },
                    series: [{
                        field: "CountMade",
                        name: "Eventos Finalizados"
                    }, {
                        field: "CountUnmade",
                        name: "Eventos Pendientes"
                    }, {
                        field: "CountCanceled",
                        name: "Eventos Cancelados"
                    }],
                    categoryAxis: {
                        field: "EventTypeName"
                    },
                    dataBound: onDataBound,
                });
            }

No answers yet. Maybe you can help?

Tags
Charts
Asked by
Felipe
Top achievements
Rank 1
Share this question
or