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

Pie Chart does not render correctly when updating DataSource

4 Answers 374 Views
Charts
This is a migrated thread and some comments may be shown as answers.
Gergo
Top achievements
Rank 1
Gergo asked on 03 Apr 2012, 10:19 AM
Hi All,

I have a problem with the DataViz Pie Chart.

Here is the idea: I have a global variable where I store key/value pairs. Keys represent the id of the div where the chart will be rendered and the value is the array for the dataSource.

Example: 
['chart1' : [ { category :"Category1", value:"value1", color: "#BBBBBB" }....]

here I have the configuration for the chart and the creation of DataSource:

var newDataSource = new kendo.data.DataSource({ data: GLOBAL_ALL_PIE_DATA[controlID] });
 
 var chartConfiguration = {
                theme: $(control).attr("theme"),
                title: { text: $(control).attr("title") },
                legend: {
                    position: $(control).attr("position")
                },
                seriesDefaults: {
                    labels: {
                        visible: $(control).attr("showLabels"),
                        format: "{0}%"
                    }
                },
                dataSource: newDataSource,
                series: [{
                    type: "pie",
                    categoryField: "category",
                    field: "value",
                    colorField: "color"
                }],
                tooltip: {
                    visible: $(control).attr("showTooltip"),
                    format: "{0}%"
                }
            };
 
            //create the chart
            $(jqControlID).kendoChart(chartConfiguration);
       }
    }
}

First time the Chart is rendered correctly.

When I want to update the datasource (let's say I create a new Instance of kendo.data.DataSource  or I use the add(model) method of the datasource) the chart loads as seen on the attached picture. After updating the datasource or using the add method am using the refresh() method of the chart to redraw.

I am pretty sure that I am not doing something ok with the datasources, but I can't figure it out.

Thanks in advance,
Gergő

4 Answers, 1 is accepted

Sort by
0
Hristo Germanov
Telerik team
answered on 06 Apr 2012, 08:33 AM
Hi Gergo,

Thank you for contacting us.

Can you try to pass a number instead of a string value of the pie chart?

All the best,
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
Gergo
Top achievements
Rank 1
answered on 20 Apr 2012, 08:05 PM
Hi Hristo,

First of all, thank you very much for the reply.
I've changed my code.
Currently I am using a kendo model with the datasource, where the type of the mapped field is number. The error still persists. I am adding the new objects to the datasource, and I am using the datasource.sync() method to update the chart. The same happens when adding new elements to the datasource.
The strange thing is, the error only appears when adding elements to the datasource. When removing elements from datasource the chart is re-rendered correctly.
 
Do you have any extra ideas ?

Thanks in advance,
Gergő
0
Accepted
Hristo Germanov
Telerik team
answered on 25 Apr 2012, 09:14 AM
Hello Gergo,

I can't reproduce the issue. I tried this and I can't see any problems. What is different in your case?

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
Gergo
Top achievements
Rank 1
answered on 25 Apr 2012, 11:28 AM
Hi Hristo,

Thank you very much for the sample. I figured out the problem. I had one piece of code unchanged and I tried to add string value to the dataSource in the field which displays the values.

All the best,
Gergő
Tags
Charts
Asked by
Gergo
Top achievements
Rank 1
Answers by
Hristo Germanov
Telerik team
Gergo
Top achievements
Rank 1
Share this question
or