Steema Issues Database

Note: This database is for bugs and wishes only. For technical support help, if you are a customer please visit our online forums;
otherwise you can use StackOverflow.
Before using this bug-tracker we recommend a look at this document, Steema Bug Fixing Policy.



Bug 274 - [TV52016010] A customer suggests a fix: http://www.teechart.net/support/viewtopic...
Summary: [TV52016010] A customer suggests a fix: http://www.teechart.net/support/viewt...
Status: CONFIRMED
Alias: None
Product: VCL TeeChart
Classification: Unclassified
Component: Series (show other bugs)
Version: unspecified
Hardware: All All
: High major
Target Milestone: ---
Assignee: Steema Issue Manager
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-20 18:13 EST by yeray alonso
Modified: 2013-11-20 10:35 EST (History)
0 users

See Also:
Chart Series: ---
Delphi / C++ Builder RAD IDE Version:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description yeray alonso 2013-11-20 10:35:48 EST
A customer suggests a fix:
http://www.teechart.net/support/viewtopic.php?f=3&t=12970&view=unread#unread
This is the code to reproduce the problem:
uses Series;
procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
  Chart1.AddSeries(TAreaSeries);
  Chart1.AddSeries(TAreaSeries);
  for i:=0 to 10 do
  begin
    Chart1[0].Add(-(i-5));
    Chart1[1].Add(i-5);
  end;
  (Chart1[0] as TAreaSeries).MultiArea:=maStacked;
end;
And the customer suggestion consists on adding an override for the PointOrigin function in TAreaSeries (Series.pas):
    Function PointOrigin(ValueIndex:Longint; SumAll:Boolean):Double; override;
// negative values are wrongly stacked in the original code. This overriden
// function calculates the correct origin value for each datapoint
Function TAreaSeries.PointOrigin(ValueIndex:Longint; SumAll:Boolean):Double;
   Function LocalPointOrigin:Double;
   var t         : Longint;
       tmpSeries : TChartSeries;
       val:double;
       sumneg,sumpos:boolean;
   Begin
     result:=0;
     // first of determine wheter we have to sum negative or positive values
     val:=MandatoryValueList[ValueIndex];
     sumneg:=val<0;
     sumpos:=val>=0;
     if Assigned(ParentChart) then with ParentChart do
     begin
       if SumPos then
       begin
         for t:=0 to SeriesList.Count-1 do
         Begin
           tmpSeries:=Series[t];
           if (not SumAll) and (tmpSeries=Self) then
             Break
           else
           With tmpSeries do
           if Active and SameClass(Self) and (tmpSeries.Count>ValueIndex) then
           begin
             val:=GetOriginValue(ValueIndex);
             if (val>=0.0) and sumpos then
               result:=result+val
           end;
         end
       end
       else if SumNeg then
       begin
         for t:=0 to SeriesList.Count-1 do
         Begin
           tmpSeries:=Series[t];
           if (not SumAll) and (tmpSeries=Self) then
             Break
           else
           With tmpSeries do
           if Active and SameClass(Self) and (tmpSeries.Count>ValueIndex) then
           begin
             val:=GetOriginValue(ValueIndex);
             if (val<0.0) then
               result:=result+val
           end;
         end;
       end
     end;
   end;
Begin
  if MultiArea in [maStacked,maStacked100] then
    result:=LocalPointOrigin
  else result:=inherited PointOrigin(ValueIndex,SumAll);
End; [created:2012-01-20T18:13:32.000+01:00 reported by:yeray@steema.com reported in version:2011.04.41118 (TeeChart VCL)]