use smaller font for legend.

This commit is contained in:
Martin Preuss
2025-10-03 01:58:28 +02:00
parent 625162bb3c
commit b597fadeff
5 changed files with 29 additions and 17 deletions

View File

@@ -210,7 +210,8 @@
GWEN_Date_GetYear(dt), \n GWEN_Date_GetYear(dt), \n
GWEN_Date_GetMonth(dt), \n GWEN_Date_GetMonth(dt), \n
GWEN_Date_GetDay(dt)); \n GWEN_Date_GetDay(dt)); \n
$(struct_prefix)_AddNewTick(st, GWEN_Buffer_GetStart(dbuf), v, lvl, 0); \n if (!$(struct_prefix)_HasTickValue(st, v)) \n
$(struct_prefix)_AddNewTick(st, GWEN_Buffer_GetStart(dbuf), v, lvl, 0); \n
GWEN_Buffer_Reset(dbuf); \n GWEN_Buffer_Reset(dbuf); \n
} \n } \n
GWEN_Date_AddDays(dt, 1); \n GWEN_Date_AddDays(dt, 1); \n
@@ -241,30 +242,31 @@
GWEN_DATE *dt; \n GWEN_DATE *dt; \n
\n \n
maxValue=st->maxValue; \n maxValue=st->maxValue; \n
dt=GWEN_Date_fromLocalTime(maxValue); \n
GWEN_Date_free(dt); \n
\n
minValue=st->minValue; \n minValue=st->minValue; \n
dt=GWEN_Date_fromLocalTime(minValue); \n dt=GWEN_Date_fromLocalTime(minValue); \n
if (dt) { \n
GWEN_DATE *dtWeekStart; \n
\n
dtWeekStart=GWEN_Date_GetThisWeekStartFromMonday(dt); \n
GWEN_Date_free(dt); \n
dt=dtWeekStart; \n
} \n
\n \n
dbuf=GWEN_Buffer_new(0, 256, 0, 1); \n dbuf=GWEN_Buffer_new(0, 256, 0, 1); \n
while(1) { \n while(1) { \n
double v; \n double v; \n
GWEN_DATE *dtCurrent; \n
\n \n
dtCurrent=GWEN_Date_GetThisWeekStartFromMonday(dt); \n v=GWEN_Date_toLocalTime(dt); \n
v=GWEN_Date_toLocalTime(dtCurrent); \n
if (v>=minValue && v<maxValue) { \n if (v>=minValue && v<maxValue) { \n
GWEN_Buffer_AppendArgs(dbuf, \n GWEN_Buffer_AppendArgs(dbuf, \n
"%04d/%02d/%02d", \n "%04d/%02d/%02d", \n
GWEN_Date_GetYear(dtCurrent), \n GWEN_Date_GetYear(dt), \n
GWEN_Date_GetMonth(dtCurrent), \n GWEN_Date_GetMonth(dt), \n
GWEN_Date_GetDay(dtCurrent)); \n GWEN_Date_GetDay(dt)); \n
$(struct_prefix)_AddNewTick(st, GWEN_Buffer_GetStart(dbuf), v, lvl, 0); \n if (!$(struct_prefix)_HasTickValue(st, v)) \n
$(struct_prefix)_AddNewTick(st, GWEN_Buffer_GetStart(dbuf), v, lvl, 0); \n
GWEN_Buffer_Reset(dbuf); \n GWEN_Buffer_Reset(dbuf); \n
} \n } \n
GWEN_Date_free(dt); \n
dt=dtCurrent; \n
GWEN_Date_AddDays(dt, 7); \n GWEN_Date_AddDays(dt, 7); \n
if (v>=maxValue) \n if (v>=maxValue) \n
break; \n break; \n
@@ -297,6 +299,13 @@
\n \n
minValue=st->minValue; \n minValue=st->minValue; \n
dt=GWEN_Date_fromLocalTime(minValue); \n dt=GWEN_Date_fromLocalTime(minValue); \n
if (dt) { \n
GWEN_DATE *dtMonthStart; \n
\n
dtMonthStart=GWEN_Date_GetThisMonthStart(dt); \n
GWEN_Date_free(dt); \n
dt=dtMonthStart; \n
} \n
\n \n
dbuf=GWEN_Buffer_new(0, 256, 0, 1); \n dbuf=GWEN_Buffer_new(0, 256, 0, 1); \n
while(1) { \n while(1) { \n
@@ -310,7 +319,8 @@
"%04d/%02d", \n "%04d/%02d", \n
GWEN_Date_GetYear(dtCurrent), \n GWEN_Date_GetYear(dtCurrent), \n
GWEN_Date_GetMonth(dtCurrent)); \n GWEN_Date_GetMonth(dtCurrent)); \n
$(struct_prefix)_AddNewTick(st, GWEN_Buffer_GetStart(dbuf), v, lvl, 0); \n if (!$(struct_prefix)_HasTickValue(st, v)) \n
$(struct_prefix)_AddNewTick(st, GWEN_Buffer_GetStart(dbuf), v, lvl, 0); \n
GWEN_Buffer_Reset(dbuf); \n GWEN_Buffer_Reset(dbuf); \n
} \n } \n
GWEN_Date_free(dt); \n GWEN_Date_free(dt); \n

