fenix-hub / godot-engine.easy-charts

A Godot Engine addon for plotting general purpose charts. A collection of Control, 2D and 3D Nodes to plot every chart possible.
MIT License
648 stars 48 forks source link

[BUG] Old functions being plotted when calling plot multiple times with different functions #91

Closed Snafuh closed 8 months ago

Snafuh commented 1 year ago

When calling plot on the same chart multiple times with different functions, e.g. when toggling between different graphs on the same chart, the previous displayed function persists.

This seems to happen when switching between plotting one function and two functions. The graph with one function is correctly displayed, but the one with two functions displays three graphs.

To Reproduce

if tab == 0:
        var Func1 = Function.new(x, Load, "Load", {color = Color.WEB_GREEN, type = Function.Type.LINE })
        chart.plot([Func1])
    elif tab == 1:
        var Func2  = Function.new(x, CO2, "CO2", { color = Color.RED, marker = Function.Marker.NONE, type = Function.Type.LINE })
        var Func3 = Function.new(x, CO2_Concentration, "CO2 Concentration", { color = Color.BLUE, marker = Function.Marker.NONE, type = Function.Type.LINE })
        chart.plot([Func2, Func3])

This code results in 3 graphs being displayed.

Plot_Error

Expected behavior Only the plotted functions are displayed and plot can correctly be called with different functions multiple times.

Desktop (please complete the following information):