Jump to content

Graph flashes and dissapears on initialization


Recommended Posts

Posted

I am using the following code to initialize a graph window:

static GGraphStyle graphStyle = {
    {GGRAPH_POINT_DOT, 0, Yellow},        {GGRAPH_LINE_NONE, 2, Gray},
    {GGRAPH_LINE_SOLID, 0, White},        {GGRAPH_LINE_SOLID, 0, White},
    {GGRAPH_LINE_DASH, 5, Gray, 10},      {GGRAPH_LINE_DOT, 7, Yellow, 19},
    GWIN_GRAPH_STYLE_POSITIVE_AXIS_ARROWS  // Flags
};

...

GWindowInit winInit;
gwinClearInit(&winInit);
winInit.show = gTrue;
winInit.x = winInit.y = 0;
winInit.width = gdispGetWidth();
winInit.height = 130;

temperatureGraph = gwinGraphCreate(&graphObj, &winInit);
gwinGraphSetOrigin(temperatureGraph, 0, 0);
gwinGraphSetStyle(temperatureGraph, &graphStyle);
gwinGraphDrawAxis(temperatureGraph);

Upon startup, I can see the graph but it quickly disappears. I have another label I constantly update and that works just fine. Any ideas as to what may be wrong? I could upload a video if that is allowed, but basically this is what happens:

  1. Screen starts up
  2. Label is shown on screen
  3. Graph is shown, quickly disappears
  4. Label proceeds to be updated.

I thought it could be the label updating procedure and I commented it out but the graph still disappeared.

Posted

Hello & Welcome to the µGFX community!

A notable difference between the Graph and the Label is that the Graph is just a window whereas the label is a widget. The documentation explains the differences. The most important one for you to know is that a widget knows how to redraw itself whereas a window does not (widgets inherit from windows).

The reason for the graph being just a window is that there wouldn't be any sensible way for us to know how to represent the data it shows in a generic, resource friendly manner. Most users either have a dedicated function to draw the entire graph (with data) and call that whenever necessary or they wrap it inside of a widget themselves.

Once the graph is shown, it should not disappear unless the area gets cleared (eg. because you call gdispClear() or draw something else over it). Is it possible that this happens somewhere?

I hope that helps. Please don't hesitate to ask if you have any further questions.

Posted

Thanks.

I tried it and it seems that the label does interfere with the graph. I think it may have to do with letting UGFX auto calculate the labels height. Removing the label does let the graph render properly.

Posted

I did some more testing. Creating the label does seem to interfere with the graph, however it seems the only thing that happens is  the axis disappears, the graph is still there as I can still draw points and they are displayed on screen. It seems as if the  axis disappear once the initialization function exits. If I redraw the axis in other parts of the code, they stay on screen. Weird but I guess its  solved.

 

Posted

Just to be clear: When you talk about 'label', you're referring to the GWIN Label Widget created via gwinLabelCreate() correct?
Does that label overlap the area of the graph?

 

8 hours ago, crazybolillo said:

[...] the axis disappears, the graph is still there as I can still draw points and they are displayed on screen. It seems as if the  axis disappear once the initialization function exits. If I redraw the axis in other parts of the code, they stay on screen. Weird but I guess its  solved.

That would be because the graph is a window and not a widget (explained above).
I do think that a better approach would be to promote the graph to become a widget too and then providing an interface to manage the plottable data. This is what most users of the graph widget end up doing anyway. Maybe we'll upgrade the built-in graph to facilitate this - Any feedback is welcomed :)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...