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

JSON chart

6 Answers 563 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Mattias
Top achievements
Rank 1
Mattias asked on 29 Sep 2011, 10:03 AM
Hi, Im trying to bind a chart with json, but I cant get it to work.
Here is how the json looks like.

{"d":{"__type":"test.PersonSearchSummary","TotalSearches":300,"Hits":250,"Alternates":30,"Misses":20}}

Here is how i try to create the chart

function createChart() {
                    $("#chart").kendoChart({
                        theme: "kendo",
                        title: {
                            text: "Internet Users"
                        },
                        legend: {
                            position: "bottom"
                        },
                        seriesDefaults: {
                            type: "column",
                            stack: true
 
                        },
                        dataSource: {
                            transport: {
                            read: {
                            type: "POST",
                                contentType: "application/json; charset=utf-8",
                                url: "Default.aspx/GetPersonSearchData",
                                    dataType: "json"
                                }
                            }
                        },
 
                        series: [{
                            name: "PersonSearch",
                            field: "TotalSearches"
                            
                        }, {
                            name: "United States",
                            field: "Hits"
                            
}],
                            valueAxis: {
                            majorUnit: 1000
 
                            },
                            categoryAxis: {
                            field: "test.PersonSearchSummary"
                            },
                            tooltip: {
                                visible: true,
                                format: "{0}%"
                            }
                        });
                    }
 
                    $(document).ready(function() {
                        createChart();
 
                        $(document).bind("kendo:skinChange", function(e) {
                            createChart();
                        });
                    });

6 Answers, 1 is accepted

Sort by
0
Hristo Germanov
Telerik team
answered on 04 Oct 2011, 11:34 AM
Hi Mattias,

Thank you for contacting us.

The problem is fixed and the fix will be included with next official release of Kendo UI.

Greetings,
Hristo Germanov
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
raj
Top achievements
Rank 1
answered on 18 Oct 2011, 07:11 AM

Hi
    Im facing the issue as mentioned..

I used jQuery.getJSON("ControllerName/MethodName",function (data){

$("#projectStateChart").kendoChart({
        theme: "black",
        title: { text: "" },
        legend: { position: "right" },
        dataSource: { data: ds.SummaryDataSource },
        series: [{ type: "pie", field: "Count", categoryField: "State", startAngle: 160, padding: 0 }]
    }).data("kendoChart");

}

In my controller method i have
Public ActionResult MethodName()
{
return JSON(ModelClass.MyData);

}


The controller method gets fired but i don see any graph coming up..

Please help Telerik Team
0
Dimo
Telerik team
answered on 18 Oct 2011, 09:23 AM
Hello Raj,

It is not clear what ds.SummaryDataSource is. Have you debugged your code? Have you checked our demos that show how to bind a Kendo Chart to a remote datasource using JSON?

http://demos.telerik.com/kendo-ui/dataviz/bar-charts/remote-data.html

http://docs.telerik.com/kendo-ui/getting-started/dataviz/chart/data-binding#binding-to-remote-data

Regards,
Dimo
the Telerik team
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
raj
Top achievements
Rank 1
answered on 18 Oct 2011, 10:40 AM
Hi
      Thank you for the reply.. Got resolved by deleting the data.summarydatasource and replacing with data..
One more mistake was returning
Json(ModelClass.BusinessDetailsNOP.NOPYTD(yrs) instead of

Json(ModelClass.BusinessDetailsNOP.NOPYTD(yrs), JsonRequestBehavior.AllowGet);
0
WarriorJorge
Top achievements
Rank 1
answered on 06 Apr 2014, 03:39 PM
BTW, the first link is not working - 404
0
Dimo
Telerik team
answered on 07 Apr 2014, 09:02 AM
Hi Jorge,

I updated the links to reflect the pages' current URLs, thank you.

Regards,
Dimo
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Data Source
Asked by
Mattias
Top achievements
Rank 1
Answers by
Hristo Germanov
Telerik team
raj
Top achievements
Rank 1
Dimo
Telerik team
WarriorJorge
Top achievements
Rank 1
Share this question
or