update samples

This commit is contained in:
Nicolò Santilio 2020-12-31 15:02:54 +01:00
parent 8646fcb6c6
commit c9023e2dac
17 changed files with 52 additions and 157 deletions

View File

@ -160,14 +160,14 @@ func build_chart():
SIZE = get_size()
origin = Vector2(OFFSET.x,SIZE.y-OFFSET.y)
func structure_datas(database : Array, are_values_columns : bool, x_values_index : int):
# @x_values_index can be either a column or a row relative to x values
self.are_values_columns = are_values_columns
func structure_datas(database : Array):
# @labels_index can be either a column or a row relative to x values
are_values_columns = (invert_chart != are_values_columns)
if are_values_columns:
for row in database.size():
var t_vals: Array
for column in database[row].size():
if column == x_values_index:
if column == labels_index:
var x_data = database[row][column]
if x_data.is_valid_float() or x_data.is_valid_integer():
x_datas.append(x_data as float)
@ -187,7 +187,7 @@ func structure_datas(database : Array, are_values_columns : bool, x_values_index
x_label = str(x_datas.pop_front())
else:
for row in database.size():
if row == x_values_index:
if row == labels_index:
x_datas = (database[row])
x_label = x_datas.pop_front() as String
else:
@ -246,19 +246,16 @@ func structure_datas(database : Array, are_values_columns : bool, x_values_index
func calculate_pass():
if invert_chart:
x_chors = y_labels as PoolStringArray
if show_x_values_as_labels:
x_chors = x_datas as PoolStringArray
else:
if show_x_values_as_labels:
x_chors = x_datas as PoolStringArray
else:
x_chors = x_labels
x_chors = x_labels
# calculate distance in pixel between 2 consecutive values/datas
if not are_values_columns:
x_pass = (SIZE.x - OFFSET.x*2 - (column_width) * ( y_datas.size() if not invert_chart else y_datas[0].size()+1 ) - column_gap - column_width/2) / ((x_chors.size()-1) if x_chors.size()!=1 else 1)
x_pass = (SIZE.x - OFFSET.x*2 - (column_width) * ( y_datas.size()) - column_gap - column_width/2) / ((x_chors.size()-1) if x_chors.size()!=1 else 1)
else:
x_pass = (SIZE.x - OFFSET.x*2 - (column_width) * ( y_datas.size() if invert_chart else y_datas[0].size()+1 ) - column_gap - column_width/2) / (x_chors.size()-1)
x_pass = (SIZE.x - OFFSET.x*2 - (column_width) * ( y_datas[0].size()+1 ) - column_gap - column_width/2) / (x_chors.size()-1)
y_pass = (origin.y - ChartName.get_rect().size.y*2) / (y_chors.size() - 1)
func calculate_coordinates():
@ -266,25 +263,15 @@ func calculate_coordinates():
y_coordinates.clear()
point_values.clear()
point_positions.clear()
if invert_chart:
for column in y_datas[0].size():
var single_coordinates : Array
for row in y_datas:
if origin_at_zero:
single_coordinates.append((row[column]*y_pass)/v_dist)
else:
single_coordinates.append((row[column] - y_margin_min)*y_pass/v_dist)
y_coordinates.append(single_coordinates)
else:
for cluster in y_datas:
var single_coordinates : Array
for value in cluster.size():
if origin_at_zero:
single_coordinates.append((cluster[value]*y_pass)/v_dist)
else:
single_coordinates.append((cluster[value] - y_margin_min)*y_pass/v_dist)
y_coordinates.append(single_coordinates)
for cluster in y_datas:
var single_coordinates : Array
for value in cluster.size():
if origin_at_zero:
single_coordinates.append((cluster[value]*y_pass)/v_dist)
else:
single_coordinates.append((cluster[value] - y_margin_min)*y_pass/v_dist)
y_coordinates.append(single_coordinates)
if show_x_values_as_labels:
for x in x_datas.size():
@ -292,10 +279,7 @@ func calculate_coordinates():
else:
for x in x_datas.size():
if origin_at_zero:
if not invert_chart:
x_coordinates.append(x_pass*x)
else:
x_coordinates.append(x*x_pass/h_dist)
x_coordinates.append(x_pass*x)
else:
x_coordinates.append((x_datas[x] - x_margin_min)*x_pass/h_dist)
@ -303,24 +287,14 @@ func calculate_coordinates():
point_values.append([])
point_positions.append([])
if invert_chart:
for function in y_coordinates.size():
for function_value in y_coordinates[function].size():
if are_values_columns:
point_values[function].append([x_datas[function_value],y_datas[function_value][function]])
point_positions[function].append(Vector2(OFFSET.x/2 + column_width/2 + (column_width + column_gap)*function + x_coordinates[function_value]+origin.x,origin.y-y_coordinates[function][function_value]))
else:
point_positions[function].append(Vector2(OFFSET.x/2 + column_width/2 + (column_width + column_gap)*function + x_coordinates[function_value]+origin.x,origin.y-y_coordinates[function][function_value]))
point_values[function].append([x_datas[function_value],y_datas[function_value][function]])
else:
for cluster in y_coordinates.size():
for y in y_coordinates[cluster].size():
if are_values_columns:
point_positions[y].append(Vector2(OFFSET.x/2 + column_width/2 + (column_width + column_gap)*y + x_coordinates[cluster] + origin.x, origin.y-y_coordinates[cluster][y]))
point_values[y].append([x_datas[cluster],y_datas[cluster][y]])
else:
point_values[cluster].append([x_datas[y],y_datas[cluster][y]])
point_positions[cluster].append(Vector2(OFFSET.x/2 + column_width/2 + (column_width + column_gap)*cluster + x_coordinates[y]+origin.x,origin.y-y_coordinates[cluster][y]))
for cluster in y_coordinates.size():
for y in y_coordinates[cluster].size():
if are_values_columns:
point_positions[y].append(Vector2(OFFSET.x/2 + column_width/2 + (column_width + column_gap)*y + x_coordinates[cluster] + origin.x, origin.y-y_coordinates[cluster][y]))
point_values[y].append([x_datas[cluster],y_datas[cluster][y]])
else:
point_values[cluster].append([x_datas[y],y_datas[cluster][y]])
point_positions[cluster].append(Vector2(OFFSET.x/2 + column_width/2 + (column_width + column_gap)*cluster + x_coordinates[y]+origin.x,origin.y-y_coordinates[cluster][y]))
func _draw():
clear_points()
@ -342,10 +316,10 @@ func _draw():
point.connect("_mouse_entered",self,"show_data")
point.connect("_mouse_exited",self,"hide_data")
point.create_point(points_shape[_function], function_colors[function_point if invert_chart else _function],
point.create_point(points_shape[_function], function_colors[_function],
Color.white, point_positions[_function][function_point] + Vector2(0,7),
point.format_value(point_values[_function][function_point], false, false),
y_labels[function_point if invert_chart else _function] as String)
y_labels[_function] as String)
PointContainer.add_child(point)
point.rect_size.y = origin.y - point_positions[_function][function_point].y
draw_line( Vector2(point_positions[_function][function_point].x, origin.y),
@ -362,9 +336,9 @@ func draw_grid():
draw_line(point-Vector2(0,5),point,v_lines_color,1,true)
var calculated_gap : float
if not are_values_columns:
calculated_gap = ( y_datas.size() if not invert_chart else y_datas[0].size()+1 )
calculated_gap = ( y_datas.size() )
else:
calculated_gap = ( y_datas.size() if invert_chart else y_datas[0].size()+1 )
calculated_gap = ( y_datas[0].size()+1 )
draw_string(
font,
point + Vector2(-const_width/2*x_chors[p].length() + (column_width + column_gap) * functions, font_size),

View File

@ -1,10 +0,0 @@
Year;Column 1
2009;36200
2010;36600
2011;37500
2012;38700
2013;39600
2014;40500
2015;41200
2016;41803
2017;42600
1 Year Column 1
2 2009 36200
3 2010 36600
4 2011 37500
5 2012 38700
6 2013 39600
7 2014 40500
8 2015 41200
9 2016 41803
10 2017 42600

View File

@ -1,10 +0,0 @@
[remap]
importer="csv"
type="TextFile"
[deps]
source_file="res://addons/easy_charts/file.samples/2_columns.csv"
[params]

View File

@ -1,10 +0,0 @@
[remap]
importer="csv"
type="TextFile"
[deps]
source_file="res://addons/easy_charts/file.samples/datas.csv"
[params]

View File

@ -1,5 +0,0 @@
Year;2009;2010;2011;2012;2013;2014;2015;2016;2017
Column 1;36200;36600;37500;38700;39600;40500;41200;41803;42600
Column 2;27200;27800;28500;29400;30200;30900;31500;31931;32600
Column 3;26200;26600;27500;28700;29600;20500;21200;21803;22600
Column 4;17200;17800;18500;19400;10200;10900;11500;11931;12600
1 Year 2009 2010 2011 2012 2013 2014 2015 2016 2017
2 Column 1 36200 36600 37500 38700 39600 40500 41200 41803 42600
3 Column 2 27200 27800 28500 29400 30200 30900 31500 31931 32600
4 Column 3 26200 26600 27500 28700 29600 20500 21200 21803 22600
5 Column 4 17200 17800 18500 19400 10200 10900 11500 11931 12600

View File

@ -1,10 +0,0 @@
[remap]
importer="csv"
type="TextFile"
[deps]
source_file="res://addons/easy_charts/file.samples/datas2.csv"
[params]

View File

@ -1,10 +0,0 @@
[remap]
importer="csv"
type="TextFile"
[deps]
source_file="res://addons/easy_charts/file.samples/datas_on_columns.csv"
[params]

View File

@ -1,5 +0,0 @@
Year;2009;2010;2011;2012;2013;2014;2015;2016;2017
Column 1;36200;36600;37500;38700;39600;40500;41200;41803;42600
Column 2;27200;27800;28500;29400;30200;30900;31500;31931;32600
Column 3;26200;26600;27500;28700;29600;20500;21200;21803;22600
Column 4;17200;17800;18500;19400;10200;10900;11500;11931;12600
1 Year 2009 2010 2011 2012 2013 2014 2015 2016 2017
2 Column 1 36200 36600 37500 38700 39600 40500 41200 41803 42600
3 Column 2 27200 27800 28500 29400 30200 30900 31500 31931 32600
4 Column 3 26200 26600 27500 28700 29600 20500 21200 21803 22600
5 Column 4 17200 17800 18500 19400 10200 10900 11500 11931 12600

View File

@ -1,10 +0,0 @@
[remap]
importer="csv"
type="TextFile"
[deps]
source_file="res://addons/easy_charts/file.samples/datas_on_rows.csv"
[params]

View File

@ -1,3 +0,0 @@
Meccaniche;deve essere possibile rallentare/fermare il tempo;deve essere basato su una griglia;deve essere un gioco a tentativi;deve implementare della magia;non deve contenere istruzioni
Valori;22;13;20;20;15
Valori2;22;13;20;20;15
1 Meccaniche deve essere possibile rallentare/fermare il tempo deve essere basato su una griglia deve essere un gioco a tentativi deve implementare della magia non deve contenere istruzioni
2 Valori 22 13 20 20 15
3 Valori2 22 13 20 20 15

View File

@ -1,10 +0,0 @@
[remap]
importer="csv"
type="TextFile"
[deps]
source_file="res://addons/easy_charts/file.samples/gei_jam#2columns.csv"
[params]

View File

@ -1,6 +0,0 @@
Meccaniche;Voti
deve essere possibile rallentare/fermare il tempo;22
deve essere basato su una griglia;13
deve essere un gioco a tentativi;20
deve implementare della magia;20
non deve contenere istruzioni;15
1 Meccaniche Voti
2 deve essere possibile rallentare/fermare il tempo 22
3 deve essere basato su una griglia 13
4 deve essere un gioco a tentativi 20
5 deve implementare della magia 20
6 non deve contenere istruzioni 15

View File

@ -1,10 +0,0 @@
[remap]
importer="csv"
type="TextFile"
[deps]
source_file="res://addons/easy_charts/file.samples/godot_engine_italia_jam#2.csv"
[params]

View File

@ -0,0 +1,10 @@
[remap]
importer="csv"
type="TextFile"
[deps]
source_file="res://addons/easy_charts/file.samples/linechart (columns).csv"
[params]

View File

@ -0,0 +1,10 @@
[remap]
importer="csv"
type="TextFile"
[deps]
source_file="res://addons/easy_charts/file.samples/linechart (rows).csv"
[params]