[chronojump] Encoder cairo barplot do not show legend



commit 229a0f612e1329a7d7f1632a847a953fa34a8e21
Author: Xavier de Blas <xaviblas gmail com>
Date:   Mon Mar 21 17:01:07 2022 +0100

    Encoder cairo barplot do not show legend

 src/gui/cairo/bars.cs   | 19 ++++++++++++++-----
 src/gui/eventExecute.cs | 20 ++++++++++----------
 2 files changed, 24 insertions(+), 15 deletions(-)
---
diff --git a/src/gui/cairo/bars.cs b/src/gui/cairo/bars.cs
index 3d5bf0275..a8cf2dda5 100644
--- a/src/gui/cairo/bars.cs
+++ b/src/gui/cairo/bars.cs
@@ -251,7 +251,7 @@ public abstract class CairoBars : CairoGeneric
 
        public abstract void GraphDo (List<PointF> pointMain_l, List<List<PointF>> pointSecondary_ll, bool 
mainAtLeft,
                        List<Cairo.Color> colorMain_l, List<Cairo.Color> colorSecondary, List<string> names_l,
-                       string labelBarMain, string labelBarSecondary, bool labelRotateInFirstBar,
+                       bool showLegend, string labelBarMain, string labelBarSecondary, bool 
labelRotateInFirstBar,
                        int fontHeightForBottomNames, int marginForBottomNames, string title, bool clickable);
 
        protected void initGraph(string font, double widthPercent1)
@@ -792,7 +792,7 @@ public class CairoBars1Series : CairoBars
 
        public override void GraphDo (List<PointF> pointMain_l, List<List<PointF>> pointSecondary_ll, bool 
mainAtLeft,
                        List<Cairo.Color> colorMain_l, List<Cairo.Color> colorSecondary, List<string> names_l,
-                       string labelBarMain, string labelBarSecondary, bool labelRotateInFirstBar,
+                       bool showLegend, string labelBarMain, string labelBarSecondary, bool 
labelRotateInFirstBar,
                        int fontHeightForBottomNames, int marginForBottomNames, string title, bool clickable)
        {
                LogB.Information("at CairoBars1Series.Do");
@@ -801,6 +801,7 @@ public class CairoBars1Series : CairoBars
                this.colorMain_l = colorMain_l;
                //this.colorSecondary_l = colorSecondary_l; //unused in this class
                this.names_l = names_l;
+               //this.showLegend = showLegend; //unused on this class
                this.fontHeightForBottomNames = fontHeightForBottomNames;
                this.marginForBottomNames = marginForBottomNames;
                this.title = title;
@@ -838,6 +839,7 @@ public class CairoBarsNHSeries : CairoBars
        private List<Cairo.Color> colorMain_l;
        private List<Cairo.Color> colorSecondary_l;
        private List<string> names_l;
+       private bool showLegend;
        private string labelBarMain;
        private string labelBarSecondary;
        private bool labelRotateInFirstBar;
@@ -872,8 +874,11 @@ public class CairoBarsNHSeries : CairoBars
        protected override void topMarginSet ()
        {
                topMargin = 50; //to accomodate legend under title
-               oneRowLegend = true;
 
+               if(! showLegend)
+                       return;
+
+               oneRowLegend = true;
                calculateOneRowLegendWidth();
 
                g.SetFontSize(textHeight-2);
@@ -1144,7 +1149,7 @@ public class CairoBarsNHSeries : CairoBars
 
        public override void GraphDo (List<PointF> pointMain_l, List<List<PointF>> pointSecondary_ll, bool 
mainAtLeft,
                        List<Cairo.Color> colorMain_l, List<Cairo.Color> colorSecondary_l, List<string> 
names_l,
-                       string labelBarMain, string labelBarSecondary, bool labelRotateInFirstBar,
+                       bool showLegend, string labelBarMain, string labelBarSecondary, bool 
labelRotateInFirstBar,
                        int fontHeightForBottomNames, int marginForBottomNames, string title, bool clickable)
        {
                this.pointSecondary_ll = pointSecondary_ll;
@@ -1152,6 +1157,7 @@ public class CairoBarsNHSeries : CairoBars
                this.colorMain_l = colorMain_l;
                this.colorSecondary_l = colorSecondary_l;
                this.names_l = names_l;
+               this.showLegend = showLegend;
                this.labelBarMain = labelBarMain;
                this.labelBarSecondary = labelBarSecondary;
                this.labelRotateInFirstBar = labelRotateInFirstBar;
@@ -1177,7 +1183,10 @@ public class CairoBarsNHSeries : CairoBars
                plotBars();
 
                writeTitleAtTop ();
-               writeLegend ();
+
+               if(showLegend)
+                       writeLegend ();
+
                if(clickable)
                        addClickableMark (g);
 
diff --git a/src/gui/eventExecute.cs b/src/gui/eventExecute.cs
index 061779993..c8b7282d2 100644
--- a/src/gui/eventExecute.cs
+++ b/src/gui/eventExecute.cs
@@ -2639,17 +2639,17 @@ public class CairoPaintBarsPreJumpSimple : CairoPaintBarsPre
 
                        cb.GraphDo (pointB_l, pointSecondary_ll, false,
                                        new List<Cairo.Color>(), new List<Cairo.Color>(), names_l,
-                                       "", "", false,
+                                       true, "", "", false,
                                        fontHeightForBottomNames, bottomMargin, title, false);
                } else if (showBarA) //takeOff, takeOffWeight
                        cb.GraphDo (pointA_l, new List<List<PointF>>(), false,
                                        new List<Cairo.Color>(), new List<Cairo.Color>(), names_l,
-                                       "", "", false,
+                                       false, "", "", false,
                                        fontHeightForBottomNames, bottomMargin, title, false);
                else //rest of the jumps: sj, cmj, ..
                        cb.GraphDo (pointB_l, new List<List<PointF>>(), false,
                                        new List<Cairo.Color>(), new List<Cairo.Color>(), names_l,
-                                       "", "", false,
+                                       false, "", "", false,
                                        fontHeightForBottomNames, bottomMargin, title, false);
        }
 }
