fair-acc / chart-fx

A scientific charting library focused on performance optimised real-time data visualisation at 25 Hz update rates for data sets with a few 10 thousand up to 5 million data points.
GNU Lesser General Public License v3.0
507 stars 93 forks source link

Appearing of redundant chart axes #666

Open kromar777 opened 6 months ago

kromar777 commented 6 months ago

In one of my apps a user can dynamically add/remove/edit axes and renderers can have as independent as well as "shared" axes (usually only Y as secondary). I create separate renderers for each dataset and before doing this I always remove chart axes: chart.getAxes().clear(). Also I follow the recommendation in the examples: N.B. it's important to set secondary axis on the 2nd renderer before adding the renderer to the chart. After that I don't touch the chart until adding datasets, but sometimes extra axes are still present: 2024-05-01_09-37-41 I don't get it in what moment they are added again. I'm not sure whether it's a bug and not a big deal actualy though I would like to get advice how to reliable get rid of chart axes besides of inserting chart.getAxes().clear() in different places along the code where they can appear.

ennerf commented 5 months ago

The mechanism to keep track of axes should be refactored a bit, but so far it has been a low priority.

I assume that this is caused caused by some call to e.g. chart::getXAxis that automatically adds an axis if the chart does not already have one defined (maybe by the gridRenderer?). To fix it, the chart axes should be explicitly specified rather than being cleared, e.g., chart.getAxes().setAll(xAxis, yAxis, xAxis2, yAxis2).