improved X-axis ticks.
This commit is contained in:
@@ -213,6 +213,56 @@
|
|||||||
</inline>
|
</inline>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<inline loc="end" access="public">
|
||||||
|
<content>
|
||||||
|
$(api) void $(struct_prefix)_GenMinuteTicks($(struct_type) *st, int lvl, int minutes);
|
||||||
|
</content>
|
||||||
|
</inline>
|
||||||
|
|
||||||
|
<inline loc="code">
|
||||||
|
<content>
|
||||||
|
void $(struct_prefix)_GenMinuteTicks($(struct_type) *st, int lvl, int minutes) \n
|
||||||
|
{ \n
|
||||||
|
double minValue; \n
|
||||||
|
double maxValue; \n
|
||||||
|
GWEN_BUFFER *dbuf; \n
|
||||||
|
GWEN_TIMESTAMP *ts; \n
|
||||||
|
int m; \n
|
||||||
|
int addSecs; \n
|
||||||
|
\n
|
||||||
|
addSecs=minutes*60; \n
|
||||||
|
maxValue=st->maxValue; \n
|
||||||
|
minValue=st->minValue; \n
|
||||||
|
ts=GWEN_Timestamp_fromLocalTime(minValue); \n
|
||||||
|
m=(GWEN_Timestamp_GetMinute(ts)/minutes); \n
|
||||||
|
GWEN_Timestamp_SetTime(ts, GWEN_Timestamp_GetHour(ts), m*minutes, 0); \n
|
||||||
|
\n
|
||||||
|
dbuf=GWEN_Buffer_new(0, 256, 0, 1); \n
|
||||||
|
while(1) { \n
|
||||||
|
double v; \n
|
||||||
|
\n
|
||||||
|
v=GWEN_Timestamp_toTimeT(ts); \n
|
||||||
|
if (v>=minValue && v<maxValue) { \n
|
||||||
|
GWEN_Buffer_AppendArgs(dbuf, \n
|
||||||
|
"%02d:%02d", \n
|
||||||
|
GWEN_Timestamp_GetHour(ts), \n
|
||||||
|
GWEN_Timestamp_GetMinute(ts)); \n
|
||||||
|
if (!$(struct_prefix)_HasTickValue(st, v)) \n
|
||||||
|
$(struct_prefix)_AddNewTick(st, GWEN_Buffer_GetStart(dbuf), v, lvl, 0, (double) addSecs); \n
|
||||||
|
GWEN_Buffer_Reset(dbuf); \n
|
||||||
|
} \n
|
||||||
|
GWEN_Timestamp_AddSeconds(ts, addSecs); \n
|
||||||
|
if (v>maxValue) \n
|
||||||
|
break; \n
|
||||||
|
} \n
|
||||||
|
GWEN_Buffer_free(dbuf); \n
|
||||||
|
GWEN_Timestamp_free(ts); \n
|
||||||
|
} \n
|
||||||
|
</content>
|
||||||
|
</inline>
|
||||||
|
|
||||||
|
|
||||||
<inline loc="end" access="public">
|
<inline loc="end" access="public">
|
||||||
<content>
|
<content>
|
||||||
$(api) void $(struct_prefix)_GenHourTicks($(struct_type) *st, int lvl, int hours);
|
$(api) void $(struct_prefix)_GenHourTicks($(struct_type) *st, int lvl, int hours);
|
||||||
@@ -406,8 +456,8 @@
|
|||||||
v=GWEN_Date_toLocalTime(dtCurrent); \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", \n
|
"%02d/%02d", \n
|
||||||
GWEN_Date_GetYear(dtCurrent), \n
|
GWEN_Date_GetYear(dtCurrent)-2000, \n
|
||||||
GWEN_Date_GetMonth(dtCurrent)); \n
|
GWEN_Date_GetMonth(dtCurrent)); \n
|
||||||
if (!$(struct_prefix)_HasTickValue(st, v)) \n
|
if (!$(struct_prefix)_HasTickValue(st, v)) \n
|
||||||
$(struct_prefix)_AddNewTick(st, GWEN_Buffer_GetStart(dbuf), v, lvl, 0, (double) addSecs); \n
|
$(struct_prefix)_AddNewTick(st, GWEN_Buffer_GetStart(dbuf), v, lvl, 0, (double) addSecs); \n
|
||||||
@@ -425,6 +475,100 @@
|
|||||||
</content>
|
</content>
|
||||||
</inline>
|
</inline>
|
||||||
|
|
||||||
|
|
||||||
|
<inline loc="end" access="public">
|
||||||
|
<content>
|
||||||
|
$(api) void $(struct_prefix)_GenTimeTicks($(struct_type) *st);
|
||||||
|
</content>
|
||||||
|
</inline>
|
||||||
|
|
||||||
|
<inline loc="code">
|
||||||
|
<content>
|
||||||
|
void $(struct_prefix)_GenTimeTicks($(struct_type) *st) \n
|
||||||
|
{ \n
|
||||||
|
int nextLevel=0; \n
|
||||||
|
\n
|
||||||
|
$(struct_prefix)_GenMonthTicks(st, nextLevel); \n
|
||||||
|
if ($(struct_prefix)_HasAtLeastNLevelTicks(st, nextLevel, nextLevel?1:4)) \n
|
||||||
|
nextLevel++; \n
|
||||||
|
else \n
|
||||||
|
$(struct_prefix)_RemoveLevelTicks(st, nextLevel); \n
|
||||||
|
\n
|
||||||
|
if (nextLevel<3) { \n
|
||||||
|
$(struct_prefix)_GenWeekTicks(st, nextLevel); \n
|
||||||
|
if ($(struct_prefix)_HasAtLeastNLevelTicks(st, nextLevel, nextLevel?1:4)) \n
|
||||||
|
nextLevel++; \n
|
||||||
|
else \n
|
||||||
|
$(struct_prefix)_RemoveLevelTicks(st, nextLevel); \n
|
||||||
|
} \n
|
||||||
|
\n
|
||||||
|
if (nextLevel<3) { \n
|
||||||
|
$(struct_prefix)_GenDayTicks(st, nextLevel); \n
|
||||||
|
if ($(struct_prefix)_HasAtLeastNLevelTicks(st, nextLevel, nextLevel?1:4)) \n
|
||||||
|
nextLevel++; \n
|
||||||
|
else \n
|
||||||
|
$(struct_prefix)_RemoveLevelTicks(st, nextLevel); \n
|
||||||
|
} \n
|
||||||
|
\n
|
||||||
|
if (nextLevel<3) { \n
|
||||||
|
$(struct_prefix)_GenHourTicks(st, nextLevel, 12); \n
|
||||||
|
if ($(struct_prefix)_HasAtLeastNLevelTicks(st, nextLevel, nextLevel?1:4)) \n
|
||||||
|
nextLevel++; \n
|
||||||
|
else \n
|
||||||
|
$(struct_prefix)_RemoveLevelTicks(st, nextLevel); \n
|
||||||
|
} \n
|
||||||
|
\n
|
||||||
|
if (nextLevel<3) { \n
|
||||||
|
$(struct_prefix)_GenHourTicks(st, nextLevel, 6); \n
|
||||||
|
if ($(struct_prefix)_HasAtLeastNLevelTicks(st, nextLevel, nextLevel?1:4)) \n
|
||||||
|
nextLevel++; \n
|
||||||
|
else \n
|
||||||
|
$(struct_prefix)_RemoveLevelTicks(st, nextLevel); \n
|
||||||
|
} \n
|
||||||
|
\n
|
||||||
|
if (nextLevel<3) { \n
|
||||||
|
$(struct_prefix)_GenHourTicks(st, nextLevel, 6); \n
|
||||||
|
if ($(struct_prefix)_HasAtLeastNLevelTicks(st, nextLevel, nextLevel?1:4)) \n
|
||||||
|
nextLevel++; \n
|
||||||
|
else \n
|
||||||
|
$(struct_prefix)_RemoveLevelTicks(st, nextLevel); \n
|
||||||
|
} \n
|
||||||
|
\n
|
||||||
|
if (nextLevel<3) { \n
|
||||||
|
$(struct_prefix)_GenHourTicks(st, nextLevel, 1); \n
|
||||||
|
if ($(struct_prefix)_HasAtLeastNLevelTicks(st, nextLevel, nextLevel?1:4)) \n
|
||||||
|
nextLevel++; \n
|
||||||
|
else \n
|
||||||
|
$(struct_prefix)_RemoveLevelTicks(st, nextLevel); \n
|
||||||
|
} \n
|
||||||
|
|
||||||
|
if (nextLevel<3) { \n
|
||||||
|
$(struct_prefix)_GenMinuteTicks(st, nextLevel, 30); \n
|
||||||
|
if ($(struct_prefix)_HasAtLeastNLevelTicks(st, nextLevel, nextLevel?1:4)) \n
|
||||||
|
nextLevel++; \n
|
||||||
|
else \n
|
||||||
|
$(struct_prefix)_RemoveLevelTicks(st, nextLevel); \n
|
||||||
|
} \n
|
||||||
|
|
||||||
|
if (nextLevel<3) { \n
|
||||||
|
$(struct_prefix)_GenMinuteTicks(st, nextLevel, 5); \n
|
||||||
|
if ($(struct_prefix)_HasAtLeastNLevelTicks(st, nextLevel, nextLevel?1:4)) \n
|
||||||
|
nextLevel++; \n
|
||||||
|
else \n
|
||||||
|
$(struct_prefix)_RemoveLevelTicks(st, nextLevel); \n
|
||||||
|
} \n
|
||||||
|
|
||||||
|
if (nextLevel<3) { \n
|
||||||
|
$(struct_prefix)_GenMinuteTicks(st, nextLevel, 1); \n
|
||||||
|
if ($(struct_prefix)_HasAtLeastNLevelTicks(st, nextLevel, nextLevel?1:4)) \n
|
||||||
|
nextLevel++; \n
|
||||||
|
else \n
|
||||||
|
$(struct_prefix)_RemoveLevelTicks(st, nextLevel); \n
|
||||||
|
} \n
|
||||||
|
} \n
|
||||||
|
</content>
|
||||||
|
</inline>
|
||||||
|
|
||||||
</inlines>
|
</inlines>
|
||||||
|
|
||||||
</lang>
|
</lang>
|
||||||
|
|||||||
@@ -147,6 +147,7 @@ void AQDG_TimeGraph_SetupTicks(AQDG_GRAPH *g, uint32_t flags, double minY, doubl
|
|||||||
|
|
||||||
void _setupTicksForTimeAxis(AQDG_GRAPH_AXIS *axis)
|
void _setupTicksForTimeAxis(AQDG_GRAPH_AXIS *axis)
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
double minValue;
|
double minValue;
|
||||||
double maxValue;
|
double maxValue;
|
||||||
double diffInDays;
|
double diffInDays;
|
||||||
@@ -175,6 +176,9 @@ void _setupTicksForTimeAxis(AQDG_GRAPH_AXIS *axis)
|
|||||||
AQDG_Graph_Axis_GenWeekTicks(axis, 1);
|
AQDG_Graph_Axis_GenWeekTicks(axis, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
AQDG_Graph_Axis_GenTimeTicks(axis);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user