@@ -2778,7 +2778,7 @@ public class CairoPaintBarsPreJumpReactive : CairoPaintBarsPre
 
                cb.GraphDo (pointB_l, pointSecondary_ll, false,
                                new List<Cairo.Color>(), new List<Cairo.Color>(), names_l,
-                               "", "", false,
+                               true, "", "", false,
                                fontHeightForBottomNames, bottomMargin, title, false);
        }
 }
@@ -2879,7 +2879,7 @@ public class CairoPaintBarsPreRunSimple : CairoPaintBarsPre
 
                cb.GraphDo (point_l, new List<List<PointF>>(), false,
                                new List<Cairo.Color>(), new List<Cairo.Color>(), names_l,
-                               "", "", false,
+                               false, "", "", false,
                                fontHeightForBottomNames, bottomMargin, title, false);
        }
 }
@@ -2990,7 +2990,7 @@ public class CairoPaintBarsPreRunInterval : CairoPaintBarsPre
 
                cb.GraphDo (point_l, new List<List<PointF>>(), false,
                                new List<Cairo.Color>(), new List<Cairo.Color>(), names_l,
-                               "", "", false,
+                               false, "", "", false,
                                fontHeightForBottomNames, bottomMargin, title, false);
        }
 }
@@ -3119,7 +3119,7 @@ public class CairoPaintBarsPreJumpReactiveRealtimeCapture : CairoPaintBarsPre
 
                cb.GraphDo (pointB_l, pointSecondary_ll, false,
                                new List<Cairo.Color>(), new List<Cairo.Color>(), names_l,
-                               "", "", false,
+                               true, "", "", false,
                                14, 8, title, false);
        }
 }
@@ -3291,7 +3291,7 @@ public class CairoPaintBarsPreRunIntervalRealtimeCapture : CairoPaintBarsPre
 
                cb.GraphDo (point_l, new List<List<PointF>>(), false,
                                new List<Cairo.Color>(), new List<Cairo.Color>(), names_l,
-                               "", "", false,
+                               false, "", "", false,
                                14, 22, title, false); //22 because there are two rows
        }
 }
@@ -3584,7 +3584,7 @@ public class CairoPaintBarplotPreEncoder : CairoPaintBarsPre
                if(pegbe.eccon == "c")
                        cb.GraphDo (dataA_l, new List<List<PointF>>(), false,
                                        colorMain_l, new List<Cairo.Color>(), names_l,
-                                       "", "", false,
+                                       false, "", "", false,
                                        14, 8, "my title", ! pegbe.capturing);
                else {
                        List<List<PointF>> pointSecondary_ll = new List<List<PointF>>();
@@ -3592,7 +3592,7 @@ public class CairoPaintBarplotPreEncoder : CairoPaintBarsPre
 
                        cb.GraphDo (dataB_l, pointSecondary_ll, false,
                                        colorMain_l, colorSecondary_l, names_l,
-                                       "Ecc", "Con", true,
+                                       false, "Ecc", "Con", true,
                                        14, 8, "my title", ! pegbe.capturing);
                }
        }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]