How to read Json data in Kendo Chart (Pie Charts)
1 Answer 17 Views
Stark
Top achievements
Rank 1
Iron
Iron
Stark asked on 09 May 2021, 04:36 AM

In demo Pie Chart From kendo https://demos.telerik.com/kendo-ui/pie-charts/index

data: is created manual, but I want to read data from a url of type Json. 

Help me. Thanks.

                    data: [{
                        category: "Asia",
                        value: 53.8,
                        color: "#9de219"
                    },{
                        category: "Europe",
                        value: 16.1,
                        color: "#90cc38"
                    },{
                        category: "Latin America",
                        value: 11.3,
                        color: "#068c35"
                    },{
                        category: "Africa",
                        value: 9.6,
                        color: "#006634"
                    },{
                        category: "Middle East",
                        value: 5.2,
                        color: "#004d38"
                    },{
                        category: "North America",
                        value: 3.6,
                        color: "#033939"
                    }]
    <div id="chart" style="background: center no-repeat url('../content/shared/styles/world-map.png');"></div>
    
    <script>
        function createChart() {
            $("#chart").kendoChart({
                title: {
                    position: "bottom",
                    text: "Share of Internet Population Growth, 2007 - 2012"
                },
                legend: {
                    visible: false
                },
                chartArea: {
                    background: ""
                },
                seriesDefaults: {
                    labels: {
                        visible: true,
                        background: "transparent",
                        template: "#= category #: \n #= value#%"
                    }
                },
                series: [{
                    type: "pie",
                    startAngle: 150,
                    data: [{
                        category: "Asia",
                        value: 53.8,
                        color: "#9de219"
                    },{
                        category: "Europe",
                        value: 16.1,
                        color: "#90cc38"
                    },{
                        category: "Latin America",
                        value: 11.3,
                        color: "#068c35"
                    },{
                        category: "Africa",
                        value: 9.6,
                        color: "#006634"
                    },{
                        category: "Middle East",
                        value: 5.2,
                        color: "#004d38"
                    },{
                        category: "North America",
                        value: 3.6,
                        color: "#033939"
                    }]
                }],
                tooltip: {
                    visible: true,
                    format: "{0}%"
                }
            });
        }

        $(document).ready(createChart);
        $(document).bind("kendo:skinChange", createChart);
    </script>

1 Answer, 1 is accepted

Sort by
0
Georgi Denchev
Telerik team
answered on 11 May 2021, 12:10 PM

Hello, Stark,

Please check the Binding to remote data demo.

The data for the demo is read from the following url:

https://demos.telerik.com/kendo-ui/content/dataviz/js/screen_resolution.json 

Best Regards,
Georgi Denchev
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Asked by
Stark
Top achievements
Rank 1
Iron
Iron
Answers by
Georgi Denchev
Telerik team
Share this question
or