-
Notifications
You must be signed in to change notification settings - Fork 224
Description
Hi all,
I am using 0-17.2 of GUISlice and using the Graph element I have drawn this graph:
**
**
The reason I think this looks strange, is the plotted line is sitting between 20 and 22. Yet the Y axis scale is between 0 and 150.
I would say the half way point of this graph is 75, so I have roughly marked this as the red area:
Here I think you can see why I think this is off. I would expect the green line to be below the half way point of the lower half of the graph - but I do not think it is, it looks like it is in the upper half of that segment. This is
The relevant code sections are:
void updateGraph(int player_count,int max_players){
if(!set_graph_min_max){
char max_players_str[3];
sprintf(max_players_str,"%i",max_players);
uint16_t max = max_players;
gslc_ElemXGraphSetRange(&m_gui,m_pElemGraph1,0,max);
gslc_ElemSetTxtStr(&m_gui,YAxisMax,max_players_str);
gslc_ElemXGraphReset(&m_gui,m_pElemGraph1);
set_graph_min_max=true;
}
int16_t new_val = player_count;
gslc_ElemXGraphAdd(&m_gui,m_pElemGraph1,new_val);
}
That is used to add points to the graph and adjust the Y axis if needed.
The instantiation is handled by GUISliceBuilder 0.17.b40 generated code - namely:
// Create E_ELEM_BOX1 box
pElemRef = gslc_ElemCreateBox(&m_gui,E_ELEM_BOX1,E_PG_MAIN,(gslc_tsRect){3,75,205,78});
// Create graph E_ELEM_GRAPH1
pElemRef = gslc_ElemXGraphCreate(&m_gui,E_ELEM_GRAPH1,E_PG_MAIN,
&m_sGraph1,(gslc_tsRect){4,76,202,75},E_BUILTIN5X8,(int16_t*)&m_anGraphBuf1,
200,GSLC_COL_GREEN);
gslc_ElemXGraphSetStyle(&m_gui,pElemRef, GSLCX_GRAPH_STYLE_DOT, 5);
gslc_ElemSetCol(&m_gui,pElemRef,GSLC_COL_BROWN,GSLC_COL_BLACK,GSLC_COL_BLACK);
m_pElemGraph1 = pElemRef;
// Create Y_AXIS_MAX runtime modifiable text
static char m_sDisplayText9[4] = "120";
pElemRef = gslc_ElemCreateTxt(&m_gui,Y_AXIS_MAX,E_PG_MAIN,(gslc_tsRect){210,71,27,18},
(char*)m_sDisplayText9,4,E_BUILTIN5X8);
YAxisMax = pElemRef;
// Create Y_AXIS_MIN runtime modifiable text
static char m_sDisplayText10[2] = "0";
pElemRef = gslc_ElemCreateTxt(&m_gui,Y_AXIS_MIN,E_PG_MAIN,(gslc_tsRect){212,136,19,26},
(char*)m_sDisplayText10,2,E_BUILTIN5X8);
YAxisMin = pElemRef;
// Create X_AXIS_FIRSTTIME runtime modifiable text
static char m_sDisplayText12[6] = "12:00";
pElemRef = gslc_ElemCreateTxt(&m_gui,X_AXIS_FIRSTTIME,E_PG_MAIN,(gslc_tsRect){7,158,34,13},
(char*)m_sDisplayText12,6,E_BUILTIN5X8);
XAxisFirstTime = pElemRef;
// Create X_AXIS_MIDTIME runtime modifiable text
static char m_sDisplayText13[6] = "12:30";
pElemRef = gslc_ElemCreateTxt(&m_gui,X_AXIS_MIDTIME,E_PG_MAIN,(gslc_tsRect){92,158,38,16},
(char*)m_sDisplayText13,6,E_BUILTIN5X8);
XAxisMidTime = pElemRef;
// Create X_AXIS_CURRENT_TIME runtime modifiable text
static char m_sDisplayText14[6] = "13:00";
pElemRef = gslc_ElemCreateTxt(&m_gui,X_AXIS_CURRENT_TIME,E_PG_MAIN,(gslc_tsRect){179,156,38,16},
(char*)m_sDisplayText14,6,E_BUILTIN5X8);
XAxisCurrentTime = pElemRef;
I then made a test where I plot one point at 75, and the rest at 20. You can see the result of that here:
You can see the first 75 point is at the very top of the graph, not at the middle. So that suggests the total Y axis value of plotted points is wrong. Infact the 20 looks about in the right place if 75 was the max, but that could also be coincidental.
I thought I set that here:
gslc_ElemXGraphSetRange(&m_gui,m_pElemGraph1,0,max);
Where 0 is the min and max == 150 but clearly that is not doing what I think it should, or there is a bug, or I am doing something wrong!
Please help!