Compare commits
17 Commits
v0.1.3-bet
...
v0.1.4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a1c610d972 | ||
|
|
28fc5d6445 | ||
|
|
a204af508f | ||
|
|
93e066d333 | ||
|
|
a2319c1823 | ||
|
|
aefee5d631 | ||
|
|
ba79f68819 | ||
|
|
545db8bc60 | ||
|
|
3b914e5630 | ||
|
|
36725f170f | ||
|
|
e3eb5cc901 | ||
|
|
0325d51c0e | ||
|
|
2a641f7a25 | ||
|
|
42c81e32ce | ||
|
|
87053c5029 | ||
|
|
fb6af5ef1b | ||
|
|
d6040a6bc9 |
4
0BUILD
4
0BUILD
@@ -3,8 +3,8 @@
|
|||||||
|
|
||||||
<gwbuild requiredVersion="5.9.0" >
|
<gwbuild requiredVersion="5.9.0" >
|
||||||
|
|
||||||
<project name="aqdiagram" version="0.1.3-beta"
|
<project name="aqdiagram" version="0.1.4"
|
||||||
so_current="0" so_age="0" so_revision="3"
|
so_current="0" so_age="0" so_revision="4"
|
||||||
write_config_h="TRUE"
|
write_config_h="TRUE"
|
||||||
>
|
>
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ mkdir build
|
|||||||
cd build
|
cd build
|
||||||
gwbuild -s ..
|
gwbuild -s ..
|
||||||
gwbuild -p
|
gwbuild -p
|
||||||
gwbuild -Btm2builder
|
gwbuild -Btm2builder (not needed with newer versions of gwenbuild)
|
||||||
gwbuild -jNN (with NN number of parallel processes, e.g. 4 for quadcore cpu)
|
gwbuild -jNN (with NN number of parallel processes, e.g. 4 for quadcore cpu)
|
||||||
sudo gwbuild -i
|
sudo gwbuild -i
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ AQDG_GRAPH_DATAPAIR_LIST *AQDG_Data_DaySums(const AQDG_GRAPH_DATAPAIR_LIST *dpLi
|
|||||||
while(dp) {
|
while(dp) {
|
||||||
double v;
|
double v;
|
||||||
|
|
||||||
v=AQDG_Graph_DataPair_GetValueX(dp);
|
v=AQDG_Graph_DataPair_GetValueY(dp);
|
||||||
if (lastDate==NULL) {
|
if (lastDate==NULL) {
|
||||||
/* first value */
|
/* first value */
|
||||||
lastDate=GWEN_Date_fromLocalTime(AQDG_Graph_DataPair_GetValueX(dp));
|
lastDate=GWEN_Date_fromLocalTime(AQDG_Graph_DataPair_GetValueX(dp));
|
||||||
|
|||||||
@@ -13,6 +13,9 @@
|
|||||||
#include "./floatingavg.h"
|
#include "./floatingavg.h"
|
||||||
|
|
||||||
|
|
||||||
|
static double _averageOverArray(const double *lastValues, int num);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
AQDG_GRAPH_DATAPAIR_LIST *AQDG_Data_FloatingAverage(const AQDG_GRAPH_DATAPAIR_LIST *dpList, int num)
|
AQDG_GRAPH_DATAPAIR_LIST *AQDG_Data_FloatingAverage(const AQDG_GRAPH_DATAPAIR_LIST *dpList, int num)
|
||||||
{
|
{
|
||||||
@@ -28,36 +31,19 @@ AQDG_GRAPH_DATAPAIR_LIST *AQDG_Data_FloatingAverage(const AQDG_GRAPH_DATAPAIR_LI
|
|||||||
while(dp) {
|
while(dp) {
|
||||||
AQDG_GRAPH_DATAPAIR *newDp;
|
AQDG_GRAPH_DATAPAIR *newDp;
|
||||||
double v;
|
double v;
|
||||||
int i;
|
|
||||||
|
|
||||||
v=AQDG_Graph_DataPair_GetValueY(dp);
|
v=AQDG_Graph_DataPair_GetValueY(dp);
|
||||||
if (idx>=num)
|
idx%=num;
|
||||||
idx=0;
|
lastValues[idx++]=v;
|
||||||
lastValues[idx]=v;
|
|
||||||
idx++;
|
|
||||||
cnt++;
|
cnt++;
|
||||||
|
|
||||||
if (cnt<num) {
|
if (cnt<num) {
|
||||||
/* buffer not full, average over the values we already have */
|
/* buffer not full, average over the values we already have */
|
||||||
if (cnt) {
|
v=_averageOverArray(lastValues, cnt);
|
||||||
double totalSum=0.0;
|
|
||||||
|
|
||||||
for (i=0; i<cnt; i++) {
|
|
||||||
totalSum+=lastValues[i];
|
|
||||||
}
|
|
||||||
v=totalSum/((double)cnt);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
v=0.0;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
double totalSum=0.0;
|
|
||||||
|
|
||||||
/* buffer full, average over full buffer */
|
/* buffer full, average over full buffer */
|
||||||
for (i=0; i<num; i++) {
|
v=_averageOverArray(lastValues, num);
|
||||||
totalSum+=lastValues[i];
|
|
||||||
}
|
|
||||||
v=totalSum/((double)num);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
newDp=AQDG_Graph_DataPair_dup(dp);
|
newDp=AQDG_Graph_DataPair_dup(dp);
|
||||||
@@ -73,3 +59,23 @@ AQDG_GRAPH_DATAPAIR_LIST *AQDG_Data_FloatingAverage(const AQDG_GRAPH_DATAPAIR_LI
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
double _averageOverArray(const double *lastValues, int num)
|
||||||
|
{
|
||||||
|
double v=0.0;
|
||||||
|
|
||||||
|
if (num) {
|
||||||
|
double totalSum=0.0;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
/* average over full buffer */
|
||||||
|
for (i=0; i<num; i++) {
|
||||||
|
totalSum+=lastValues[i];
|
||||||
|
}
|
||||||
|
v=totalSum/((double)num);
|
||||||
|
}
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
|
|
||||||
<setVar name="local/typefiles" >
|
<setVar name="local/typefiles" >
|
||||||
datapair.t2d
|
datapair.t2d
|
||||||
|
category.t2d
|
||||||
subgraph.t2d
|
subgraph.t2d
|
||||||
tick.t2d
|
tick.t2d
|
||||||
axis.t2d
|
axis.t2d
|
||||||
@@ -42,6 +43,7 @@
|
|||||||
|
|
||||||
<setVar name="local/built_sources" >
|
<setVar name="local/built_sources" >
|
||||||
datapair.c
|
datapair.c
|
||||||
|
category.c
|
||||||
subgraph.c
|
subgraph.c
|
||||||
tick.c
|
tick.c
|
||||||
axis.c
|
axis.c
|
||||||
@@ -50,6 +52,7 @@
|
|||||||
|
|
||||||
<setVar name="local/built_headers_pub">
|
<setVar name="local/built_headers_pub">
|
||||||
datapair.h
|
datapair.h
|
||||||
|
category.h
|
||||||
subgraph.h
|
subgraph.h
|
||||||
tick.h
|
tick.h
|
||||||
axis.h
|
axis.h
|
||||||
@@ -59,6 +62,7 @@
|
|||||||
|
|
||||||
<setVar name="local/built_headers_priv" >
|
<setVar name="local/built_headers_priv" >
|
||||||
datapair_p.h
|
datapair_p.h
|
||||||
|
category_p.h
|
||||||
subgraph_p.h
|
subgraph_p.h
|
||||||
tick_p.h
|
tick_p.h
|
||||||
axis_p.h
|
axis_p.h
|
||||||
@@ -79,6 +83,7 @@
|
|||||||
<headers dist="true" install="$(pkgincludedir)/graph">
|
<headers dist="true" install="$(pkgincludedir)/graph">
|
||||||
graph.h
|
graph.h
|
||||||
timegraph.h
|
timegraph.h
|
||||||
|
bargraph.h
|
||||||
w_graph.h
|
w_graph.h
|
||||||
w_axis.h
|
w_axis.h
|
||||||
w_xaxis.h
|
w_xaxis.h
|
||||||
@@ -101,6 +106,7 @@
|
|||||||
$(local/typefiles)
|
$(local/typefiles)
|
||||||
graph.c
|
graph.c
|
||||||
timegraph.c
|
timegraph.c
|
||||||
|
bargraph.c
|
||||||
w_graph.c
|
w_graph.c
|
||||||
w_axis.c
|
w_axis.c
|
||||||
w_xaxis.c
|
w_xaxis.c
|
||||||
|
|||||||
@@ -633,6 +633,42 @@
|
|||||||
</content>
|
</content>
|
||||||
</inline>
|
</inline>
|
||||||
|
|
||||||
|
|
||||||
|
<inline loc="end" access="public">
|
||||||
|
<content>
|
||||||
|
$(api) void $(struct_prefix)_AddMargins(AQDG_GRAPH_AXIS *axis, double percent);
|
||||||
|
</content>
|
||||||
|
</inline>
|
||||||
|
|
||||||
|
<inline loc="code">
|
||||||
|
<content>
|
||||||
|
void $(struct_prefix)_AddMargins(AQDG_GRAPH_AXIS *axis, double percent)
|
||||||
|
{
|
||||||
|
double vMax;
|
||||||
|
double vMin;
|
||||||
|
double vDiff;
|
||||||
|
|
||||||
|
vMin=axis->minValue;
|
||||||
|
vMax=axis->maxValue;
|
||||||
|
vDiff=vMax-vMin;
|
||||||
|
if (vDiff==0.0) {
|
||||||
|
vDiff=vMax;
|
||||||
|
if (vDiff==0.0)
|
||||||
|
vDiff=1.0;
|
||||||
|
}
|
||||||
|
if (vDiff>0.0) {
|
||||||
|
double vDiffForPercent;
|
||||||
|
|
||||||
|
vDiffForPercent=vDiff*(percent/100.0);
|
||||||
|
vMin-=vDiffForPercent;
|
||||||
|
vMax+=vDiffForPercent;
|
||||||
|
axis->minValue=vMin;
|
||||||
|
axis->maxValue=vMax;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</content>
|
||||||
|
</inline>
|
||||||
|
|
||||||
</inlines>
|
</inlines>
|
||||||
|
|
||||||
</lang>
|
</lang>
|
||||||
|
|||||||
171
src/lib/aqdiagram/graph/bargraph.c
Normal file
171
src/lib/aqdiagram/graph/bargraph.c
Normal file
@@ -0,0 +1,171 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* This file is part of the project AqDiagram.
|
||||||
|
* AqDiagram (c) by 2025 Martin Preuss, all rights reserved.
|
||||||
|
*
|
||||||
|
* The license for this file can be found in the file COPYING which you
|
||||||
|
* should have received along with this file.
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "./bargraph.h"
|
||||||
|
|
||||||
|
#include <aqdiagram/data/date.h>
|
||||||
|
#include <aqdiagram/data/floatingavg.h>
|
||||||
|
#include <aqdiagram/data/accumulate.h>
|
||||||
|
#include <aqdiagram/data/negate.h>
|
||||||
|
|
||||||
|
#include <gwenhywfar/debug.h>
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* definitions
|
||||||
|
* ------------------------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define AQDG_BARGRAPH_MARGINSPERCENT_X 1.0
|
||||||
|
#define AQDG_BARGRAPH_MARGINSPERCENT_Y 10.0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* forward declarations
|
||||||
|
* ------------------------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
static void _setDataTicks(const AQDG_GRAPH *g, AQDG_GRAPH_AXIS *axis);
|
||||||
|
static void _setValuesX(AQDG_GRAPH_DATAPAIR_LIST *dpList);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* code
|
||||||
|
* ------------------------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
AQDG_GRAPH *AQDG_BarGraph_new(const char *sTitle,
|
||||||
|
const char *sSubTitle,
|
||||||
|
const char *sYLabel,
|
||||||
|
const char *sYUnits,
|
||||||
|
int yPrecision)
|
||||||
|
{
|
||||||
|
AQDG_GRAPH *g;
|
||||||
|
AQDG_GRAPH_AXIS *xAxis;
|
||||||
|
AQDG_GRAPH_AXIS *yAxis;
|
||||||
|
AQDG_GRAPH_SUBGRAPH *subGraph;
|
||||||
|
|
||||||
|
g=AQDG_Graph_new();
|
||||||
|
AQDG_Graph_SetTitle(g, sTitle);
|
||||||
|
AQDG_Graph_SetSubTitle(g, sSubTitle);
|
||||||
|
|
||||||
|
xAxis=AQDG_Graph_Axis_new();
|
||||||
|
AQDG_Graph_Axis_SetLabel(xAxis, "Category");
|
||||||
|
AQDG_Graph_Axis_SetPrecision(xAxis, 0);
|
||||||
|
AQDG_Graph_SetAxis(g, AQDG_GRAPH_AXISPOS_BOTTOM, xAxis);
|
||||||
|
|
||||||
|
yAxis=AQDG_Graph_Axis_new();
|
||||||
|
AQDG_Graph_Axis_SetLabel(yAxis, sYLabel);
|
||||||
|
AQDG_Graph_Axis_SetPrecision(yAxis, yPrecision);
|
||||||
|
AQDG_Graph_Axis_SetUnits(yAxis, sYUnits);
|
||||||
|
AQDG_Graph_SetAxis(g, AQDG_GRAPH_AXISPOS_LEFT, yAxis);
|
||||||
|
|
||||||
|
subGraph=AQDG_Graph_SubGraph_new();
|
||||||
|
AQDG_Graph_SubGraph_SetIndexAxisX(subGraph, AQDG_GRAPH_AXISPOS_BOTTOM);
|
||||||
|
AQDG_Graph_SubGraph_SetIndexAxisY(subGraph, AQDG_GRAPH_AXISPOS_LEFT);
|
||||||
|
AQDG_Graph_AddSubGraph(g, subGraph);
|
||||||
|
|
||||||
|
return g;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQDG_BarGraph_AddCurve(AQDG_GRAPH *g, const char *sLabel, int graphType, AQDG_GRAPH_DATAPAIR_LIST *dpList)
|
||||||
|
{
|
||||||
|
AQDG_GRAPH_SUBGRAPH *subGraph;
|
||||||
|
|
||||||
|
_setValuesX(dpList);
|
||||||
|
subGraph=AQDG_Graph_GetFirstSubGraph(g);
|
||||||
|
if (subGraph) {
|
||||||
|
AQDG_GRAPH_CURVE *curve;
|
||||||
|
|
||||||
|
curve=AQDG_Graph_Curve_new();
|
||||||
|
AQDG_Graph_Curve_SetLabel(curve, sLabel);
|
||||||
|
AQDG_Graph_Curve_SetGraphType(curve, graphType);
|
||||||
|
AQDG_Graph_Curve_SetDataPairs(curve, dpList);
|
||||||
|
AQDG_Graph_SubGraph_AddCurve(subGraph, curve);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQDG_BarGraph_SetupTicks(AQDG_GRAPH *g, uint32_t flags, double minY, double maxY)
|
||||||
|
{
|
||||||
|
AQDG_GRAPH_AXIS *axis;
|
||||||
|
|
||||||
|
AQDG_Graph_CalcMinMaxValues(g);
|
||||||
|
|
||||||
|
/* create ticks for X axis */
|
||||||
|
axis=AQDG_Graph_GetAxisByIndex(g, AQDG_GRAPH_AXISPOS_BOTTOM);
|
||||||
|
if (axis) {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* create ticks for Y axis */
|
||||||
|
axis=AQDG_Graph_GetAxisByIndex(g, AQDG_GRAPH_AXISPOS_LEFT);
|
||||||
|
if (axis) {
|
||||||
|
AQDG_Graph_Axis_AddMargins(axis, AQDG_BARGRAPH_MARGINSPERCENT_Y);
|
||||||
|
if (flags & AQDG_BARGRAPH_SETUPTICKS_FLAGS_MINY)
|
||||||
|
AQDG_Graph_Axis_SetMinValue(axis, minY);
|
||||||
|
if (flags & AQDG_BARGRAPH_SETUPTICKS_FLAGS_MAXY)
|
||||||
|
AQDG_Graph_Axis_SetMaxValue(axis, maxY);
|
||||||
|
AQDG_Graph_Axis_GenLog10Ticks(axis);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void _setDataTicks(const AQDG_GRAPH *g, AQDG_GRAPH_AXIS *axis)
|
||||||
|
{
|
||||||
|
const AQDG_GRAPH_SUBGRAPH *subGraph;
|
||||||
|
const AQDG_GRAPH_CURVE_LIST *curveList;
|
||||||
|
const AQDG_GRAPH_CURVE *curve;
|
||||||
|
const AQDG_GRAPH_DATAPAIR_LIST *dpList;
|
||||||
|
const AQDG_GRAPH_DATAPAIR *dp;
|
||||||
|
|
||||||
|
subGraph=AQDG_Graph_GetFirstSubGraph(g);
|
||||||
|
curveList=subGraph?AQDG_Graph_SubGraph_GetCurves(subGraph):NULL;
|
||||||
|
curve=curveList?AQDG_Graph_Curve_List_First(curveList):NULL;
|
||||||
|
dpList=curve?AQDG_Graph_Curve_GetDataPairs(curve):NULL;
|
||||||
|
dp=dpList?AQDG_Graph_DataPair_List_First(dpList):NULL;
|
||||||
|
while(dp) {
|
||||||
|
AQDG_Graph_Axis_AddNewTick(axis, AQDG_Graph_DataPair_GetLabel(dp), AQDG_Graph_DataPair_GetValueX(dp), 0, 0, 1);
|
||||||
|
dp=AQDG_Graph_DataPair_List_Next(dp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
43
src/lib/aqdiagram/graph/bargraph.h
Normal file
43
src/lib/aqdiagram/graph/bargraph.h
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* This file is part of the project AqDiagram.
|
||||||
|
* AqDiagram (c) by 2025 Martin Preuss, all rights reserved.
|
||||||
|
*
|
||||||
|
* The license for this file can be found in the file COPYING which you
|
||||||
|
* should have received along with this file.
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef AQDG_GRAPH_BARGRAPH_H
|
||||||
|
#define AQDG_GRAPH_BARGRAPH_H
|
||||||
|
|
||||||
|
#include <aqdiagram/placement/object.h>
|
||||||
|
#include <aqdiagram/graph/graph.h>
|
||||||
|
|
||||||
|
|
||||||
|
#define AQDG_BARGRAPH_SETUPTICKS_FLAGS_MINY 0x01
|
||||||
|
#define AQDG_BARGRAPH_SETUPTICKS_FLAGS_MAXY 0x02
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
AQDG_API AQDG_GRAPH *AQDG_BarGraph_new(const char *sTitle,
|
||||||
|
const char *sSubTitle,
|
||||||
|
const char *sYLabel,
|
||||||
|
const char *sYUnits,
|
||||||
|
int yPrecision);
|
||||||
|
|
||||||
|
AQDG_API void AQDG_BarGraph_AddCurve(AQDG_GRAPH *g, const char *sLabel, int graphType, AQDG_GRAPH_DATAPAIR_LIST *dpList);
|
||||||
|
AQDG_API void AQDG_BarGraph_SetupTicks(AQDG_GRAPH *g, uint32_t flags, double minY, double maxY);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
420
src/lib/aqdiagram/graph/category.t2d
Normal file
420
src/lib/aqdiagram/graph/category.t2d
Normal file
@@ -0,0 +1,420 @@
|
|||||||
|
<?xml?>
|
||||||
|
|
||||||
|
<tm2>
|
||||||
|
<type id="AQDG_GRAPH_CATEGORY" type="pointer">
|
||||||
|
<descr>
|
||||||
|
This class describes a set of report data for a given category.
|
||||||
|
</descr>
|
||||||
|
<lang id="c">
|
||||||
|
<identifier>AQDG_GRAPH_CATEGORY</identifier>
|
||||||
|
<prefix>AQDG_Graph_Category</prefix>
|
||||||
|
<baseFileName>category</baseFileName>
|
||||||
|
|
||||||
|
<flags>
|
||||||
|
with_list2
|
||||||
|
with_tree2
|
||||||
|
</flags>
|
||||||
|
|
||||||
|
<headers>
|
||||||
|
<header type="sys" loc="pre">aqdiagram/aqdg_api.h</header>
|
||||||
|
<header type="sys" loc="pre">aqdiagram/graph/datapair.h</header>
|
||||||
|
<header type="sys" loc="pre">gwenhywfar/path.h</header>
|
||||||
|
</headers>
|
||||||
|
|
||||||
|
<inlines>
|
||||||
|
|
||||||
|
<inline loc="end" access="public">
|
||||||
|
<content>
|
||||||
|
$(api) void $(struct_prefix)_AddDataPair($(struct_type) *st, AQDG_GRAPH_DATAPAIR *dp);
|
||||||
|
</content>
|
||||||
|
</inline>
|
||||||
|
|
||||||
|
<inline loc="code">
|
||||||
|
<content>
|
||||||
|
void $(struct_prefix)_AddDataPair($(struct_type) *st, AQDG_GRAPH_DATAPAIR *dp) \n
|
||||||
|
{ \n
|
||||||
|
if (st && dp) { \n
|
||||||
|
double v; \n
|
||||||
|
\n
|
||||||
|
v=AQDG_Graph_DataPair_GetValueY(dp); \n
|
||||||
|
if (st->dataPairList==NULL) \n
|
||||||
|
st->dataPairList=AQDG_Graph_DataPair_List_new(); \n
|
||||||
|
AQDG_Graph_DataPair_List_Add(dp, st->dataPairList); \n
|
||||||
|
st->totalAmount+=v; \n
|
||||||
|
if (v<0.0) \n
|
||||||
|
st->negAmount+=v; \n
|
||||||
|
else \n
|
||||||
|
st->posAmount+=v; \n
|
||||||
|
} \n
|
||||||
|
} \n
|
||||||
|
</content>
|
||||||
|
</inline>
|
||||||
|
|
||||||
|
|
||||||
|
<inline loc="end" access="public">
|
||||||
|
<content>
|
||||||
|
$(api) void $(struct_prefix)_AddValue($(struct_type) *st, double v);
|
||||||
|
</content>
|
||||||
|
</inline>
|
||||||
|
|
||||||
|
<inline loc="code">
|
||||||
|
<content>
|
||||||
|
void $(struct_prefix)_AddValue($(struct_type) *st, double v) \n
|
||||||
|
{ \n
|
||||||
|
if (st) { \n
|
||||||
|
st->totalAmount+=v; \n
|
||||||
|
if (v<0.0) \n
|
||||||
|
st->negAmount+=v; \n
|
||||||
|
else \n
|
||||||
|
st->posAmount+=v; \n
|
||||||
|
} \n
|
||||||
|
} \n
|
||||||
|
</content>
|
||||||
|
</inline>
|
||||||
|
|
||||||
|
|
||||||
|
<inline loc="end" access="public">
|
||||||
|
<content>
|
||||||
|
$(api) int $(struct_prefix)_Tree2_AddDataPair($(struct_type) *st, AQDG_GRAPH_DATAPAIR *dp);
|
||||||
|
</content>
|
||||||
|
</inline>
|
||||||
|
|
||||||
|
<inline loc="code">
|
||||||
|
<content>
|
||||||
|
int $(struct_prefix)_Tree2_AddDataPair($(struct_type) *st, AQDG_GRAPH_DATAPAIR *dp) \n
|
||||||
|
{ \n
|
||||||
|
uint32_t categoryId; \n
|
||||||
|
\n
|
||||||
|
categoryId=AQDG_Graph_DataPair_GetCategoryId(dp); \n
|
||||||
|
if (categoryId) { \n
|
||||||
|
AQDG_GRAPH_CATEGORY *cat; \n
|
||||||
|
\n
|
||||||
|
cat=AQDG_Graph_Category_Tree2_GetByCategoryId(st, categoryId); \n
|
||||||
|
if (cat) { \n
|
||||||
|
AQDG_Graph_Category_AddDataPair(cat, dp); \n
|
||||||
|
return 0; \n
|
||||||
|
} \n
|
||||||
|
} \n
|
||||||
|
return GWEN_ERROR_NOT_FOUND; \n
|
||||||
|
} \n
|
||||||
|
</content>
|
||||||
|
</inline>
|
||||||
|
|
||||||
|
|
||||||
|
<inline loc="end" access="public">
|
||||||
|
<content>
|
||||||
|
$(api) int $(struct_prefix)_Tree2_AddValue($(struct_type) *st, uint32_t categoryId, double v);
|
||||||
|
</content>
|
||||||
|
</inline>
|
||||||
|
|
||||||
|
<inline loc="code">
|
||||||
|
<content>
|
||||||
|
int $(struct_prefix)_Tree2_AddValue($(struct_type) *st, uint32_t categoryId, double v) \n
|
||||||
|
{ \n
|
||||||
|
if (categoryId) { \n
|
||||||
|
AQDG_GRAPH_CATEGORY *cat; \n
|
||||||
|
\n
|
||||||
|
cat=AQDG_Graph_Category_Tree2_GetByCategoryId(st, categoryId); \n
|
||||||
|
if (cat) { \n
|
||||||
|
AQDG_Graph_Category_AddValue(cat, v); \n
|
||||||
|
return 0; \n
|
||||||
|
} \n
|
||||||
|
} \n
|
||||||
|
return GWEN_ERROR_NOT_FOUND; \n
|
||||||
|
} \n
|
||||||
|
</content>
|
||||||
|
</inline>
|
||||||
|
|
||||||
|
|
||||||
|
<inline loc="end" access="public">
|
||||||
|
<content>
|
||||||
|
$(api) void $(struct_prefix)_Tree2_SumUpChildren($(struct_type) *st);
|
||||||
|
</content>
|
||||||
|
</inline>
|
||||||
|
|
||||||
|
<inline loc="code">
|
||||||
|
<content>
|
||||||
|
void $(struct_prefix)_Tree2_SumUpChildren($(struct_type) *st) \n
|
||||||
|
{ \n
|
||||||
|
if (st) { \n
|
||||||
|
$(struct_type) *child; \n
|
||||||
|
\n
|
||||||
|
child=$(struct_prefix)_Tree2_GetFirstChild(st); \n
|
||||||
|
while (child) { \n
|
||||||
|
$(struct_prefix)_Tree2_SumUpChildren(child); \n
|
||||||
|
st->totalAmount+=child->totalAmount; \n
|
||||||
|
st->negAmount+=child->negAmount; \n
|
||||||
|
st->posAmount+=child->posAmount; \n
|
||||||
|
child=AQDG_Graph_Category_Tree2_GetNext(child); \n
|
||||||
|
} \n
|
||||||
|
} \n
|
||||||
|
} \n
|
||||||
|
</content>
|
||||||
|
</inline>
|
||||||
|
|
||||||
|
|
||||||
|
<inline loc="end" access="public">
|
||||||
|
<content>
|
||||||
|
$(api) void $(struct_prefix)_Tree2_MarkCategoriesWithDataPairs($(struct_type) *st);
|
||||||
|
</content>
|
||||||
|
</inline>
|
||||||
|
|
||||||
|
<inline loc="code">
|
||||||
|
<content>
|
||||||
|
void $(struct_prefix)_Tree2_MarkCategoriesWithDataPairs($(struct_type) *st) \n
|
||||||
|
{ \n
|
||||||
|
while (st) { \n
|
||||||
|
if (st->dataPairList && AQDG_Graph_DataPair_List_GetCount(st->dataPairList)) \n
|
||||||
|
st->flags|=$(struct_type)_FLAGS_SELECTED; \n
|
||||||
|
st=AQDG_Graph_Category_Tree2_GetBelow(st); \n
|
||||||
|
} \n
|
||||||
|
} \n
|
||||||
|
</content>
|
||||||
|
</inline>
|
||||||
|
|
||||||
|
|
||||||
|
<inline loc="end" access="public">
|
||||||
|
<content>
|
||||||
|
$(api) void $(struct_prefix)_Tree2_SubFlags($(struct_type) *st, uint32_t flags);
|
||||||
|
</content>
|
||||||
|
</inline>
|
||||||
|
|
||||||
|
<inline loc="code">
|
||||||
|
<content>
|
||||||
|
void $(struct_prefix)_Tree2_SubFlags($(struct_type) *st, uint32_t flags) \n
|
||||||
|
{ \n
|
||||||
|
while (st) { \n
|
||||||
|
st->flags&=~flags; \n
|
||||||
|
st=AQDG_Graph_Category_Tree2_GetBelow(st); \n
|
||||||
|
} \n
|
||||||
|
} \n
|
||||||
|
</content>
|
||||||
|
</inline>
|
||||||
|
|
||||||
|
|
||||||
|
<inline loc="end" access="public">
|
||||||
|
<content>
|
||||||
|
$(api) void $(struct_prefix)_Tree2_SubFlagsDown($(struct_type) *st, uint32_t flags);
|
||||||
|
</content>
|
||||||
|
</inline>
|
||||||
|
|
||||||
|
<inline loc="code">
|
||||||
|
<content>
|
||||||
|
void $(struct_prefix)_Tree2_SubFlagsDown($(struct_type) *st, uint32_t flags) \n
|
||||||
|
{ \n
|
||||||
|
if (st) { \n
|
||||||
|
st->flags&=~flags; \n
|
||||||
|
st=$(struct_prefix)_Tree2_GetFirstChild(st); \n
|
||||||
|
while (st) { \n
|
||||||
|
$(struct_prefix)_Tree2_SubFlagsDown(st, flags); \n
|
||||||
|
st=AQDG_Graph_Category_Tree2_GetNext(st); \n
|
||||||
|
} \n
|
||||||
|
} \n
|
||||||
|
} \n
|
||||||
|
</content>
|
||||||
|
</inline>
|
||||||
|
|
||||||
|
|
||||||
|
<inline loc="end" access="public">
|
||||||
|
<content>
|
||||||
|
$(api) void $(struct_prefix)_Tree2_AddFlagsDown($(struct_type) *st, uint32_t flags);
|
||||||
|
</content>
|
||||||
|
</inline>
|
||||||
|
|
||||||
|
<inline loc="code">
|
||||||
|
<content>
|
||||||
|
void $(struct_prefix)_Tree2_AddFlagsDown($(struct_type) *st, uint32_t flags) \n
|
||||||
|
{ \n
|
||||||
|
if (st) { \n
|
||||||
|
st->flags|=flags; \n
|
||||||
|
st=$(struct_prefix)_Tree2_GetFirstChild(st); \n
|
||||||
|
while (st) { \n
|
||||||
|
$(struct_prefix)_Tree2_AddFlagsDown(st, flags); \n
|
||||||
|
st=AQDG_Graph_Category_Tree2_GetNext(st); \n
|
||||||
|
} \n
|
||||||
|
} \n
|
||||||
|
} \n
|
||||||
|
</content>
|
||||||
|
</inline>
|
||||||
|
|
||||||
|
|
||||||
|
<inline loc="end" access="public">
|
||||||
|
<content>
|
||||||
|
$(api) void $(struct_prefix)_Tree2_AddFlagsUp($(struct_type) *st, uint32_t flags);
|
||||||
|
</content>
|
||||||
|
</inline>
|
||||||
|
|
||||||
|
<inline loc="code">
|
||||||
|
<content>
|
||||||
|
void $(struct_prefix)_Tree2_AddFlagsUp($(struct_type) *st, uint32_t flags) \n
|
||||||
|
{ \n
|
||||||
|
while (st) { \n
|
||||||
|
st->flags|=flags; \n
|
||||||
|
st=AQDG_Graph_Category_Tree2_GetParent(st); \n
|
||||||
|
} \n
|
||||||
|
} \n
|
||||||
|
</content>
|
||||||
|
</inline>
|
||||||
|
|
||||||
|
|
||||||
|
<inline loc="code">
|
||||||
|
<content>
|
||||||
|
static void* _handlePath(const char *aname, void *data, int idx, uint32_t flags) \n
|
||||||
|
{ \n
|
||||||
|
$(struct_type) *st; \n
|
||||||
|
\n
|
||||||
|
st=($(struct_type)*) data; \n
|
||||||
|
if (st) { \n
|
||||||
|
if (flags & GWEN_PATH_FLAGS_ROOT) { \n
|
||||||
|
while($(struct_prefix)_Tree2_GetParent(st)) \n
|
||||||
|
st=$(struct_prefix)_Tree2_GetParent(st); \n
|
||||||
|
return st; \n
|
||||||
|
} \n
|
||||||
|
\n
|
||||||
|
if (strcasecmp(aname, "..")==0) \n
|
||||||
|
return $(struct_prefix)_Tree2_GetParent(st); \n
|
||||||
|
else if (strcasecmp(aname, ".")==0) \n
|
||||||
|
return st; \n
|
||||||
|
\n
|
||||||
|
st=$(struct_prefix)_Tree2_GetFirstChild(st); \n
|
||||||
|
while(st) { \n
|
||||||
|
const char *s; \n
|
||||||
|
\n
|
||||||
|
s=$(struct_prefix)_GetName(st); \n
|
||||||
|
if (s && strcasecmp(s, aname)==0) \n
|
||||||
|
return st; \n
|
||||||
|
st=$(struct_prefix)_Tree2_GetNext(st); \n
|
||||||
|
} \n
|
||||||
|
} \n
|
||||||
|
return NULL; \n
|
||||||
|
} \n
|
||||||
|
</content>
|
||||||
|
</inline>
|
||||||
|
|
||||||
|
|
||||||
|
<inline loc="end" access="public">
|
||||||
|
<content>
|
||||||
|
$(api) $(struct_type)* $(struct_prefix)_Tree2_GetByPath(const $(struct_type) *st, const char *path);
|
||||||
|
</content>
|
||||||
|
</inline>
|
||||||
|
|
||||||
|
<inline loc="code">
|
||||||
|
<content>
|
||||||
|
$(struct_type)* $(struct_prefix)_Tree2_GetByPath(const $(struct_type) *st, const char *path) \n
|
||||||
|
{ \n
|
||||||
|
return GWEN_Path_HandleWithIdx(path, (void*) st, GWEN_PATH_FLAGS_NAMEMUSTEXIST, _handlePath); \n
|
||||||
|
} \n
|
||||||
|
</content>
|
||||||
|
</inline>
|
||||||
|
|
||||||
|
|
||||||
|
<inline loc="end" access="public">
|
||||||
|
<content>
|
||||||
|
$(api) void $(struct_prefix)_Tree2_CollectChildrenDataPairs($(struct_type) *st);
|
||||||
|
</content>
|
||||||
|
</inline>
|
||||||
|
|
||||||
|
<inline loc="code">
|
||||||
|
<content>
|
||||||
|
void $(struct_prefix)_Tree2_CollectChildrenDataPairs($(struct_type) *st) \n
|
||||||
|
{ \n
|
||||||
|
if (st) { \n
|
||||||
|
$(struct_type) *child; \n
|
||||||
|
\n
|
||||||
|
child=$(struct_prefix)_Tree2_GetFirstChild(st); \n
|
||||||
|
while(child) { \n
|
||||||
|
$(struct_prefix)_Tree2_CollectChildrenDataPairs(child); \n
|
||||||
|
if (child->dataPairList) { \n
|
||||||
|
AQDG_GRAPH_DATAPAIR *dp; \n
|
||||||
|
\n
|
||||||
|
while( (dp=AQDG_Graph_DataPair_List_First(child->dataPairList)) ){ \n
|
||||||
|
AQDG_Graph_DataPair_List_Del(dp); \n
|
||||||
|
$(struct_prefix)_AddDataPair(st, dp); \n
|
||||||
|
} \n
|
||||||
|
} \n
|
||||||
|
child=$(struct_prefix)_Tree2_GetNext(child); \n
|
||||||
|
} \n
|
||||||
|
} \n
|
||||||
|
} \n
|
||||||
|
</content>
|
||||||
|
</inline>
|
||||||
|
|
||||||
|
|
||||||
|
</inlines>
|
||||||
|
|
||||||
|
</lang>
|
||||||
|
|
||||||
|
<defines>
|
||||||
|
<define id="$(struct_type)_FLAGS" prefix="AQDG_GRAPH_CATEGORY_FLAGS_">
|
||||||
|
<item name="MODIFIED" value="0x00000001" />
|
||||||
|
<item name="SELECTED" value="0x00000002" />
|
||||||
|
</define>
|
||||||
|
|
||||||
|
</defines>
|
||||||
|
|
||||||
|
<members>
|
||||||
|
|
||||||
|
<member name="flags" type="uint32_t" maxlen="8">
|
||||||
|
<default>0</default>
|
||||||
|
<preset>0</preset>
|
||||||
|
<flags>with_flags</flags>
|
||||||
|
<access>public</access>
|
||||||
|
</member>
|
||||||
|
|
||||||
|
<member name="categoryId" type="uint32_t" maxlen="8">
|
||||||
|
<default>0</default>
|
||||||
|
<preset>0</preset>
|
||||||
|
<flags>none with_getbymember</flags>
|
||||||
|
<access>public</access>
|
||||||
|
</member>
|
||||||
|
|
||||||
|
<member name="name" type="char_ptr" maxlen="256" >
|
||||||
|
<access>public</access>
|
||||||
|
<flags>own with_getbymember</flags>
|
||||||
|
<setflags>const dup</setflags>
|
||||||
|
<getflags>const</getflags>
|
||||||
|
</member>
|
||||||
|
|
||||||
|
<member name="label" type="char_ptr" maxlen="256" >
|
||||||
|
<access>public</access>
|
||||||
|
<flags>own with_getbymember</flags>
|
||||||
|
<setflags>const dup</setflags>
|
||||||
|
<getflags>const</getflags>
|
||||||
|
</member>
|
||||||
|
|
||||||
|
<member name="totalAmount" type="double" maxlen="8" >
|
||||||
|
<default>0.0</default>
|
||||||
|
<preset>0.0</preset>
|
||||||
|
<access>public</access>
|
||||||
|
<flags>sortbymember</flags>
|
||||||
|
</member>
|
||||||
|
|
||||||
|
<member name="negAmount" type="double" maxlen="8" >
|
||||||
|
<default>0.0</default>
|
||||||
|
<preset>0.0</preset>
|
||||||
|
<access>public</access>
|
||||||
|
<flags>sortbymember</flags>
|
||||||
|
</member>
|
||||||
|
|
||||||
|
<member name="posAmount" type="double" maxlen="8" >
|
||||||
|
<default>0.0</default>
|
||||||
|
<preset>0.0</preset>
|
||||||
|
<access>public</access>
|
||||||
|
<flags>sortbymember</flags>
|
||||||
|
</member>
|
||||||
|
|
||||||
|
<member name="dataPairList" type="AQDG_GRAPH_DATAPAIR_LIST" >
|
||||||
|
<default>NULL</default>
|
||||||
|
<preset>NULL</preset>
|
||||||
|
<access>public</access>
|
||||||
|
<flags>own</flags>
|
||||||
|
<setflags>nodup</setflags>
|
||||||
|
<getflags>none</getflags>
|
||||||
|
</member>
|
||||||
|
|
||||||
|
</members>
|
||||||
|
|
||||||
|
</type>
|
||||||
|
|
||||||
|
</tm2>
|
||||||
|
|
||||||
@@ -22,6 +22,82 @@
|
|||||||
<header type="sys" loc="pre">aqdiagram/aqdg_api.h</header>
|
<header type="sys" loc="pre">aqdiagram/aqdg_api.h</header>
|
||||||
</headers>
|
</headers>
|
||||||
|
|
||||||
|
<inlines>
|
||||||
|
<inline loc="end" access="public">
|
||||||
|
<content>
|
||||||
|
$(api) double $(struct_prefix)_List_GetMinDiffX(const $(struct_type)_LIST *st);
|
||||||
|
</content>
|
||||||
|
</inline>
|
||||||
|
|
||||||
|
<inline loc="code">
|
||||||
|
<content>
|
||||||
|
double $(struct_prefix)_List_GetMinDiffX(const $(struct_type)_LIST *stList) \n
|
||||||
|
{ \n
|
||||||
|
int idx=0; \n
|
||||||
|
double diff=0.0; \n
|
||||||
|
const $(struct_type) *dp; \n
|
||||||
|
const $(struct_type) *dpPrevious=NULL; \n
|
||||||
|
\n
|
||||||
|
dp=$(struct_prefix)_List_First(stList); \n
|
||||||
|
while(dp) { \n
|
||||||
|
if (idx==1) \n
|
||||||
|
diff=dp->valueX-dpPrevious->valueX; \n
|
||||||
|
else if (idx>1) { \n
|
||||||
|
double newDiff; \n
|
||||||
|
\n
|
||||||
|
newDiff=dp->valueX-dpPrevious->valueX; \n
|
||||||
|
if (newDiff<diff) \n
|
||||||
|
diff=newDiff; \n
|
||||||
|
} \n
|
||||||
|
dpPrevious=dp; \n
|
||||||
|
idx++; \n
|
||||||
|
\n
|
||||||
|
dp=$(struct_prefix)_List_Next(dp); \n
|
||||||
|
} \n
|
||||||
|
return diff; \n
|
||||||
|
} \n
|
||||||
|
</content>
|
||||||
|
</inline>
|
||||||
|
|
||||||
|
<inline loc="end" access="public">
|
||||||
|
<content>
|
||||||
|
$(api) double $(struct_prefix)_List_GetMinDiffY(const $(struct_type)_LIST *st);
|
||||||
|
</content>
|
||||||
|
</inline>
|
||||||
|
|
||||||
|
<inline loc="code">
|
||||||
|
<content>
|
||||||
|
double $(struct_prefix)_List_GetMinDiffY(const $(struct_type)_LIST *stList) \n
|
||||||
|
{ \n
|
||||||
|
int idx=0; \n
|
||||||
|
double diff=0.0; \n
|
||||||
|
const $(struct_type) *dp; \n
|
||||||
|
const $(struct_type) *dpPrevious=NULL; \n
|
||||||
|
\n
|
||||||
|
dp=$(struct_prefix)_List_First(stList); \n
|
||||||
|
while(dp) { \n
|
||||||
|
if (idx==1) \n
|
||||||
|
diff=dp->valueY-dpPrevious->valueY; \n
|
||||||
|
else if (idx>1) { \n
|
||||||
|
double newDiff; \n
|
||||||
|
\n
|
||||||
|
newDiff=dp->valueY-dpPrevious->valueY; \n
|
||||||
|
if (newDiff<diff) \n
|
||||||
|
diff=newDiff; \n
|
||||||
|
} \n
|
||||||
|
dpPrevious=dp; \n
|
||||||
|
idx++; \n
|
||||||
|
\n
|
||||||
|
dp=$(struct_prefix)_List_Next(dp); \n
|
||||||
|
} \n
|
||||||
|
return diff; \n
|
||||||
|
} \n
|
||||||
|
</content>
|
||||||
|
</inline>
|
||||||
|
|
||||||
|
</inlines>
|
||||||
|
|
||||||
|
|
||||||
</lang>
|
</lang>
|
||||||
|
|
||||||
<members>
|
<members>
|
||||||
|
|||||||
@@ -22,14 +22,21 @@
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* definitions
|
||||||
|
* ------------------------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define AQDG_TIMEGRAPH_MARGINSPERCENT_X 1.0
|
||||||
|
#define AQDG_TIMEGRAPH_MARGINSPERCENT_Y 10.0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* forward declarations
|
* forward declarations
|
||||||
* ------------------------------------------------------------------------------------------------
|
* ------------------------------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void _setupTicksForTimeAxis(AQDG_GRAPH_AXIS *axis);
|
|
||||||
static void _setupTicksForDataAxis(AQDG_GRAPH_AXIS *axis);
|
|
||||||
static int _readNumFromString(const char **sPtr);
|
static int _readNumFromString(const char **sPtr);
|
||||||
|
|
||||||
|
|
||||||
@@ -39,8 +46,6 @@ static int _readNumFromString(const char **sPtr);
|
|||||||
* ------------------------------------------------------------------------------------------------
|
* ------------------------------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
AQDG_GRAPH *AQDG_TimeGraph_new(const char *sTitle,
|
AQDG_GRAPH *AQDG_TimeGraph_new(const char *sTitle,
|
||||||
const char *sSubTitle,
|
const char *sSubTitle,
|
||||||
const char *sYLabel,
|
const char *sYLabel,
|
||||||
@@ -104,92 +109,21 @@ void AQDG_TimeGraph_SetupTicks(AQDG_GRAPH *g, uint32_t flags, double minY, doubl
|
|||||||
/* create ticks for X axis */
|
/* create ticks for X axis */
|
||||||
axis=AQDG_Graph_GetAxisByIndex(g, AQDG_GRAPH_AXISPOS_BOTTOM);
|
axis=AQDG_Graph_GetAxisByIndex(g, AQDG_GRAPH_AXISPOS_BOTTOM);
|
||||||
if (axis) {
|
if (axis) {
|
||||||
_setupTicksForTimeAxis(axis);
|
AQDG_Graph_Axis_AddMargins(axis, AQDG_TIMEGRAPH_MARGINSPERCENT_X);
|
||||||
|
AQDG_Graph_Axis_GenTimeTicks(axis);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* create ticks for Y axis */
|
/* create ticks for Y axis */
|
||||||
axis=AQDG_Graph_GetAxisByIndex(g, AQDG_GRAPH_AXISPOS_LEFT);
|
axis=AQDG_Graph_GetAxisByIndex(g, AQDG_GRAPH_AXISPOS_LEFT);
|
||||||
if (axis) {
|
if (axis) {
|
||||||
double vMax;
|
AQDG_Graph_Axis_AddMargins(axis, AQDG_TIMEGRAPH_MARGINSPERCENT_Y);
|
||||||
double vMin;
|
|
||||||
double vDiff;
|
|
||||||
|
|
||||||
vMin=AQDG_Graph_Axis_GetMinValue(axis);
|
|
||||||
vMax=AQDG_Graph_Axis_GetMaxValue(axis);
|
|
||||||
vDiff=vMax-vMin;
|
|
||||||
DBG_ERROR(NULL, "old vMin=%.2f, vMax=%.2f", vMin, vMax);
|
|
||||||
|
|
||||||
if (vDiff==0.0) {
|
|
||||||
DBG_ERROR(NULL, "min = max = %.2f", vMax);
|
|
||||||
vDiff=vMax;
|
|
||||||
if (vDiff==0.0)
|
|
||||||
vDiff=1.0;
|
|
||||||
}
|
|
||||||
if (vDiff>0.0) {
|
|
||||||
double vDiffBy10;
|
|
||||||
|
|
||||||
DBG_ERROR(NULL, "Setting vmin and vmax");
|
|
||||||
vDiffBy10=vDiff/10.0;
|
|
||||||
vMin-=vDiffBy10;
|
|
||||||
vMax+=vDiffBy10;
|
|
||||||
DBG_ERROR(NULL, "new vMin=%.2f, vMax=%.2f", vMin, vMax);
|
|
||||||
AQDG_Graph_Axis_SetMinValue(axis, vMin);
|
|
||||||
AQDG_Graph_Axis_SetMaxValue(axis, vMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (flags & AQDG_TIMEGRAPH_SETUPTICKS_FLAGS_MINY)
|
if (flags & AQDG_TIMEGRAPH_SETUPTICKS_FLAGS_MINY)
|
||||||
AQDG_Graph_Axis_SetMinValue(axis, minY);
|
AQDG_Graph_Axis_SetMinValue(axis, minY);
|
||||||
if (flags & AQDG_TIMEGRAPH_SETUPTICKS_FLAGS_MAXY)
|
if (flags & AQDG_TIMEGRAPH_SETUPTICKS_FLAGS_MAXY)
|
||||||
AQDG_Graph_Axis_SetMaxValue(axis, maxY);
|
AQDG_Graph_Axis_SetMaxValue(axis, maxY);
|
||||||
_setupTicksForDataAxis(axis);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void _setupTicksForTimeAxis(AQDG_GRAPH_AXIS *axis)
|
|
||||||
{
|
|
||||||
#if 0
|
|
||||||
double minValue;
|
|
||||||
double maxValue;
|
|
||||||
double diffInDays;
|
|
||||||
|
|
||||||
minValue=AQDG_Graph_Axis_GetMinValue(axis);
|
|
||||||
maxValue=AQDG_Graph_Axis_GetMaxValue(axis);
|
|
||||||
diffInDays=(maxValue-minValue)/(24*60*60);
|
|
||||||
DBG_ERROR(AQDG_LOGDOMAIN, "Difference in days: %f.0", diffInDays);
|
|
||||||
if (diffInDays<3) {
|
|
||||||
AQDG_Graph_Axis_GenHourTicks(axis, 0, 1);
|
|
||||||
}
|
|
||||||
else if (diffInDays<32) {
|
|
||||||
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) {
|
|
||||||
AQDG_Graph_Axis_GenWeekTicks(axis, 0);
|
|
||||||
AQDG_Graph_Axis_GenDayTicks(axis, 1);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
AQDG_Graph_Axis_GenMonthTicks(axis, 0);
|
|
||||||
if (diffInDays<100) {
|
|
||||||
AQDG_Graph_Axis_GenDayTicks(axis, 1);
|
|
||||||
}
|
|
||||||
else if (diffInDays<400) {
|
|
||||||
AQDG_Graph_Axis_GenWeekTicks(axis, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
AQDG_Graph_Axis_GenTimeTicks(axis);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void _setupTicksForDataAxis(AQDG_GRAPH_AXIS *axis)
|
|
||||||
{
|
|
||||||
AQDG_Graph_Axis_GenLog10Ticks(axis);
|
AQDG_Graph_Axis_GenLog10Ticks(axis);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ static int _screenDistBetweenLevelTicksX(const AQDG_GRAPH_TICK_LIST *tickList, i
|
|||||||
int contentSize, double minValue, double maxValue);
|
int contentSize, double minValue, double maxValue);
|
||||||
static int _screenDistBetweenLevelTicksY(const AQDG_GRAPH_TICK_LIST *tickList, int lvl,
|
static int _screenDistBetweenLevelTicksY(const AQDG_GRAPH_TICK_LIST *tickList, int lvl,
|
||||||
int contentSize, double minValue, double maxValue);
|
int contentSize, double minValue, double maxValue);
|
||||||
|
static int _distToScreenDist(int contentSize, double minValue, double maxValue, double value);
|
||||||
|
|
||||||
static void _drawCurveLines(AQDG_OBJECT *o, AQDG_DRAW_CONTEXT *dc, const AQDG_GRAPH_CURVE *curve,
|
static void _drawCurveLines(AQDG_OBJECT *o, AQDG_DRAW_CONTEXT *dc, const AQDG_GRAPH_CURVE *curve,
|
||||||
double minValueX, double maxValueX, double minValueY, double maxValueY,
|
double minValueX, double maxValueX, double minValueY, double maxValueY,
|
||||||
@@ -50,6 +51,9 @@ static void _drawCurvePoints(AQDG_OBJECT *o, AQDG_DRAW_CONTEXT *dc, const AQDG_G
|
|||||||
static void _drawCurveStepLines(AQDG_OBJECT *o, AQDG_DRAW_CONTEXT *dc, const AQDG_GRAPH_CURVE *curve,
|
static void _drawCurveStepLines(AQDG_OBJECT *o, AQDG_DRAW_CONTEXT *dc, const AQDG_GRAPH_CURVE *curve,
|
||||||
double minValueX, double maxValueX, double minValueY, double maxValueY,
|
double minValueX, double maxValueX, double minValueY, double maxValueY,
|
||||||
int pen);
|
int pen);
|
||||||
|
static void _drawCurveVertBars(AQDG_OBJECT *o, AQDG_DRAW_CONTEXT *dc, const AQDG_GRAPH_CURVE *curve,
|
||||||
|
double minValueX, double maxValueX, double minValueY, double maxValueY,
|
||||||
|
int pen);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -193,6 +197,8 @@ void _drawCurve(AQDG_OBJECT *o, AQDG_DRAW_CONTEXT *dc, const AQDG_GRAPH_CURVE *c
|
|||||||
_drawCurveStepLines(o, dc, curve, minValueX, maxValueX, minValueY, maxValueY, pen);
|
_drawCurveStepLines(o, dc, curve, minValueX, maxValueX, minValueY, maxValueY, pen);
|
||||||
break;
|
break;
|
||||||
case AQDG_GRAPH_TYPE_BARS:
|
case AQDG_GRAPH_TYPE_BARS:
|
||||||
|
_drawCurveVertBars(o, dc, curve, minValueX, maxValueX, minValueY, maxValueY, pen);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -327,12 +333,7 @@ void _drawHorizontalGrid(AQDG_OBJECT *o, AQDG_DRAW_CONTEXT *dc)
|
|||||||
int _screenDistBetweenLevelTicksX(const AQDG_GRAPH_TICK_LIST *tickList, int lvl,
|
int _screenDistBetweenLevelTicksX(const AQDG_GRAPH_TICK_LIST *tickList, int lvl,
|
||||||
int contentSize, double minValue, double maxValue)
|
int contentSize, double minValue, double maxValue)
|
||||||
{
|
{
|
||||||
double v;
|
return _distToScreenDist(contentSize, minValue, maxValue, AQDG_Graph_Tick_List_DistanceBetweenTicks(tickList, lvl));
|
||||||
int pts;
|
|
||||||
|
|
||||||
v=AQDG_Graph_Tick_List_DistanceBetweenTicks(tickList, lvl);
|
|
||||||
pts=(v*(contentSize/(maxValue-minValue)));
|
|
||||||
return pts;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -343,17 +344,20 @@ int _screenDistBetweenLevelTicksY(const AQDG_GRAPH_TICK_LIST *tickList, int lvl,
|
|||||||
const AQDG_GRAPH_TICK *firstLevelTick;
|
const AQDG_GRAPH_TICK *firstLevelTick;
|
||||||
|
|
||||||
firstLevelTick=AQDG_Graph_Tick_List_GetFirstTickForLevel(tickList, lvl);
|
firstLevelTick=AQDG_Graph_Tick_List_GetFirstTickForLevel(tickList, lvl);
|
||||||
if (firstLevelTick) {
|
if (firstLevelTick)
|
||||||
double v;
|
return _distToScreenDist(contentSize, minValue, maxValue, AQDG_Graph_Tick_GetLevelDist(firstLevelTick));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int _distToScreenDist(int contentSize, double minValue, double maxValue, double value)
|
||||||
|
{
|
||||||
int pts;
|
int pts;
|
||||||
|
|
||||||
v=AQDG_Graph_Tick_GetLevelDist(firstLevelTick);
|
pts=(value*(contentSize/(maxValue-minValue)));
|
||||||
pts=(v*(contentSize/(maxValue-minValue)));
|
|
||||||
DBG_ERROR(NULL, "Level dist %d: %d", lvl, pts);
|
|
||||||
return pts;
|
return pts;
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -489,6 +493,76 @@ void _drawCurveStepLines(AQDG_OBJECT *o, AQDG_DRAW_CONTEXT *dc, const AQDG_GRAPH
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void _drawCurveVertBars(AQDG_OBJECT *o, AQDG_DRAW_CONTEXT *dc, const AQDG_GRAPH_CURVE *curve,
|
||||||
|
double minValueX, double maxValueX, double minValueY, double maxValueY,
|
||||||
|
int pen)
|
||||||
|
{
|
||||||
|
const AQDG_GRAPH_DATAPAIR_LIST *dpList;
|
||||||
|
const AQDG_GRAPH_DATAPAIR *dp;
|
||||||
|
|
||||||
|
dpList=AQDG_Graph_Curve_GetDataPairs(curve);
|
||||||
|
dp=dpList?AQDG_Graph_DataPair_List_First(dpList):NULL;
|
||||||
|
if (dp) {
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
int absX;
|
||||||
|
int absY;
|
||||||
|
double valueMinDist;
|
||||||
|
int barWidth;
|
||||||
|
double baseLineValueY;
|
||||||
|
int baseLinePosY;
|
||||||
|
|
||||||
|
absX=AQDG_Object_GetAbsoluteX(o);
|
||||||
|
absY=AQDG_Object_GetAbsoluteY(o);
|
||||||
|
width=AQDG_Object_GetWidth(o);
|
||||||
|
height=AQDG_Object_GetHeight(o);
|
||||||
|
valueMinDist=AQDG_Graph_DataPair_List_GetMinDiffX(dpList);
|
||||||
|
barWidth=_distToScreenDist(width, minValueX, maxValueX, (valueMinDist*5.0)/6.0);
|
||||||
|
|
||||||
|
if (maxValueY<0.0)
|
||||||
|
baseLineValueY=maxValueY;
|
||||||
|
else if (minValueY>0.0)
|
||||||
|
baseLineValueY=minValueY;
|
||||||
|
else
|
||||||
|
baseLineValueY=0.0;
|
||||||
|
baseLinePosY=_calcVerticalPos(baseLineValueY, height, minValueY, maxValueY);
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
DBG_ERROR(NULL,
|
||||||
|
"valueMinDist=%.2f, barWidth=%d, baseLineValueY=%.2f, baseLinePosY=%d",
|
||||||
|
valueMinDist, barWidth, baseLineValueY, baseLinePosY);
|
||||||
|
#endif
|
||||||
|
while(dp) {
|
||||||
|
int pos;
|
||||||
|
int xPos1;
|
||||||
|
int xPos2;
|
||||||
|
int yPos;
|
||||||
|
int h;
|
||||||
|
double xValue;
|
||||||
|
double yValue;
|
||||||
|
|
||||||
|
xValue=AQDG_Graph_DataPair_GetValueX(dp);
|
||||||
|
yValue=AQDG_Graph_DataPair_GetValueY(dp);
|
||||||
|
|
||||||
|
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+xPos1, absY+yPos, (xPos2-xPos1)+1, h);
|
||||||
|
dp=AQDG_Graph_DataPair_List_Next(dp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user