View File

@@ -127,7 +127,7 @@ void _setupTicksForTimeAxis(AQDG_GRAPH_AXIS *axis)
minValue=AQDG_Graph_Axis_GetMinValue(axis); minValue=AQDG_Graph_Axis_GetMinValue(axis);
maxValue=AQDG_Graph_Axis_GetMaxValue(axis); maxValue=AQDG_Graph_Axis_GetMaxValue(axis);
diffInDays=(maxValue-minValue)/(24*60*60); diffInDays=(maxValue-minValue)/(24*60*60);
DBG_INFO(AQDG_LOGDOMAIN, "Difference in days: %f.0", diffInDays); DBG_ERROR(AQDG_LOGDOMAIN, "Difference in days: %f.0", diffInDays);
if (diffInDays<3) { if (diffInDays<3) {
AQDG_Graph_Axis_GenHourTicks(axis, 0, 1); AQDG_Graph_Axis_GenHourTicks(axis, 0, 1);
} }

View File

@@ -549,6 +549,7 @@ void AQDG_GraphWidget_SetupDefaultFonts(AQDG_OBJECT *o)
MKNORMALFONT(AQDG_GRAPHWIDGET_FONT_IDX_AXISLABEL, 12); MKNORMALFONT(AQDG_GRAPHWIDGET_FONT_IDX_AXISLABEL, 12);
MKNORMALFONT(AQDG_GRAPHWIDGET_FONT_IDX_TICKLABELMAINLEVEL, 12); MKNORMALFONT(AQDG_GRAPHWIDGET_FONT_IDX_TICKLABELMAINLEVEL, 12);
MKNORMALFONT(AQDG_GRAPHWIDGET_FONT_IDX_TICKLABELSUBLEVEL, 10); MKNORMALFONT(AQDG_GRAPHWIDGET_FONT_IDX_TICKLABELSUBLEVEL, 10);
MKNORMALFONT(AQDG_GRAPHWIDGET_FONT_IDX_LEGEND, 10);
#undef MKNORMALFONT #undef MKNORMALFONT
} }

View File

@@ -75,6 +75,7 @@ enum {
AQDG_GRAPHWIDGET_FONT_IDX_AXISLABEL, AQDG_GRAPHWIDGET_FONT_IDX_AXISLABEL,
AQDG_GRAPHWIDGET_FONT_IDX_TICKLABELMAINLEVEL, AQDG_GRAPHWIDGET_FONT_IDX_TICKLABELMAINLEVEL,
AQDG_GRAPHWIDGET_FONT_IDX_TICKLABELSUBLEVEL, AQDG_GRAPHWIDGET_FONT_IDX_TICKLABELSUBLEVEL,
AQDG_GRAPHWIDGET_FONT_IDX_LEGEND,
AQDG_GRAPHWIDGET_FONT_IDX_LAST AQDG_GRAPHWIDGET_FONT_IDX_LAST
}; };

View File

@@ -51,7 +51,7 @@ AQDG_OBJECT *AQDG_LegendWidget_new(AQDG_OBJECT *parent, uint32_t options, AQDG_O
xo->graphWidget=graphWidget; xo->graphWidget=graphWidget;
AQDG_Object_SetVSpacing(o, 1); AQDG_Object_SetVSpacing(o, 1);
AQDG_Object_SetHSpacing(o, 1); AQDG_Object_SetHSpacing(o, 4);
_setupWidget(o, xo); _setupWidget(o, xo);
return o; return o;
@@ -80,7 +80,7 @@ void _setupWidget(AQDG_OBJECT *o, AQDG_WIDGET_LEGEND *xo)
int penIdx=AQDG_GRAPHWIDGET_PEN_IDX_CURVE0; int penIdx=AQDG_GRAPHWIDGET_PEN_IDX_CURVE0;
dc=AQDG_DrawableWidget_GetDrawContext(o); dc=AQDG_DrawableWidget_GetDrawContext(o);
AQDG_DrawableWidget_SetFontId(o, AQDG_GraphWidget_GetFont(xo->graphWidget, AQDG_GRAPHWIDGET_FONT_IDX_SUBTITLE)); AQDG_DrawableWidget_SetFontId(o, AQDG_GraphWidget_GetFont(xo->graphWidget, AQDG_GRAPHWIDGET_FONT_IDX_LEGEND));
AQDG_DrawableWidget_new(o, 0, dc); AQDG_DrawableWidget_new(o, 0, dc);
AQDG_LabelWidget_new(o, 0, dc, "Cur:"); AQDG_LabelWidget_new(o, 0, dc, "Cur:");