Page 1 of 1
Pie chart - other slice
Posted: Tue Nov 17, 2009 6:53 pm
by 14045174
This is another problem with logic embedded into paint events. I have a pie chart and I am using OtherSlice feature. The chart is saved into a file and I am reading this file and creating the chart in memory. But until the chart is actually drawn on the screen (which I am not even planning to do) the OtherSlice is not created and the pie even has no idea which slices will fall into it! That makes it impossible for me to create the chart I need. Also, when I need to save my chart, I need to turn off the OtherSlice and I am running into the same problem again - without actually drawing the chart it still thinks that some of the slices belong to OtherSlice (even though it's style is None by then!)
Re: Pie chart - other slice
Posted: Wed Nov 18, 2009 11:10 am
by 10050769
Hello UserLs,
I couldn't reproduce your problem using following code with version3 of TeeChart .Net. Please, check previous project works as you want.
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
private Steema.TeeChart.Styles.Pie pie1;
private Steema.TeeChart.TChart tChart2;
private void InitializeChart()
{
tChart2 = new Steema.TeeChart.TChart();
pie1 = new Steema.TeeChart.Styles.Pie(tChart2.Chart);
pie1.FillSampleValues();
pie1.OtherSlice.Style = Steema.TeeChart.Styles.PieOtherStyles.BelowPercent;
pie1.OtherSlice.Value = 10;
pie1.OtherSlice.Legend.Visible = true;
pie1.OtherSlice.Legend.Left = tChart2.Legend.Left;
pie1.OtherSlice.Legend.Top = tChart2.Legend.Bottom;
tChart2.Export.Template.Save("c:\\tChart.ten");
}
private void button1_Click(object sender, EventArgs e)
{
tChart1.Import.Template.Load("c:\\tChart.ten");
}
If previous project doesn’t work as you want, I suggest modifying this simple project, because we can reproduce the issue here.
Thanks,
Re: Pie chart - other slice
Posted: Wed Nov 18, 2009 6:36 pm
by 14045174
Here is the code, you can run to see the problem:
Code: Select all
var chart = new TChart();
var pie = new Pie(chart.Chart);
pie.FillSampleValues();
pie.OtherSlice.Style = PieOtherStyles.BelowPercent;
pie.OtherSlice.Value = 30;
var allSlices = "";
var visibleSlices = "";
for (var idx = 0; idx < pie.PieValues.Count; idx++)
{
allSlices = allSlices + "\r\n" + pie.PieValues[idx];
if (!pie.BelongsToOtherSlice(idx))
visibleSlices = visibleSlices + "\r\n" + pie.PieValues[idx];
}
MessageBox.Show(String.Format("The two lists should be different:\r\n{0}\r\n\r\n{1}",
allSlices, visibleSlices));
Re: Pie chart - other slice
Posted: Thu Nov 19, 2009 10:08 am
by 10050769
Hello UserLs,
I could reproduce your issue with version 3 of TeeChart .Net. I have been investigatin and I found that BelongToOtherSlice need to draw Chart(chart.Draw()),otherwise you will not run the internal method DoBeforeDrawChart() and BelongToOtherSlice will not be updated. I recommend using workaround chart.Draw(), as do in next code:
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
private Steema.TeeChart.Styles.Pie pie;
private Steema.TeeChart.TChart chart;
private void InitializeChart()
{
var chart = new Steema.TeeChart.TChart();
var pie = new Steema.TeeChart.Styles.Pie(chart.Chart);
pie.Add(20);
pie.Add(15);
pie.Add(12);
pie.Add(18);
pie.Add(5);
pie.Add(8);
pie.Add(7);
pie.Add(15);
pie.OtherSlice.Style = Steema.TeeChart.Styles.PieOtherStyles.BelowPercent;
pie.OtherSlice.Value = 10;
chart.Draw();
var allSlices = "";
var visibleSlices = "";
for (var idx = 0; idx < pie.Count; idx++)
{
allSlices = allSlices + "\r\n" + pie.PieValues[idx];
if (!pie.BelongsToOtherSlice(idx))
visibleSlices = visibleSlices + "\r\n" + pie.PieValues[idx];
}
MessageBox.Show(String.Format("The two lists should be different:\r\n{0}\r\n\r\n{1}",
allSlices, visibleSlices));
}
You can see in the code above that is painted internally, because project works fine.
On the other hand, I have added your enhancement request to the wish-list to be considered for inclusion in future.
I hope will helps.
Thanks,
Re: Pie chart - other slice
Posted: Thu Nov 19, 2009 2:34 pm
by 14045174
The problem with calling Draw() event is that under some versions of Windows it does nothing unless you are actually showing a form on your screen (not even outside of the screen boundaries), which is not an option for me.
Re: Pie chart - other slice
Posted: Mon Nov 23, 2009 10:49 am
by 10050769
Hello UserLs,
The problem with calling Draw() event is that under some versions of Windows it does nothing unless you are actually showing a form on your screen (not even outside of the screen boundaries), which is not an option for me.
Please could you tell us under what versions of Windows you are experiencing the problems. We are not aware of the limitations you describe and would like to be able to reproduce them here to help find a solution.
Thanks,