From 87053c5029e014167d7f3978c41cd725691e2a61 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Tue, 30 Dec 2025 10:50:09 +0100 Subject: [PATCH] clip bars to viewport. --- src/lib/aqdiagram/graph/w_viewport.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/lib/aqdiagram/graph/w_viewport.c b/src/lib/aqdiagram/graph/w_viewport.c index eb612a0..410b31e 100644 --- a/src/lib/aqdiagram/graph/w_viewport.c +++ b/src/lib/aqdiagram/graph/w_viewport.c @@ -533,7 +533,9 @@ void _drawCurveVertBars(AQDG_OBJECT *o, AQDG_DRAW_CONTEXT *dc, const AQDG_GRAPH_ valueMinDist, barWidth, baseLineValueY, baseLinePosY); #endif while(dp) { - int xPos; + int pos; + int xPos1; + int xPos2; int yPos; int h; double xValue; @@ -542,14 +544,18 @@ void _drawCurveVertBars(AQDG_OBJECT *o, AQDG_DRAW_CONTEXT *dc, const AQDG_GRAPH_ xValue=AQDG_Graph_DataPair_GetValueX(dp); yValue=AQDG_Graph_DataPair_GetValueY(dp); - xPos=_calcHorizontalPos(xValue, width, minValueX, maxValueX)-barWidth/2; + pos=_calcHorizontalPos(xValue, width, minValueX, maxValueX); + xPos1=pos-barWidth/2; + xPos2=pos+barWidth/2; + xPos1=(xPos1<0)?0:xPos1; + xPos2=(width>xPos2)?xPos2:(width-1); yPos=_calcVerticalPos(yValue, height, minValueY, maxValueY); h=baseLinePosY-yPos; if (h<0) { yPos+=h; h=-h; } - AQDG_Draw_Context_DrawFilledRect(dc, pen, absX+xPos, absY+yPos, barWidth, h); + AQDG_Draw_Context_DrawFilledRect(dc, pen, absX+xPos1, absY+yPos, (xPos2-xPos1)+1, h); dp=AQDG_Graph_DataPair_List_Next(dp); } }