View Issue Details

IDProjectCategoryView StatusLast Update
0035025LazarusTAChartpublic2019-02-08 22:42
ReporterMarcin WiazowskiAssigned Towp 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version2.1 (SVN)Product Build60350 
Target Version2.0.2Fixed in Version 
Summary0035025: TAChart: potential improvement for marks' direction
DescriptionCurrently, for series having ZeroLevel (like bar series), when MarkPositions = lmpInside / lmpOutside, data points having their Y = ZeroLevel receive mark's direction arbitrarily set towards +INF (lmpOutside) or -INF (lmpInside).

I successfully modified the code, so in this case mark's direction is calculated by using average level of all data points - exactly as it is now for series not having ZeroLevel (like line series).

Only in case when it still doesn't help (i.e. when Y = average level of all data points), the current arbitrary behavior is used.


Regards
TagsNo tags attached.
Fixed in Revision60352, r60366
LazTarget2.0.2
WidgetsetWin32/Win64
Attached Files
  • test.diff (1,718 bytes)
    Index: components/tachart/tacustomseries.pas
    ===================================================================
    --- components/tachart/tacustomseries.pas	(revision 60350)
    +++ components/tachart/tacustomseries.pas	(working copy)
    @@ -1424,19 +1424,42 @@
       isNeg: Boolean;
       ref: Double;
     begin
    -  if FSupportsZeroLevel then
    -    ref := GetZeroLevel
    -  else
    -    with Extent do
    -      if IsRotated then
    -        ref := (b.x + a.x) / 2
    -      else
    -        ref := (b.y + a.y) / 2;
       case MarkPositions of
    -    lmpOutside: isNeg := Source[AIndex]^.Y < ref;
         lmpPositive: isNeg := false;
         lmpNegative: isNeg := true;
    -    lmpInside: isNeg := Source[AIndex]^.Y >= ref;
    +    lmpOutside,
    +    lmpInside :
    +      begin
    +        if FSupportsZeroLevel then
    +          ref := GetZeroLevel
    +        else
    +          with Extent do
    +            if IsRotated then
    +              ref := (b.x + a.x) * 0.5
    +            else
    +              ref := (b.y + a.y) * 0.5;
    +
    +        if Source[AIndex]^.Y < ref then
    +          isNeg := true
    +        else
    +        if Source[AIndex]^.Y > ref then
    +          isNeg := false
    +        else
    +        if not FSupportsZeroLevel then
    +          isNeg := false // for Y = ref, we arbitrarily set "false"
    +        else begin
    +          with Extent do
    +            if IsRotated then
    +              ref := (b.x + a.x) * 0.5
    +            else
    +              ref := (b.y + a.y) * 0.5;
    +
    +          isNeg := Source[AIndex]^.Y < ref; // for Y = ref, we arbitrarily set "false"
    +        end;
    +
    +        if MarkPositions = lmpInside then
    +          isNeg := not isNeg;
    +      end;
       end;
       if Assigned(GetAxisY) then
         if (IsRotated and ParentChart.IsRightToLeft) xor GetAxisY.Inverted then
    
    test.diff (1,718 bytes)
  • Reproduce.zip (3,397 bytes)
  • Reproduce.png (36,992 bytes)
    Reproduce.png (36,992 bytes)

Activities

Marcin Wiazowski

2019-02-06 20:38

reporter  

test.diff (1,718 bytes)
Index: components/tachart/tacustomseries.pas
===================================================================
--- components/tachart/tacustomseries.pas	(revision 60350)
+++ components/tachart/tacustomseries.pas	(working copy)
@@ -1424,19 +1424,42 @@
   isNeg: Boolean;
   ref: Double;
 begin
-  if FSupportsZeroLevel then
-    ref := GetZeroLevel
-  else
-    with Extent do
-      if IsRotated then
-        ref := (b.x + a.x) / 2
-      else
-        ref := (b.y + a.y) / 2;
   case MarkPositions of
