mirror of
https://github.com/Relintai/pandemonium_engine_easy_charts.git
synced 2024-11-14 10:17:24 +01:00
refactor: remove spaces before type declaration colons
This commit is contained in:
parent
3d2a6dbcc7
commit
265e28d1f1
@ -12,105 +12,105 @@ and joined with straight line segments.
|
|||||||
A line chart is often used to visualize a trend in data over intervals of time –
|
A line chart is often used to visualize a trend in data over intervals of time –
|
||||||
a time series – thus the line is often drawn chronologically.
|
a time series – thus the line is often drawn chronologically.
|
||||||
In these cases they are known as run charts.
|
In these cases they are known as run charts.
|
||||||
/ source : Wikipedia /
|
/ source: Wikipedia /
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
var OutlinesTween : Tween
|
var OutlinesTween: Tween
|
||||||
var FunctionsTween : Tween
|
var FunctionsTween: Tween
|
||||||
var Functions : Node2D
|
var Functions: Node2D
|
||||||
var GridTween : Tween
|
var GridTween: Tween
|
||||||
var PointData : PointData
|
var PointData: PointData
|
||||||
var Outlines : Line2D
|
var Outlines: Line2D
|
||||||
var Grid : Node2D
|
var Grid: Node2D
|
||||||
|
|
||||||
var point_node : PackedScene = preload("../Utilities/Point/Point.tscn")
|
var point_node: PackedScene = preload("../Utilities/Point/Point.tscn")
|
||||||
var FunctionLegend : PackedScene = preload("../Utilities/Legend/FunctionLegend.tscn")
|
var FunctionLegend: PackedScene = preload("../Utilities/Legend/FunctionLegend.tscn")
|
||||||
|
|
||||||
var font_size : float = 16
|
var font_size: float = 16
|
||||||
var const_height : float = font_size/2*font_size/20
|
var const_height: float = font_size/2*font_size/20
|
||||||
var const_width : float = font_size/2
|
var const_width: float = font_size/2
|
||||||
|
|
||||||
var OFFSET : Vector2 = Vector2(0,0)
|
var OFFSET: Vector2 = Vector2(0,0)
|
||||||
|
|
||||||
#-------------------------------------------------------------------------#
|
#-------------------------------------------------------------------------#
|
||||||
var origin : Vector2
|
var origin: Vector2
|
||||||
|
|
||||||
# actual distance between x and y values
|
# actual distance between x and y values
|
||||||
var x_pass : float
|
var x_pass: float
|
||||||
var y_pass : float
|
var y_pass: float
|
||||||
|
|
||||||
# vertical distance between y consecutive points used for intervals
|
# vertical distance between y consecutive points used for intervals
|
||||||
var v_dist : float
|
var v_dist: float
|
||||||
var h_dist : float
|
var h_dist: float
|
||||||
|
|
||||||
# quantization, representing the interval in which values will be displayed
|
# quantization, representing the interval in which values will be displayed
|
||||||
|
|
||||||
# define values on x an y axis
|
# define values on x an y axis
|
||||||
var x_chors : Array
|
var x_chors: Array
|
||||||
var y_chors : Array
|
var y_chors: Array
|
||||||
|
|
||||||
# actual coordinates of points (in pixel)
|
# actual coordinates of points (in pixel)
|
||||||
var x_coordinates : Array
|
var x_coordinates: Array
|
||||||
var y_coordinates : Array
|
var y_coordinates: Array
|
||||||
|
|
||||||
# datas contained in file
|
# datas contained in file
|
||||||
var datas : Array
|
var datas: Array
|
||||||
|
|
||||||
# amount of functions to represent
|
# amount of functions to represent
|
||||||
var functions : int = 0
|
var functions: int = 0
|
||||||
|
|
||||||
var x_label : String
|
var x_label: String
|
||||||
|
|
||||||
# database values
|
# database values
|
||||||
var x_datas : Array
|
var x_datas: Array
|
||||||
var y_datas : Array
|
var y_datas: Array
|
||||||
|
|
||||||
# labels displayed on chart
|
# labels displayed on chart
|
||||||
var x_labels : Array
|
var x_labels: Array
|
||||||
var y_labels : Array
|
var y_labels: Array
|
||||||
|
|
||||||
var x_margin_min : int = 0
|
var x_margin_min: int = 0
|
||||||
var y_margin_min : int = 0
|
var y_margin_min: int = 0
|
||||||
|
|
||||||
# actual values of point, from the database
|
# actual values of point, from the database
|
||||||
var point_values : Array
|
var point_values: Array
|
||||||
|
|
||||||
# actual position of points in pixel
|
# actual position of points in pixel
|
||||||
var point_positions : Array
|
var point_positions: Array
|
||||||
|
|
||||||
var legend : Array setget set_legend,get_legend
|
var legend: Array setget set_legend,get_legend
|
||||||
|
|
||||||
# ---------------------
|
# ---------------------
|
||||||
export (Vector2) var SIZE : Vector2 = Vector2() setget _set_size
|
export (Vector2) var SIZE: Vector2 = Vector2() setget _set_size
|
||||||
export (String, FILE, "*.txt, *.csv") var source : String = ""
|
export (String, FILE, "*.txt, *.csv") var source: String = ""
|
||||||
export (String) var delimiter : String = ";"
|
export (String) var delimiter: String = ";"
|
||||||
export (bool) var origin_at_zero : bool = true
|
export (bool) var origin_at_zero: bool = true
|
||||||
|
|
||||||
export (bool) var are_values_columns : bool = false
|
export (bool) var are_values_columns: bool = false
|
||||||
export (int,0,100) var x_values_index : int = 0
|
export (int,0,100) var x_values_index: int = 0
|
||||||
export(bool) var show_x_values_as_labels : bool = true
|
export(bool) var show_x_values_as_labels: bool = true
|
||||||
|
|
||||||
#export (float,1,20,0.5) var column_width : float = 10
|
#export (float,1,20,0.5) var column_width: float = 10
|
||||||
#export (float,0,10,0.5) var column_gap : float = 2
|
#export (float,0,10,0.5) var column_gap: float = 2
|
||||||
|
|
||||||
export (float,0.1,10.0) var x_decim : float = 5.0
|
export (float,0.1,10.0) var x_decim: float = 5.0
|
||||||
export (float,0.1,10.0) var y_decim : float = 5.0
|
export (float,0.1,10.0) var y_decim: float = 5.0
|
||||||
export (PointShapes) var point_shape : int = 0
|
export (PointShapes) var point_shape: int = 0
|
||||||
export (PoolColorArray) var function_colors = [Color("#1e1e1e")]
|
export (PoolColorArray) var function_colors = [Color("#1e1e1e")]
|
||||||
export (Color) var v_lines_color : Color = Color("#cacaca")
|
export (Color) var v_lines_color: Color = Color("#cacaca")
|
||||||
export (Color) var h_lines_color : Color = Color("#cacaca")
|
export (Color) var h_lines_color: Color = Color("#cacaca")
|
||||||
|
|
||||||
export (bool) var boxed : bool = true
|
export (bool) var boxed: bool = true
|
||||||
export (Color) var box_color : Color = Color("#1e1e1e")
|
export (Color) var box_color: Color = Color("#1e1e1e")
|
||||||
export (Font) var font : Font
|
export (Font) var font: Font
|
||||||
export (Font) var bold_font : Font
|
export (Font) var bold_font: Font
|
||||||
export (Color) var font_color : Color = Color("#1e1e1e")
|
export (Color) var font_color: Color = Color("#1e1e1e")
|
||||||
export (TemplatesNames) var template : int = Chart.TemplatesNames.Default setget apply_template
|
export (TemplatesNames) var template: int = Chart.TemplatesNames.Default setget apply_template
|
||||||
export (float,0.1,1) var drawing_duration : float = 0.5
|
export (float,0.1,1) var drawing_duration: float = 0.5
|
||||||
export (bool) var invert_chart : bool = false
|
export (bool) var invert_chart: bool = false
|
||||||
|
|
||||||
var templates : Dictionary = {}
|
var templates: Dictionary = {}
|
||||||
|
|
||||||
signal chart_plotted(chart)
|
signal chart_plotted(chart)
|
||||||
signal point_pressed(point)
|
signal point_pressed(point)
|
||||||
@ -130,7 +130,7 @@ func _get_children():
|
|||||||
Outlines = $Outlines
|
Outlines = $Outlines
|
||||||
Grid = $Grid
|
Grid = $Grid
|
||||||
|
|
||||||
func _set_size(size : Vector2):
|
func _set_size(size: Vector2):
|
||||||
SIZE = size
|
SIZE = size
|
||||||
build_chart()
|
build_chart()
|
||||||
if Engine.editor_hint:
|
if Engine.editor_hint:
|
||||||
@ -154,7 +154,7 @@ func clear():
|
|||||||
func load_font():
|
func load_font():
|
||||||
if font != null:
|
if font != null:
|
||||||
font_size = font.get_height()
|
font_size = font.get_height()
|
||||||
var theme : Theme = Theme.new()
|
var theme: Theme = Theme.new()
|
||||||
theme.set_default_font(font)
|
theme.set_default_font(font)
|
||||||
PointData.set_theme(theme)
|
PointData.set_theme(theme)
|
||||||
else:
|
else:
|
||||||
@ -164,7 +164,7 @@ func load_font():
|
|||||||
if bold_font != null:
|
if bold_font != null:
|
||||||
PointData.Data.set("custom_fonts/font",bold_font)
|
PointData.Data.set("custom_fonts/font",bold_font)
|
||||||
|
|
||||||
func _plot(source_ : String, delimiter_ : String, are_values_columns_ : bool, x_values_index_ : int):
|
func _plot(source_: String, delimiter_: String, are_values_columns_: bool, x_values_index_: int):
|
||||||
randomize()
|
randomize()
|
||||||
|
|
||||||
clear()
|
clear()
|
||||||
@ -240,8 +240,8 @@ func draw_outlines():
|
|||||||
|
|
||||||
func draw_v_grid():
|
func draw_v_grid():
|
||||||
for p in x_chors.size():
|
for p in x_chors.size():
|
||||||
var point : Vector2 = origin+Vector2((p)*x_pass,0)
|
var point: Vector2 = origin+Vector2((p)*x_pass,0)
|
||||||
var v_grid : Line2D = Line2D.new()
|
var v_grid: Line2D = Line2D.new()
|
||||||
Grid.add_child(v_grid)
|
Grid.add_child(v_grid)
|
||||||
v_grid.set_width(1)
|
v_grid.set_width(1)
|
||||||
v_grid.set_default_color(v_lines_color)
|
v_grid.set_default_color(v_lines_color)
|
||||||
@ -252,8 +252,8 @@ func draw_v_grid():
|
|||||||
|
|
||||||
func draw_h_grid():
|
func draw_h_grid():
|
||||||
for p in y_chors.size():
|
for p in y_chors.size():
|
||||||
var point : Vector2 = origin-Vector2(0,(p)*y_pass)
|
var point: Vector2 = origin-Vector2(0,(p)*y_pass)
|
||||||
var h_grid : Line2D = Line2D.new()
|
var h_grid: Line2D = Line2D.new()
|
||||||
Grid.add_child(h_grid)
|
Grid.add_child(h_grid)
|
||||||
h_grid.set_width(1)
|
h_grid.set_width(1)
|
||||||
h_grid.set_default_color(h_lines_color)
|
h_grid.set_default_color(h_lines_color)
|
||||||
@ -263,8 +263,8 @@ func draw_h_grid():
|
|||||||
yield(GridTween,"tween_all_completed")
|
yield(GridTween,"tween_all_completed")
|
||||||
|
|
||||||
|
|
||||||
func add_label(point : Vector2, text : String):
|
func add_label(point: Vector2, text: String):
|
||||||
var lbl : Label = Label.new()
|
var lbl: Label = Label.new()
|
||||||
if font != null:
|
if font != null:
|
||||||
lbl.set("custom_fonts/font",font)
|
lbl.set("custom_fonts/font",font)
|
||||||
lbl.set("custom_colors/font_color",font_color)
|
lbl.set("custom_colors/font_color",font_color)
|
||||||
@ -276,11 +276,11 @@ func draw_functions():
|
|||||||
for function in point_positions.size():
|
for function in point_positions.size():
|
||||||
draw_function(function,point_positions[function])
|
draw_function(function,point_positions[function])
|
||||||
|
|
||||||
func draw_function(f_index : int, function : Array):
|
func draw_function(f_index: int, function: Array):
|
||||||
var line : Line2D = Line2D.new()
|
var line: Line2D = Line2D.new()
|
||||||
var backline : Line2D = Line2D.new()
|
var backline: Line2D = Line2D.new()
|
||||||
construct_line(line,backline,f_index,function)
|
construct_line(line,backline,f_index,function)
|
||||||
var pointv : Point
|
var pointv: Point
|
||||||
for point in function.size():
|
for point in function.size():
|
||||||
pointv = point_node.instance()
|
pointv = point_node.instance()
|
||||||
Functions.add_child(pointv)
|
Functions.add_child(pointv)
|
||||||
@ -296,7 +296,7 @@ func draw_function(f_index : int, function : Array):
|
|||||||
yield(FunctionsTween,"tween_all_completed")
|
yield(FunctionsTween,"tween_all_completed")
|
||||||
|
|
||||||
|
|
||||||
func construct_line(line : Line2D, backline : Line2D, f_index : int, function : Array):
|
func construct_line(line: Line2D, backline: Line2D, f_index: int, function: Array):
|
||||||
var midtone = Color(Color(function_colors[f_index]).r,Color(function_colors[f_index]).g,Color(function_colors[f_index]).b,Color(function_colors[f_index]).a/2)
|
var midtone = Color(Color(function_colors[f_index]).r,Color(function_colors[f_index]).g,Color(function_colors[f_index]).b,Color(function_colors[f_index]).a/2)
|
||||||
backline.set_width(3)
|
backline.set_width(3)
|
||||||
backline.set_default_color(midtone)
|
backline.set_default_color(midtone)
|
||||||
@ -307,12 +307,12 @@ func construct_line(line : Line2D, backline : Line2D, f_index : int, function :
|
|||||||
line.antialiased = true
|
line.antialiased = true
|
||||||
Functions.add_child(line)
|
Functions.add_child(line)
|
||||||
|
|
||||||
func read_datas(source : String, delimiter : String):
|
func read_datas(source: String, delimiter: String):
|
||||||
var file : File = File.new()
|
var file: File = File.new()
|
||||||
file.open(source,File.READ)
|
file.open(source,File.READ)
|
||||||
var content : Array
|
var content: Array
|
||||||
while not file.eof_reached():
|
while not file.eof_reached():
|
||||||
var line : PoolStringArray = file.get_csv_line(delimiter)
|
var line: PoolStringArray = file.get_csv_line(delimiter)
|
||||||
content.append(line)
|
content.append(line)
|
||||||
file.close()
|
file.close()
|
||||||
for data in content:
|
for data in content:
|
||||||
@ -320,14 +320,14 @@ func read_datas(source : String, delimiter : String):
|
|||||||
content.erase(data)
|
content.erase(data)
|
||||||
return content
|
return content
|
||||||
|
|
||||||
func structure_datas(database : Array, are_values_columns : bool, x_values_index : int):
|
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
|
# @x_values_index can be either a column or a row relative to x values
|
||||||
# @y_values can be either a column or a row relative to y values
|
# @y_values can be either a column or a row relative to y values
|
||||||
self.are_values_columns = are_values_columns
|
self.are_values_columns = are_values_columns
|
||||||
match are_values_columns:
|
match are_values_columns:
|
||||||
true:
|
true:
|
||||||
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 == x_values_index:
|
||||||
var x_data = database[row][column]
|
var x_data = database[row][column]
|
||||||
@ -361,8 +361,8 @@ func structure_datas(database : Array, are_values_columns : bool, x_values_index
|
|||||||
data[value] = data[value] as float
|
data[value] = data[value] as float
|
||||||
|
|
||||||
# draw y labels
|
# draw y labels
|
||||||
var to_order : Array
|
var to_order: Array
|
||||||
var to_order_min : Array
|
var to_order_min: Array
|
||||||
for cluster in y_datas.size():
|
for cluster in y_datas.size():
|
||||||
# define x_chors and y_chors
|
# define x_chors and y_chors
|
||||||
var ordered_cluster = y_datas[cluster] as Array
|
var ordered_cluster = y_datas[cluster] as Array
|
||||||
@ -429,7 +429,7 @@ func calculate_coordinates():
|
|||||||
|
|
||||||
if invert_chart:
|
if invert_chart:
|
||||||
for column in y_datas[0].size():
|
for column in y_datas[0].size():
|
||||||
var single_coordinates : Array
|
var single_coordinates: Array
|
||||||
for row in y_datas:
|
for row in y_datas:
|
||||||
if origin_at_zero:
|
if origin_at_zero:
|
||||||
single_coordinates.append((row[column]*y_pass)/v_dist)
|
single_coordinates.append((row[column]*y_pass)/v_dist)
|
||||||
@ -438,7 +438,7 @@ func calculate_coordinates():
|
|||||||
y_coordinates.append(single_coordinates)
|
y_coordinates.append(single_coordinates)
|
||||||
else:
|
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():
|
||||||
if origin_at_zero:
|
if origin_at_zero:
|
||||||
single_coordinates.append((cluster[value]*y_pass)/v_dist)
|
single_coordinates.append((cluster[value]*y_pass)/v_dist)
|
||||||
@ -502,7 +502,7 @@ func clear_points():
|
|||||||
for function in Functions.get_children():
|
for function in Functions.get_children():
|
||||||
function.queue_free()
|
function.queue_free()
|
||||||
|
|
||||||
func set_legend(l : Array):
|
func set_legend(l: Array):
|
||||||
legend = l
|
legend = l
|
||||||
|
|
||||||
func get_legend():
|
func get_legend():
|
||||||
@ -530,12 +530,12 @@ func create_legend():
|
|||||||
legend.clear()
|
legend.clear()
|
||||||
for function in functions:
|
for function in functions:
|
||||||
var function_legend = FunctionLegend.instance()
|
var function_legend = FunctionLegend.instance()
|
||||||
var f_name : String
|
var f_name: String
|
||||||
if invert_chart:
|
if invert_chart:
|
||||||
f_name = x_datas[function] as String
|
f_name = x_datas[function] as String
|
||||||
else:
|
else:
|
||||||
f_name = y_labels[function]
|
f_name = y_labels[function]
|
||||||
var legend_font : Font
|
var legend_font: Font
|
||||||
if font != null:
|
if font != null:
|
||||||
legend_font = font
|
legend_font = font
|
||||||
if bold_font != null:
|
if bold_font != null:
|
||||||
@ -543,7 +543,7 @@ func create_legend():
|
|||||||
function_legend.create_legend(f_name,function_colors[function],bold_font,font_color)
|
function_legend.create_legend(f_name,function_colors[function],bold_font,font_color)
|
||||||
legend.append(function_legend)
|
legend.append(function_legend)
|
||||||
|
|
||||||
func apply_template(template_name : int):
|
func apply_template(template_name: int):
|
||||||
template = template_name
|
template = template_name
|
||||||
templates = Utilities._load_templates()
|
templates = Utilities._load_templates()
|
||||||
if template_name!=null:
|
if template_name!=null:
|
||||||
@ -565,5 +565,5 @@ func _enter_tree():
|
|||||||
_ready()
|
_ready()
|
||||||
|
|
||||||
# Signal Repeaters
|
# Signal Repeaters
|
||||||
func point_pressed(point : Point) -> Point:
|
func point_pressed(point: Point) -> Point:
|
||||||
return point
|
return point
|
||||||
|
Loading…
Reference in New Issue
Block a user