From eb0006c17aff1bb5c4efec962f8277e6e703acce Mon Sep 17 00:00:00 2001
From: Jorge <63685920+JFerrerBeired@users.noreply.github.com>
Date: Tue, 4 May 2021 02:08:29 +0200
Subject: [PATCH] Fix show_x_values_as_labels

Correctly sets the x position when show_x_values_as_labels is active.
---
 addons/easy_charts/Utilities/Scripts/scatter_chart_base.gd | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/addons/easy_charts/Utilities/Scripts/scatter_chart_base.gd b/addons/easy_charts/Utilities/Scripts/scatter_chart_base.gd
index 64ef5db..a0082f3 100644
--- a/addons/easy_charts/Utilities/Scripts/scatter_chart_base.gd
+++ b/addons/easy_charts/Utilities/Scripts/scatter_chart_base.gd
@@ -418,7 +418,7 @@ func structure_datas(database : Array):
 				else:
 					if row != 0:
 						var y_data = database[row][column]
-						if typeof(y_data) == TYPE_INT  or typeof(y_data) == TYPE_REAL:
+						if typeof(y_data) == TYPE_INT or typeof(y_data) == TYPE_REAL:
 							y_values[y_column].append(y_data as float)
 						else:
 							y_values[y_column].append(y_data.replace(",",".") as float)
@@ -516,7 +516,6 @@ func calculate_tics():
 			x_labels[i] = String(x_labels[i])
 		x_chors = x_labels
 	else:
-		#TODO: h_dist = ?
 		for function in y_labels.size():
 			for value in x_datas[function]:
 				if not x_chors.has(value as String): #Don't append repeated values
@@ -557,13 +556,15 @@ func calculate_coordinates():
 	
 	for function in y_labels.size():
 		for val in x_datas[function].size():
-			var value_x = (x_datas[function][val] - x_margin_min) * x_pass / h_dist if h_dist else 0
+			var value_x = (x_datas[function][val] - x_margin_min) * x_pass / h_dist if h_dist else 0 \
+					if not show_x_values_as_labels else x_chors.find(String(x_datas[function][val])) * x_pass
 			var value_y = (y_datas[function][val] - y_margin_min) * y_pass / v_dist if v_dist else 0
 	
 			point_values[function].append([x_datas[function][val], y_datas[function][val]])
 			point_positions[function].append(Vector2(value_x + origin.x, origin.y - value_y))
 
 
+
 func draw_grid():
 	# ascisse
 	for p in x_chors.size():