From 28fc5d644564f95fdc97b5e8a814016597513973 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sat, 3 Jan 2026 18:38:10 +0100 Subject: [PATCH] improved bargraph. --- src/lib/aqdiagram/graph/bargraph.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/lib/aqdiagram/graph/bargraph.c b/src/lib/aqdiagram/graph/bargraph.c index f8adafe..7b3c625 100644 --- a/src/lib/aqdiagram/graph/bargraph.c +++ b/src/lib/aqdiagram/graph/bargraph.c @@ -38,6 +38,7 @@ */ static void _setDataTicks(const AQDG_GRAPH *g, AQDG_GRAPH_AXIS *axis); +static void _setValuesX(AQDG_GRAPH_DATAPAIR_LIST *dpList); @@ -87,6 +88,7 @@ void AQDG_BarGraph_AddCurve(AQDG_GRAPH *g, const char *sLabel, int graphType, AQ { AQDG_GRAPH_SUBGRAPH *subGraph; + _setValuesX(dpList); subGraph=AQDG_Graph_GetFirstSubGraph(g); if (subGraph) { AQDG_GRAPH_CURVE *curve; @@ -110,7 +112,8 @@ void AQDG_BarGraph_SetupTicks(AQDG_GRAPH *g, uint32_t flags, double minY, double /* create ticks for X axis */ axis=AQDG_Graph_GetAxisByIndex(g, AQDG_GRAPH_AXISPOS_BOTTOM); if (axis) { - AQDG_Graph_Axis_AddMargins(axis, AQDG_BARGRAPH_MARGINSPERCENT_X); + AQDG_Graph_Axis_SetMinValue(axis, AQDG_Graph_Axis_GetMinValue(axis)-0.5); + AQDG_Graph_Axis_SetMaxValue(axis, AQDG_Graph_Axis_GetMaxValue(axis)+0.5); _setDataTicks(g, axis); } @@ -149,3 +152,20 @@ void _setDataTicks(const AQDG_GRAPH *g, AQDG_GRAPH_AXIS *axis) +void _setValuesX(AQDG_GRAPH_DATAPAIR_LIST *dpList) +{ + if (dpList) { + AQDG_GRAPH_DATAPAIR *dp; + int idx; + + dp=AQDG_Graph_DataPair_List_First(dpList); + while(dp) { + AQDG_Graph_DataPair_SetValueX(dp, (double)(idx++)); + dp=AQDG_Graph_DataPair_List_Next(dp); + } + } +} + + + +