PDA

View Full Version : Is it possible to programmatically delete the QValueAxis axis.



quant
9th October 2020, 12:01
At first, I couldn't set the scatters on the candle chart.
The candlestick chart disappeared when the scatter was set.
Default axes were used for the scatter.
I tried setting the axis for the scatter separately and the candlestick chart stopped disappearing.

Now, when I delete the scatter, the axes remain. Is it possible to programmatically delete them.

Below I attach a GIF file for clarity.
https://gifyu.com/image/6Y1R

I asked the same question on stackoverflow.com. https://stackoverflow.com/questions/64230656/now-the-problem-is-that-when-i-delete-a-scatter-its-axes-are-not-deleted
The code is in Python(Pyqt5), but I can probably understand the code in C++.

quant
10th October 2020, 09:53
Can of course try to do this:


chart.axisX(serie).setVisible(False)

But will the axes remain in memory?

d_stranz
10th October 2020, 18:52
But will the axes remain in memory?

Most likely. All you are changing is the visibility status.

Why does it matter whether the memory is freed or not?

quant
10th October 2020, 20:17
Most likely. All you are changing is the visibility status.

Why does it matter whether the memory is freed or not?

I plan to add and remove various series from the chart many times.
Over time, the app will start to hang, work incorrectly, and so on. I think so, but I'm not sure.

I created a GIF where I add scatters many times and then delete them.https://gifyu.com/image/61Mb

You can see that the graph stops changing diagonally.

Although, if I make the axes immediately invisible, then there is no problem with diagonal stretching.
I don't have much programming experience. So I decided to ask about it.

d_stranz
10th October 2020, 22:53
I plan to add and remove various series from the chart many times.
Over time, the app will start to hang, work incorrectly, and so on. I think so, but I'm not sure.

It shouldn't, if you are using the chart API correctly. If you are actually -removing- series from the plot instead of just making them invisible then python should be freeing up the memory for the items that have been removed. If all you are doing to "remove" a series is to make it invisible, then yes, you are basically forcing python and Qt to allocate more and more memory which will cause your app to bog down and probably eventually crash if you run it long enough..