[chronojump] method to calculateY based on calculated proportion of any variable on cairo XY graphs
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] method to calculateY based on calculated proportion of any variable on cairo XY graphs
- Date: Mon, 9 May 2022 15:59:34 +0000 (UTC)
commit 33ed03479108bbcefa802dec684574ee3d4929b9
Author: Xavier de Blas <xaviblas gmail com>
Date: Mon May 9 17:58:03 2022 +0200
method to calculateY based on calculated proportion of any variable on cairo XY graphs
src/gui/cairo/xy.cs | 6 ++++++
src/utilMath.cs | 9 +++++++++
2 files changed, 15 insertions(+)
---
diff --git a/src/gui/cairo/xy.cs b/src/gui/cairo/xy.cs
index fe154a185..467ebbf22 100644
--- a/src/gui/cairo/xy.cs
+++ b/src/gui/cairo/xy.cs
@@ -679,6 +679,12 @@ public abstract class CairoXY : CairoGeneric
absoluteMaxY - minY));
}
+ //when you want to plot another value, so minY, maxY is different
+ protected double calculatePaintYProportion (double YProp) //from 0 to 1
+ {
+ return graphHeight - totalMargins - (YProp * (graphHeight - 2*totalMargins));
+ }
+
// Fast calculatePaintX/Y, sadly for 10000 points the difference between fast and slow is very low
/*
diff --git a/src/utilMath.cs b/src/utilMath.cs
index a98c49b0c..c754e36c1 100644
--- a/src/utilMath.cs
+++ b/src/utilMath.cs
@@ -624,6 +624,15 @@ public static class MathUtil
return min;
}
+ public static double GetProportion (double d, List<double> d_l)
+ {
+ double max = GetMax (d_l);
+ double min = GetMin (d_l);
+
+ d -= min; //move d to 0
+ return UtilAll.DivideSafe(d, max - min);
+ }
+
}
public class InterpolateSignal
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]