-    lmpOutside: isNeg := Source[AIndex]^.Y < ref;
     lmpPositive: isNeg := false;
     lmpNegative: isNeg := true;
-    lmpInside: isNeg := Source[AIndex]^.Y >= ref;
+    lmpOutside,
+    lmpInside :
+      begin
+        if FSupportsZeroLevel then
+          ref := GetZeroLevel
+        else
+          with Extent do
+            if IsRotated then
+              ref := (b.x + a.x) * 0.5
+            else
+              ref := (b.y + a.y) * 0.5;
+
+        if Source[AIndex]^.Y < ref then
+          isNeg := true
+        else
+        if Source[AIndex]^.Y > ref then
+          isNeg := false
+        else
+        if not FSupportsZeroLevel then
+          isNeg := false // for Y = ref, we arbitrarily set "false"
+        else begin
+          with Extent do
+            if IsRotated then
+              ref := (b.x + a.x) * 0.5
+            else
+              ref := (b.y + a.y) * 0.5;
+
+          isNeg := Source[AIndex]^.Y < ref; // for Y = ref, we arbitrarily set "false"
+        end;
+
+        if MarkPositions = lmpInside then
+          isNeg := not isNeg;
+      end;
   end;
   if Assigned(GetAxisY) then
     if (IsRotated and ParentChart.IsRightToLeft) xor GetAxisY.Inverted then
test.diff (1,718 bytes)

Marcin Wiazowski

2019-02-06 20:38

reporter  

Reproduce.zip (3,397 bytes)

Marcin Wiazowski

2019-02-06 20:38

reporter  

Reproduce.png (36,992 bytes)
Reproduce.png (36,992 bytes)

wp

2019-02-07 00:09

developer   ~0113912

Applied with minor modifications. Test and close if ok.

Marcin Wiazowski

2019-02-07 01:44

reporter   ~0113916

Works as expected - thanks.



I just found some (unrelated?), minor issue when comparing the just-modified code:

function TBarSeries.Extent: TDoubleRect;
...
begin
  Result := inherited Extent;
  if IsEmpty then exit; <==== EXIT IF EMPTY
  if BarWidthStyle = bwPercentMin then
    UpdateMinXRange;
  if not IsEmpty and UseZeroLevel then <==== CALL TO "IsEmpty" MADE ONCE AGAIN

wp

2019-02-08 22:36

developer   ~0113957

The blindness after copy & paste... Fixed in r60366 along with some other stupid code. Thank you.

Marcin Wiazowski

2019-02-08 22:42

reporter   ~0113958

Thanks, fixed!

Issue History

Date Modified Username Field Change
2019-02-06 20:38 Marcin Wiazowski New Issue
2019-02-06 20:38 Marcin Wiazowski File Added: test.diff
2019-02-06 20:38 Marcin Wiazowski File Added: Reproduce.zip
2019-02-06 20:38 Marcin Wiazowski File Added: Reproduce.png
2019-02-06 22:01 wp Assigned To => wp
2019-02-06 22:01 wp Status new => assigned
2019-02-07 00:09 wp Fixed in Revision => 60352
2019-02-07 00:09 wp LazTarget => 2.0.2
2019-02-07 00:09 wp Note Added: 0113912
2019-02-07 00:09 wp Status assigned => resolved
2019-02-07 00:09 wp Resolution open => fixed
2019-02-07 00:09 wp Target Version => 2.0.2
2019-02-07 01:44 Marcin Wiazowski Note Added: 0113916
2019-02-07 01:44 Marcin Wiazowski Status resolved => assigned
2019-02-07 01:44 Marcin Wiazowski Resolution fixed => reopened
2019-02-08 22:36 wp Fixed in Revision 60352 => 60352, r60366
2019-02-08 22:36 wp Note Added: 0113957
2019-02-08 22:36 wp Status assigned => resolved
2019-02-08 22:36 wp Resolution reopened => fixed
2019-02-08 22:42 Marcin Wiazowski Note Added: 0113958
2019-02-08 22:42 Marcin Wiazowski Status resolved => closed