Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Graph does not rescale correctly when mimimizing or maximizing window. #109

Open
hansonry opened this issue Aug 30, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@hansonry
Copy link

hansonry commented Aug 30, 2024

Describe the bug
It's in the title.

To Reproduce
Steps to reproduce the behavior:

  1. Run an example.
  2. Maximize the window.
  3. Notice the graph doesn't rescale correctly.

Expected behavior
The graph should rescale along with the lines.

Screenshots
Running the line_chart example.

At launch:

Screenshot from 2024-08-29 22-00-18

After maximizing and minimizing:

Screenshot from 2024-08-29 22-00-28

Desktop (please complete the following information):

  • OS: Linux
  • Godot Engine Version: 4.3
  • Plugin Version: v24.05.06

Additional context
Seems like the root cause is that get_rect() (being called inside BoxPlot.get_box() and BoxPlot.get_plot_box()) doesn't update right away. So some parts of the redraw are scaled incorrectly.

I think I fixed it by adding this code to box_plot.gd:

func _on_resized() -> void:
	$GridBox.queue_redraw()
	for function in $FunctionsBox.get_children():
		function.queue_redraw()

_on_resized is connected to the BoxPlot resized signal.

This seems to fix the issue. I have no idea if this is the correct way to fix it or if it is the most efficient. I am not even clear on why this is necessary, seems like it would make sense for Godot to not call queue_redraw() until all the parents are updated. I probably don't understand the code well enough. Anyway, I hope this is helpful!

@hansonry hansonry added the bug Something isn't working label Aug 30, 2024
@acmepjz
Copy link

acmepjz commented Jan 13, 2025

Thanks for your fix! Personally I prefer to add the following code directly to res://addons/easy_charts/control_charts/chart.gd and connectd to PlotBox resized signal:

func _on_plot_box_resized() -> void:
	grid_box.queue_redraw()
	for function in functions_box.get_children():
		function.queue_redraw()

Would you like to create a PR for that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants