fix top displacement

This commit is contained in:
fenix-hub 2022-01-10 19:05:45 +01:00
parent bc72106178
commit 67b12be831
2 changed files with 11 additions and 7 deletions

View File

@ -58,6 +58,7 @@ __meta__ = {
}
[node name="ChartName" type="Label" parent="."]
visible = false
anchor_right = 1.0
margin_bottom = 14.0
align = 1
@ -85,10 +86,10 @@ __meta__ = {
[node name="CanvasLayer" type="CanvasLayer" parent="."]
[node name="DataTooltip" parent="CanvasLayer" instance=ExtResource( 1 )]
margin_left = -126.774
margin_top = -58.1348
margin_right = -126.91
margin_bottom = -57.3348
margin_left = -163.544
margin_top = 34.4964
margin_right = -163.68
margin_bottom = 35.2964
[node name="PointData" parent="CanvasLayer/DataTooltip" index="0"]
margin_left = -189.809

View File

@ -455,6 +455,7 @@ func calculate_tics():
calculate_interval_tics(y_margin_min, y_margin_max, v_dist, y_chors)
for i in y_chors.size():
y_chors[i] = String(y_chors[i]) #Can't cast directly on calculate_interval_tics because it mess up with the sorting
print(y_chors)
x_chors = x_labels.duplicate(true)
@ -464,13 +465,15 @@ func build_chart():
var length = font.get_string_size(str(y_tic)).x
if length > longest_y_tic:
longest_y_tic = length
OFFSET.x = longest_y_tic + tic_length + 2 * label_displacement
OFFSET.y = font.get_height() + tic_length + label_displacement
SIZE = get_size() - Vector2(OFFSET.x, 0)
origin = Vector2(OFFSET.x, SIZE.y - OFFSET.y)
print(SIZE)
print(origin)
func count_functions():
functions = y_labels.size()
@ -481,7 +484,7 @@ func calculate_pass():
if x_chors.size() > 0:
x_pass = (SIZE.x - OFFSET.x) / (x_chors.size() - 1 if x_chors.size() > 1 else x_chors.size())
if y_chors.size() > 0:
y_pass = (origin.y - ChartName.get_rect().size.y * 2) / (y_chors.size() - 1 if y_chors.size() > 1 else y_chors.size())
y_pass = (origin.y) / (y_chors.size() - 1 if y_chors.size() > 1 else y_chors.size())
# Calculate all Points' coordinates in the dataset