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 1578 - Area series cannot handle stacked positive and negatiove values properly
Summary: Area series cannot handle stacked positive and negatiove values properly
Status: CONFIRMED
Alias: None
Product: VCL TeeChart
Classification: Unclassified
Component: Series (show other bugs)
Version: 150901
Hardware: PC Windows
: High major
Target Milestone: ---
Assignee: Steema Issue Manager
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-07-14 05:04 EDT by h.hasenack
Modified: 2016-07-14 05:14 EDT (History)
1 user (show)

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


Attachments
The unpatched result (nitice yellow series drawon over green seirs, making values of green series impossible to analyse (98.55 KB, image/jpeg)
2016-07-14 05:09 EDT, h.hasenack
Details
Patch installed. crossing x axis still ugly but at leas values are displayed correctly (111.95 KB, image/jpeg)
2016-07-14 05:10 EDT, h.hasenack
Details

Note You need to log in before you can comment on or make changes to this bug.
Description h.hasenack 2016-07-14 05:04:22 EDT
When using a stacked areas, with mixed positive and negative values the areas are rendered in a very confusing way. Check the attached screenshots for with and without my patch.

the patched version is onlu "ugly" when the value crosses the x-axis, the unpatched version is ugly and dead wrong.
Comment 1 h.hasenack 2016-07-14 05:09:50 EDT
Created attachment 617 [details]
The unpatched result (nitice yellow series drawon over green seirs, making values of green series impossible to analyse
Comment 2 h.hasenack 2016-07-14 05:10:41 EDT
Created attachment 618 [details]
Patch installed. crossing x axis still ugly but at leas values are displayed correctly
Comment 3 h.hasenack 2016-07-14 05:14:25 EDT
Patches applied to series.pas (using condition compiling for HH_PATCH_TC_STACKEDAREA)

interface
....
  TCustomSeries=class(TCustomLineSeries)
....
    Function PointOrigin(ValueIndex:Integer; SumAll:Boolean):Double;  {$ifdef HH_PATCH_TC_STACKEDAREA} virtual; {$endif}
....


  TAreaSeries=Class(TCustomSeries)
....
{$IFDEF HH_PATCH_TC_STACKEDAREA}
    Function PointOrigin(ValueIndex:Integer; SumAll:Boolean):Double; override;
{$ENDIF}  public
....

implementation

....

{$ifdef HH_PATCH_TC_STACKEDAREA}
// negative values are wrongly stacked in the original code. This overriden
// function calculates the correct origin value for each datapoint
Function TAreaSeries.PointOrigin(ValueIndex:Integer; 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;
{$ENDIF}