godot-engine.easy-charts icon indicating copy to clipboard operation
godot-engine.easy-charts copied to clipboard

[BUG] Invalid get index 'lb' (on base: 'Dictionary')

Open Tianmaru opened this issue 1 year ago • 7 comments

Calling plot on chart after it was added to the scene tree (so after ready, for example to plot some new functions) results in a crash. The error message reads:

Invalid get index 'lb' (on base: 'Dictionary')

After some experimenting, the error is most likely caused by the FunctionPlotter's x_domain and y_domain values not being initialized properly yet. This means, that the _draw function is called on the function_plotters, before it is called on chart, since this would set the domains, right? Adding the following to the end of the load_functions method of chart seems to solve the issue, but causes some other unexpected side effects:

var x_domain: Dictionary = calculate_domain(x)
var y_domain: Dictionary = calculate_domain(y)
for function_plotter in functions_box.get_children():
	function_plotter.update_values(x_domain, y_domain)

Tianmaru avatar Aug 14 '23 13:08 Tianmaru