From be795689c72e4ffc74e1de8c3a3e765d1f8a9644 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Wed, 1 Oct 2025 23:08:40 +0200 Subject: [PATCH] decrease verbosity, allow for fixed limits. --- src/lib/aqdiagram/graph/timegraph.c | 24 +++++++++--------------- src/lib/aqdiagram/graph/timegraph.h | 7 ++++++- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/lib/aqdiagram/graph/timegraph.c b/src/lib/aqdiagram/graph/timegraph.c index eddf0f6..7043dde 100644 --- a/src/lib/aqdiagram/graph/timegraph.c +++ b/src/lib/aqdiagram/graph/timegraph.c @@ -87,27 +87,27 @@ void AQDG_TimeGraph_AddCurve(AQDG_GRAPH *g, const char *sLabel, int graphType, A -void AQDG_TimeGraph_SetupTicks(AQDG_GRAPH *g) +void AQDG_TimeGraph_SetupTicks(AQDG_GRAPH *g, uint32_t flags, double minY, double maxY) { AQDG_GRAPH_AXIS *axis; - DBG_ERROR(NULL, "Calc min/max values"); AQDG_Graph_CalcMinMaxValues(g); /* create ticks for X axis */ - DBG_ERROR(NULL, "Create ticks for X axis"); axis=AQDG_Graph_GetAxisByIndex(g, AQDG_GRAPH_AXISPOS_BOTTOM); if (axis) { _setupTicksForTimeAxis(axis); } /* create ticks for Y axis */ - DBG_ERROR(NULL, "Create ticks for Y axis"); axis=AQDG_Graph_GetAxisByIndex(g, AQDG_GRAPH_AXISPOS_LEFT); if (axis) { + if (flags & AQDG_TIMEGRAPH_SETUPTICKS_FLAGS_MINY) + AQDG_Graph_Axis_SetMinValue(axis, minY); + if (flags & AQDG_TIMEGRAPH_SETUPTICKS_FLAGS_MAXY) + AQDG_Graph_Axis_SetMaxValue(axis, maxY); _setupTicksForDataAxis(axis); } - DBG_ERROR(NULL, "Ticks done"); } @@ -121,33 +121,27 @@ void _setupTicksForTimeAxis(AQDG_GRAPH_AXIS *axis) minValue=AQDG_Graph_Axis_GetMinValue(axis); maxValue=AQDG_Graph_Axis_GetMaxValue(axis); diffInDays=(maxValue-minValue)/(24*60*60); - DBG_ERROR(NULL, "Difference in days: %f.0", diffInDays); + DBG_INFO(AQDG_LOGDOMAIN, "Difference in days: %f.0", diffInDays); if (diffInDays<3) { - DBG_ERROR(NULL, "Gen hour ticks"); - AQDG_Graph_Axis_GenHourTicks(axis, 0); + AQDG_Graph_Axis_GenHourTicks(axis, 0, 1); } else if (diffInDays<32) { - DBG_ERROR(NULL, "Gen day ticks"); - AQDG_Graph_Axis_GenDayTicks(axis, 0); + AQDG_Graph_Axis_GenDayTicks(axis, 0); /* level 0: gen tick for every day */ + AQDG_Graph_Axis_GenHourTicks(axis, 1, 8); /* level 1: gen tick for every 8h */ } else if (diffInDays<90) { - DBG_ERROR(NULL, "Gen week and day ticks"); AQDG_Graph_Axis_GenWeekTicks(axis, 0); AQDG_Graph_Axis_GenDayTicks(axis, 1); } else { - DBG_ERROR(NULL, "Gen month ticks"); AQDG_Graph_Axis_GenMonthTicks(axis, 0); if (diffInDays<100) { - DBG_ERROR(NULL, "Gen day ticks"); AQDG_Graph_Axis_GenDayTicks(axis, 1); } else if (diffInDays<400) { - DBG_ERROR(NULL, "Gen week ticks"); AQDG_Graph_Axis_GenWeekTicks(axis, 1); } } - DBG_ERROR(NULL, "Ticks done"); } diff --git a/src/lib/aqdiagram/graph/timegraph.h b/src/lib/aqdiagram/graph/timegraph.h index a5f2902..dc7362d 100644 --- a/src/lib/aqdiagram/graph/timegraph.h +++ b/src/lib/aqdiagram/graph/timegraph.h @@ -13,6 +13,11 @@ #include +#define AQDG_TIMEGRAPH_SETUPTICKS_FLAGS_MINY 0x01 +#define AQDG_TIMEGRAPH_SETUPTICKS_FLAGS_MAXY 0x02 + + + AQDG_API AQDG_GRAPH *AQDG_TimeGraph_new(const char *sTitle, const char *sSubTitle, const char *sYLabel, @@ -20,7 +25,7 @@ AQDG_API AQDG_GRAPH *AQDG_TimeGraph_new(const char *sTitle, int yPrecision); AQDG_API void AQDG_TimeGraph_AddCurve(AQDG_GRAPH *g, const char *sLabel, int graphType, AQDG_GRAPH_DATAPAIR_LIST *dpList); -AQDG_API void AQDG_TimeGraph_SetupTicks(AQDG_GRAPH *g); +AQDG_API void AQDG_TimeGraph_SetupTicks(AQDG_GRAPH *g, uint32_t flags, double minY, double maxY);