AjaxToolkit Version: 4.1.7.123
Using IE9.
When populating the PieChart via code if a segment covers more than approx 50% then it isn't displayed correctly.
Code:
string[] surveyItems = new string[3] { "Yes", "No", "Don't Know" };
int[] surveyAnswers = new int[3] { 1, 5, 1 };
for (int i = 0; i < 3; i++)
{
PieChartValue pcv = new PieChartValue();
pcv.Category = surveyItems[i].ToString();
pcv.Data = surveyAnswers[i];
PieChart1.PieChartValues.Add(pcv);
}
This issue can also be replicated by 'hardcoding' the values in the aspx page.
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<asp:PieChart ID="PieChart1" runat="server">
<PieChartValues>
<asp:PieChartValue Category="Yes" Data="1" PieChartValueColor=""
PieChartValueStrokeColor="" />
<asp:PieChartValue Category="No" Data="5" PieChartValueColor=""
PieChartValueStrokeColor="" />
<asp:PieChartValue Category="Don't Know" Data="1" PieChartValueColor=""
PieChartValueStrokeColor="" />
</PieChartValues>
</asp:PieChart>
Comments: I too am having an issue with this. I did create a workaround that works pie charts with 2 or more data points. And then I created a PNG that I put in a hidden div tag and positioned over the chart graphic for when there is only 1 data point. I named it 'onereason' (because my pie chart is for reasons for a problem). I created a label called lblFixPieChart that I write to from the codebehind. here is the CSHARP code: lblFixPieChart.Text = "<script>function fixPieChart() {"; // by default, the data points are named Segment1, Segment2, etc. int segmentCounter = 1; // reasonLate is a class I have that has the number of times late and a reason code (you would of course use your source for data points foreach (reasonLate ckReason in reasonsLate) { totalresults.PieChartValues.Add(new AjaxControlToolkit.PieChartValue { Category = ckReason.reasonCode, Data = ckReason.numberCases }); if (reasonsLate.Count > 1) { // lateJobsList is the list of late jobs - used to see if this data point is > 50% of the Pie if (ckReason.numberCases > System.Convert.ToDecimal(lateJobsList.Count) / 2) { // this is where I change the 0 0 to 0 1 to fix it lblFixPieChart.Text += "$('#Segment" + segmentCounter.ToString() + "').attr('d', $('#Segment" + segmentCounter.ToString() + "').attr('d').replace(' 0 0,', ' 0 1,'));"; } } else { // show my fake one piece of pie chart lblFixPieChart.Text += "$('#onereason').show();"; } segmentCounter++; } lblFixPieChart.Text += "}</script>"; You then also have to have this in your aspx page: $(document).ready(function () { setTimeout(fixPieChart, 1000); }); Because the SVG has not been rendered until after document.ready
Using IE9.
When populating the PieChart via code if a segment covers more than approx 50% then it isn't displayed correctly.
Code:
string[] surveyItems = new string[3] { "Yes", "No", "Don't Know" };
int[] surveyAnswers = new int[3] { 1, 5, 1 };
for (int i = 0; i < 3; i++)
{
PieChartValue pcv = new PieChartValue();
pcv.Category = surveyItems[i].ToString();
pcv.Data = surveyAnswers[i];
PieChart1.PieChartValues.Add(pcv);
}
This issue can also be replicated by 'hardcoding' the values in the aspx page.
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<asp:PieChart ID="PieChart1" runat="server">
<PieChartValues>
<asp:PieChartValue Category="Yes" Data="1" PieChartValueColor=""
PieChartValueStrokeColor="" />
<asp:PieChartValue Category="No" Data="5" PieChartValueColor=""
PieChartValueStrokeColor="" />
<asp:PieChartValue Category="Don't Know" Data="1" PieChartValueColor=""
PieChartValueStrokeColor="" />
</PieChartValues>
</asp:PieChart>
Comments: I too am having an issue with this. I did create a workaround that works pie charts with 2 or more data points. And then I created a PNG that I put in a hidden div tag and positioned over the chart graphic for when there is only 1 data point. I named it 'onereason' (because my pie chart is for reasons for a problem). I created a label called lblFixPieChart that I write to from the codebehind. here is the CSHARP code: lblFixPieChart.Text = "<script>function fixPieChart() {"; // by default, the data points are named Segment1, Segment2, etc. int segmentCounter = 1; // reasonLate is a class I have that has the number of times late and a reason code (you would of course use your source for data points foreach (reasonLate ckReason in reasonsLate) { totalresults.PieChartValues.Add(new AjaxControlToolkit.PieChartValue { Category = ckReason.reasonCode, Data = ckReason.numberCases }); if (reasonsLate.Count > 1) { // lateJobsList is the list of late jobs - used to see if this data point is > 50% of the Pie if (ckReason.numberCases > System.Convert.ToDecimal(lateJobsList.Count) / 2) { // this is where I change the 0 0 to 0 1 to fix it lblFixPieChart.Text += "$('#Segment" + segmentCounter.ToString() + "').attr('d', $('#Segment" + segmentCounter.ToString() + "').attr('d').replace(' 0 0,', ' 0 1,'));"; } } else { // show my fake one piece of pie chart lblFixPieChart.Text += "$('#onereason').show();"; } segmentCounter++; } lblFixPieChart.Text += "}</script>"; You then also have to have this in your aspx page: $(document).ready(function () { setTimeout(fixPieChart, 1000); }); Because the SVG has not been rendered until after document.ready