Show stopper here.
Drop a TChart on a form and add a pie series to it. Make it so that the
marks show the percent value. Then add a value to it in code, such as:
constructor TForm1.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
Series1.Clear;
Series1.Add(100, 'Item #1');
end; // Create
Run it. At least in my copy for the above example it says 'Item #1' is 50%.
--and there is only one pie in the chart. (Different results occur when different number of items are added).
Please let me know how to fix this.
Thanks
Ed Dressel
Pie Chart Bug
Hi, Ed.
Actually, the problem happens with all series. The TotalABS value, used in all series to calculate the percentage is not calculated correctly. The lower limit in the for loop (the TChartValueList.RecalcStats routine) is set to StartIndex. The correct limit should be set at StartIndex+1. Here is the corrected code - the relevant part (will be included in next TeeChart maintenance release):
If you don't have TC source code, then the only solution (for the time being) I can think of is to use the OnGetMarkText eventt to manually recalculate total abs and the percentage for each point.
Actually, the problem happens with all series. The TotalABS value, used in all series to calculate the percentage is not calculated correctly. The lower limit in the for loop (the TChartValueList.RecalcStats routine) is set to StartIndex. The correct limit should be set at StartIndex+1. Here is the corrected code - the relevant part (will be included in next TeeChart maintenance release):
Code: Select all
if Count>0 then
begin
if StartIndex=0 then
begin
tmpValue:=Value[0];
FMinValue:=tmpValue;
FMaxValue:=tmpValue;
FTotal:=tmpValue;
FTotalABS:=Abs(tmpValue);
end;
for t:=StartIndex+1 to Count-1 do // MS : 7.01 fix
Begin
tmpValue:=Value[t];
if tmpValue<FMinValue then FMinValue:=tmpValue else
if tmpValue>FMaxValue then FMaxValue:=tmpValue;
FTotal:=FTotal+tmpValue;
FTotalABS:=FTotalABS+Abs(tmpValue);
end;
end;
If you don't have TC source code, then the only solution (for the time being) I can think of is to use the OnGetMarkText eventt to manually recalculate total abs and the percentage for each point.
Marjan Slatinek,
http://www.steema.com
http://www.steema.com
Incomplete Pie Chart
All my Pie Charts are incomplete, always a slice missing. I assume this problem is related to the problem you describe.
I do not have source code and consider this to be a very serious problem. When is the ETA for the next maintance release?
The quicky solution I am testing at the moment is to do
series->Add(0, "");
before I start adding the real Points.
I could not work out how to do your "OnGetMarkText event" solution.
Could you elaborate?
Thanks
Chris Durkin
I do not have source code and consider this to be a very serious problem. When is the ETA for the next maintance release?
The quicky solution I am testing at the moment is to do
series->Add(0, "");
before I start adding the real Points.
I could not work out how to do your "OnGetMarkText event" solution.
Could you elaborate?
Thanks
Chris Durkin
Hi, Chris.
A fair estimate puts the release date within next month.When is the ETA for the next maintance release
Sure, no problem. Basically, you can use the OnGetMarkText event to calculate each slice percentage (by dividing 100 * current value with calculated sum and then transforming it to string). Something along these lines:Could you elaborate?
Code: Select all
procedure TForm1.Series1GetMarkText(Sender: TChartSeries;
ValueIndex: Integer; var MarkText: String);
var sum, pct: double;
i: integer;
begin
// step 1 : calculate correct sum
sum := 0.0;
for i := 0 to Sender.Count - 1 do sum := sum + Abs(Sender.YValue[i]);
// step 2 : calc percentage
pct := 100*Sender.YValue[ValueIndex]/sum;
// step 3 : transform to string
MarkText := FormatFloat('0.00 %',pct);
end;
Marjan Slatinek,
http://www.steema.com
http://www.steema.com
-
- Advanced
- Posts: 103
- Joined: Tue Mar 02, 2004 5:00 am
- Location: Bad Wurzach
- Contact:
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi ungos,
As Marjan's message was posted on 7th June 2004 I'd say that at least from v7.02 this fix is inlcuded and I'm not sure if it already was in v7.01. However current TeeChart version is v7.04. Right-clicking on a TChart in a form and selecting about should give you the exact version number.
If you don't have the latest version available you can download it from our customer download area.
As Marjan's message was posted on 7th June 2004 I'd say that at least from v7.02 this fix is inlcuded and I'm not sure if it already was in v7.01. However current TeeChart version is v7.04. Right-clicking on a TChart in a form and selecting about should give you the exact version number.
If you don't have the latest version available you can download it from our customer download area.
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |