mirror of
https://github.com/Relintai/pandemonium_engine_easy_charts.git
synced 2025-01-29 15:39:17 +01:00
update samples
This commit is contained in:
parent
8646fcb6c6
commit
c9023e2dac
@ -160,14 +160,14 @@ func build_chart():
|
|||||||
SIZE = get_size()
|
SIZE = get_size()
|
||||||
origin = Vector2(OFFSET.x,SIZE.y-OFFSET.y)
|
origin = Vector2(OFFSET.x,SIZE.y-OFFSET.y)
|
||||||
|
|
||||||
func structure_datas(database : Array, are_values_columns : bool, x_values_index : int):
|
func structure_datas(database : Array):
|
||||||
# @x_values_index can be either a column or a row relative to x values
|
# @labels_index can be either a column or a row relative to x values
|
||||||
self.are_values_columns = are_values_columns
|
are_values_columns = (invert_chart != are_values_columns)
|
||||||
if are_values_columns:
|
if are_values_columns:
|
||||||
for row in database.size():
|
for row in database.size():
|
||||||
var t_vals: Array
|
var t_vals: Array
|
||||||
for column in database[row].size():
|
for column in database[row].size():
|
||||||
if column == x_values_index:
|
if column == labels_index:
|
||||||
var x_data = database[row][column]
|
var x_data = database[row][column]
|
||||||
if x_data.is_valid_float() or x_data.is_valid_integer():
|
if x_data.is_valid_float() or x_data.is_valid_integer():
|
||||||
x_datas.append(x_data as float)
|
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())
|
x_label = str(x_datas.pop_front())
|
||||||
else:
|
else:
|
||||||
for row in database.size():
|
for row in database.size():
|
||||||
if row == x_values_index:
|
if row == labels_index:
|
||||||
x_datas = (database[row])
|
x_datas = (database[row])
|
||||||
x_label = x_datas.pop_front() as String
|
x_label = x_datas.pop_front() as String
|
||||||
else:
|
else:
|
||||||
@ -246,9 +246,6 @@ func structure_datas(database : Array, are_values_columns : bool, x_values_index
|
|||||||
|
|
||||||
|
|
||||||
func calculate_pass():
|
func calculate_pass():
|
||||||
if invert_chart:
|
|
||||||
x_chors = y_labels as PoolStringArray
|
|
||||||
else:
|
|
||||||
if show_x_values_as_labels:
|
if show_x_values_as_labels:
|
||||||
x_chors = x_datas as PoolStringArray
|
x_chors = x_datas as PoolStringArray
|
||||||
else:
|
else:
|
||||||
@ -256,9 +253,9 @@ func calculate_pass():
|
|||||||
|
|
||||||
# calculate distance in pixel between 2 consecutive values/datas
|
# calculate distance in pixel between 2 consecutive values/datas
|
||||||
if not are_values_columns:
|
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:
|
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)
|
y_pass = (origin.y - ChartName.get_rect().size.y*2) / (y_chors.size() - 1)
|
||||||
|
|
||||||
func calculate_coordinates():
|
func calculate_coordinates():
|
||||||
@ -267,16 +264,6 @@ func calculate_coordinates():
|
|||||||
point_values.clear()
|
point_values.clear()
|
||||||
point_positions.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:
|
for cluster in y_datas:
|
||||||
var single_coordinates : Array
|
var single_coordinates : Array
|
||||||
for value in cluster.size():
|
for value in cluster.size():
|
||||||
@ -292,10 +279,7 @@ func calculate_coordinates():
|
|||||||
else:
|
else:
|
||||||
for x in x_datas.size():
|
for x in x_datas.size():
|
||||||
if origin_at_zero:
|
if origin_at_zero:
|
||||||
if not invert_chart:
|
|
||||||
x_coordinates.append(x_pass*x)
|
x_coordinates.append(x_pass*x)
|
||||||
else:
|
|
||||||
x_coordinates.append(x*x_pass/h_dist)
|
|
||||||
else:
|
else:
|
||||||
x_coordinates.append((x_datas[x] - x_margin_min)*x_pass/h_dist)
|
x_coordinates.append((x_datas[x] - x_margin_min)*x_pass/h_dist)
|
||||||
|
|
||||||
@ -303,16 +287,6 @@ func calculate_coordinates():
|
|||||||
point_values.append([])
|
point_values.append([])
|
||||||
point_positions.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 cluster in y_coordinates.size():
|
||||||
for y in y_coordinates[cluster].size():
|
for y in y_coordinates[cluster].size():
|
||||||
if are_values_columns:
|
if are_values_columns:
|
||||||
@ -342,10 +316,10 @@ func _draw():
|
|||||||
point.connect("_mouse_entered",self,"show_data")
|
point.connect("_mouse_entered",self,"show_data")
|
||||||
point.connect("_mouse_exited",self,"hide_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),
|
Color.white, point_positions[_function][function_point] + Vector2(0,7),
|
||||||
point.format_value(point_values[_function][function_point], false, false),
|
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)
|
PointContainer.add_child(point)
|
||||||
point.rect_size.y = origin.y - point_positions[_function][function_point].y
|
point.rect_size.y = origin.y - point_positions[_function][function_point].y
|
||||||
draw_line( Vector2(point_positions[_function][function_point].x, origin.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)
|
draw_line(point-Vector2(0,5),point,v_lines_color,1,true)
|
||||||
var calculated_gap : float
|
var calculated_gap : float
|
||||||
if not are_values_columns:
|
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:
|
else:
|
||||||
calculated_gap = ( y_datas.size() if invert_chart else y_datas[0].size()+1 )
|
calculated_gap = ( y_datas[0].size()+1 )
|
||||||
draw_string(
|
draw_string(
|
||||||
font,
|
font,
|
||||||
point + Vector2(-const_width/2*x_chors[p].length() + (column_width + column_gap) * functions, font_size),
|
point + Vector2(-const_width/2*x_chors[p].length() + (column_width + column_gap) * functions, font_size),
|
||||||
|
@ -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,10 +0,0 @@
|
|||||||
[remap]
|
|
||||||
|
|
||||||
importer="csv"
|
|
||||||
type="TextFile"
|
|
||||||
|
|
||||||
[deps]
|
|
||||||
|
|
||||||
source_file="res://addons/easy_charts/file.samples/2_columns.csv"
|
|
||||||
[params]
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
|||||||
[remap]
|
|
||||||
|
|
||||||
importer="csv"
|
|
||||||
type="TextFile"
|
|
||||||
|
|
||||||
[deps]
|
|
||||||
|
|
||||||
source_file="res://addons/easy_charts/file.samples/datas.csv"
|
|
||||||
[params]
|
|
||||||
|
|
@ -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,10 +0,0 @@
|
|||||||
[remap]
|
|
||||||
|
|
||||||
importer="csv"
|
|
||||||
type="TextFile"
|
|
||||||
|
|
||||||
[deps]
|
|
||||||
|
|
||||||
source_file="res://addons/easy_charts/file.samples/datas2.csv"
|
|
||||||
[params]
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
|||||||
[remap]
|
|
||||||
|
|
||||||
importer="csv"
|
|
||||||
type="TextFile"
|
|
||||||
|
|
||||||
[deps]
|
|
||||||
|
|
||||||
source_file="res://addons/easy_charts/file.samples/datas_on_columns.csv"
|
|
||||||
[params]
|
|
||||||
|
|
@ -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,10 +0,0 @@
|
|||||||
[remap]
|
|
||||||
|
|
||||||
importer="csv"
|
|
||||||
type="TextFile"
|
|
||||||
|
|
||||||
[deps]
|
|
||||||
|
|
||||||
source_file="res://addons/easy_charts/file.samples/datas_on_rows.csv"
|
|
||||||
[params]
|
|
||||||
|
|
@ -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,10 +0,0 @@
|
|||||||
[remap]
|
|
||||||
|
|
||||||
importer="csv"
|
|
||||||
type="TextFile"
|
|
||||||
|
|
||||||
[deps]
|
|
||||||
|
|
||||||
source_file="res://addons/easy_charts/file.samples/gei_jam#2columns.csv"
|
|
||||||
[params]
|
|
||||||
|
|
@ -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,10 +0,0 @@
|
|||||||
[remap]
|
|
||||||
|
|
||||||
importer="csv"
|
|
||||||
type="TextFile"
|
|
||||||
|
|
||||||
[deps]
|
|
||||||
|
|
||||||
source_file="res://addons/easy_charts/file.samples/godot_engine_italia_jam#2.csv"
|
|
||||||
[params]
|
|
||||||
|
|
@ -0,0 +1,10 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="csv"
|
||||||
|
type="TextFile"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://addons/easy_charts/file.samples/linechart (columns).csv"
|
||||||
|
[params]
|
||||||
|
|
10
addons/easy_charts/file.samples/linechart (rows).csv.import
Normal file
10
addons/easy_charts/file.samples/linechart (rows).csv.import
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="csv"
|
||||||
|
type="TextFile"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://addons/easy_charts/file.samples/linechart (rows).csv"
|
||||||
|
[params]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user