Project

General

Profile

WCartesianChart: Removing model column does not (completely) remove series (Wt 3.3.8)

Added by Charles Hubbard over 5 years ago

CentOS 7.6 64-bit, Wt 3.3.8

We have an application that allows a user to select (via WCheckBox) one or more sensors to be plotted in a WCartesianChart widget. Selecting a sensor creates a new column in the underlying WStandardItemModel. The column is then populated with the sensor data and the model header data associated with the column is assigned the sensor name (this becomes the series legend text). Next the new column is associated with a WDataSeries, and finally that series is added to the chart via chart->addSeries(series). When we do this, the column data is plotted fine and an entry for the sensor appears in the plot legend. So far, so good. That's all works great, but here's my problem.

When a user unchecks a sensor selection checkbox, the model column associated with that sensor is deleted from the model. When that happens, the series data also disappears from the plot but the sensor name is NOT removed from the chart's legend. I am a little confused on how this all works. The application runs exactly how I want it to run on CentOS 6 with Wt 3.3.0. Under 3.3.0, deleting the column from the model also appears to completely remove the associated series from the chart AND removes the associated label from the chart legend. But on Wt 3.3.8 the legend doesn't get cleaned up. So, for example, if I have a sensor "A" to plot, selecting its checkbox the first time adds "A" to the legend and plots the data. If I uncheck the checkbox, the plotted data disappears but the "A" label remains. If I then check the checkbox again, the plotted data returns but now there are two "A" entries in the legend (each assigned a different plot color). And I can keep doing that, building up more and more legend entries as I go.

Anyone know what I am doing wrong? I thought deleting the column the series was bound to would automatically clean up the series and remove all traces of it from the chart (i.e. remove its legend entry) and, under Wt 3.3.0 at least, that does seem to be the case. But not so under 3.3.8. I have tried to delete the series manually with chart->removeSeries(column) before removing the column from the model, but the resulting behavior is unstable. Sometimes it appears to work, sometimes it doesn't. Sometimes it removes the label ("A" in my example) from the legend, but leaves the little line color indicator on the legend.

Any help would be greatly appreciated!


Replies (3)

RE: WCartesianChart: Removing model column does not (completely) remove series (Wt 3.3.8) - Added by lm at over 5 years ago

That sounds tricky. Maybe others can help you, but what would help me help you is a minimum working example. You don't happen to have one of those, do you?

RE: WCartesianChart: Removing model column does not (completely) remove series (Wt 3.3.8) - Added by Charles Hubbard over 5 years ago

Thank you for your quick response.

At the moment, I do not have a minimal example. There are quite a bit of pieces involved I guess, even in a minimal example, but I should try to put one together as soon as possible.

I will say that this is not the only time we've encountered this problem on 3.3.8 (acutally, I've seen this problem 100% of the time while working with 3.3.8 WCartesianCharts). On previous, similar charting applications that work fine under 3.3.0, under 3.3.8 they fail in exactly the same way where the series legend labels never get removed when the underlying columns are deleted (or the entire model cleared). In those other apps, it has been feasible to clear out the data model entirely (model~~clear()), and then use chart~~>setSeries(vector)) to assign all the new series at one time. I gather from the docs that setSeries() first wipes out any pre-existing series. That fixed the problem for those apps where replacing one model with a brand new one each time new data was to be plotted made sense. Unfortunately, for my current application, I really need a way to completely remove one series at a time. If I use setSeries() it will wipe out all previously assigned series first, which is not what I want. I can probably kludge a way together to make that work (deleting all series and replacing them with all new series any time I want to add or remove a single series), but I'd rather not do that. My guess is I just have some fundamental misunderstanding of how the chart the model and the series all relate to each other (and what triggers cleaning them up).

RE: WCartesianChart: Removing model column does not (completely) remove series (Wt 3.3.8) - Added by Mark Travis over 1 year ago

I'm currently experiencing this issue, and I may have to solve it like you did, by deleting the series, then re-adding.

I set the model when I initialize the container/cartesian widget so that all possible columns are drawn.

The user selects a subset and or adds additional, and I update the standarditemmodel that underlies the chart. I've verified that the new standarditemmodel does indeed contain the correct number of columns, but the chart does not reflect that. In this case (see image) I've deleted more columns than I started with. The bar chart itself updates correctly, but the legend is still reflecting the original size.

Any ideas on how to trigger the proper refresh?

    (1-3/3)