Add files via upload

This commit is contained in:
fenix-hub 2020-05-14 13:55:30 +02:00 committed by GitHub
parent 1bb4f80759
commit 529da43016
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 87 additions and 22 deletions

View File

@ -12,10 +12,7 @@ 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 source : String var OFFSET : Vector2 = Vector2(0,0)
var delimiter : String
var OFFSET : Vector2 = Vector2(50,30)
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
var origin : Vector2 var origin : Vector2
@ -29,7 +26,6 @@ var v_dist : float
# quantization, representing the interval in which values will be displayed # quantization, representing the interval in which values will be displayed
var x_decim : float = 1.0 var x_decim : float = 1.0
export (float) var y_decim : float = 5.0
# define values on x an y axis # define values on x an y axis
var x_chors : Array var x_chors : Array
@ -61,26 +57,43 @@ var point_values : Array
var point_positions : Array var point_positions : Array
var legend : Array setget set_legend,get_legend var legend : Array setget set_legend,get_legend
var are_values_columns : bool
# --------------------- # ---------------------
export (bool) var invert_xy : bool
var SIZE : Vector2 = Vector2() var SIZE : Vector2 = Vector2()
export (String, FILE) var source : String = ""
export (String) var delimiter : String = ";"
export (bool) var are_values_columns : bool = false
export (bool) var invert_xy : bool = false
export (int,0,100) var x_values : int = 0
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) var y_decim : float = 5.0
export (PoolColorArray) var function_colors = [Color("#1e1e1e")] export (PoolColorArray) var function_colors = [Color("#1e1e1e")]
export (bool) var boxed : bool = true
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 (Color) var outline_color : Color = Color("#1e1e1e") export (Color) var outline_color : Color = Color("#1e1e1e")
export (float,0.01,1) var drawing_duration : float = 0.3
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 (String,"Default","Clean","Minimal","Invert") var template : String = "Default" setget apply_template export (String,"Default","Clean","Gradient","Minimal","Invert") var template : String = "Default" setget apply_template
signal linechart_plotted() var templates : Dictionary = {}
#func _ready(): signal chart_plotted(chart)
# plot_line_chart("res://ChartNode/datas.csv",";",true,0) signal point_pressed(point)
func plot_line_chart(source_ : String, delimiter_ : String, are_values_columns_ : bool, x_values_ : int, invert_xy_ : bool = false):
func _ready():
pass
func _plot(source_ : String, delimiter_ : String, are_values_columns_ : bool, x_values_ : int, invert_xy_ : bool = false):
randomize() randomize()
load_font() load_font()
@ -94,7 +107,26 @@ func plot_line_chart(source_ : String, delimiter_ : String, are_values_columns_
calculate_coordinates() calculate_coordinates()
calculate_colors() calculate_colors()
create_legend() create_legend()
emit_signal("linechart_plotted") emit_signal("chart_plotted")
func plot():
randomize()
load_font()
PointData.hide()
if source == "" or source == null:
Utilities._print_message("Can't plot a chart without a Source file. Please, choose it in editor, or use the custom function _plot().",1)
return
datas = read_datas(source,delimiter)
count_functions()
structure_datas(datas,are_values_columns,x_values)
build_chart()
calculate_pass()
calculate_coordinates()
calculate_colors()
create_legend()
emit_signal("chart_plotted")
func calculate_colors(): func calculate_colors():
if function_colors.empty() or function_colors.size() < functions: if function_colors.empty() or function_colors.size() < functions:
@ -177,7 +209,7 @@ func structure_datas(database : Array, are_values_columns : bool, x_values : int
y_chors.append(p as String) y_chors.append(p as String)
func build_chart(): func build_chart():
SIZE = get_parent().get_size() SIZE = get_size()
origin = Vector2(OFFSET.x,SIZE.y-OFFSET.y) origin = Vector2(OFFSET.x,SIZE.y-OFFSET.y)
func calculate_pass(): func calculate_pass():
@ -388,10 +420,17 @@ func apply_template(template_name : String):
if Engine.editor_hint: if Engine.editor_hint:
if template_name!=null and template_name!="": if template_name!=null and template_name!="":
template = template_name template = template_name
var custom_template = get_parent().templates[template_name.to_lower()] var custom_template = templates[template_name.to_lower()]
function_colors[0] = Color(custom_template.function_color) function_colors = custom_template.function_colors
v_lines_color = Color(custom_template.v_lines_color) v_lines_color = Color(custom_template.v_lines_color)
h_lines_color = Color(custom_template.h_lines_color) h_lines_color = Color(custom_template.h_lines_color)
outline_color = Color(custom_template.outline_color) outline_color = Color(custom_template.outline_color)
font_color = Color(custom_template.font_color) font_color = Color(custom_template.font_color)
property_list_changed_notify() property_list_changed_notify()
func _script_changed():
_ready()
func _enter_tree():
templates = Utilities._load_templates()

View File

@ -44,6 +44,8 @@ __meta__ = {
[node name="PointData" parent="." instance=ExtResource( 1 )] [node name="PointData" parent="." instance=ExtResource( 1 )]
[node name="PointData" parent="PointData" index="0"] [node name="PointData" parent="PointData" index="0"]
visible = false
theme = SubResource( 1 ) theme = SubResource( 1 )
[connection signal="script_changed" from="." to="." method="_script_changed"]
[editable path="PointData"] [editable path="PointData"]

View File

@ -3,19 +3,31 @@ extends VBoxContainer
onready var Function : Label = $Function onready var Function : Label = $Function
onready var FunctionColor : ColorRect = $Color onready var FunctionColor : ColorRect = $Color
var text : String var function : String setget set_function, get_function
var color : Color var color : Color setget set_function_color, get_function_color
var font_color : Color var font_color : Color
var font : Font var font : Font
func _ready(): func _ready():
Function.set("custom_fonts/font",font) Function.set("custom_fonts/font",font)
Function.set("custom_colors/font_color",font_color) Function.set("custom_colors/font_color",font_color)
Function.set_text(text) Function.set_text(function)
FunctionColor.set_frame_color(color) FunctionColor.set_frame_color(color)
func create_legend(text : String, color : Color, font : Font, font_color : Color): func create_legend(text : String, color : Color, font : Font, font_color : Color):
self.text = text self.function = text
self.color = color self.color = color
self.font_color = font_color self.font_color = font_color
self.font = font self.font = font
func set_function( t : String ):
function = t
func get_function() -> String:
return function
func set_function_color( c : Color ):
color = c
func get_function_color() -> Color:
return color

View File

@ -4,9 +4,9 @@ class_name Point
const OFFSET : Vector2 = Vector2(13,13) const OFFSET : Vector2 = Vector2(13,13)
var point_value : Array setget set_value,get_value var point_value : Array setget set_value,get_value
var point_position : Vector2 var point_position : Vector2
var color : Color var color : Color setget set_color_point, get_color_point
var color_outline : Color var color_outline : Color
var function : String var function : String setget set_function, get_function
var mouse_entered : bool = false var mouse_entered : bool = false
@ -78,3 +78,15 @@ func set_value( v : Array = [] ) :
func get_value() -> Array: func get_value() -> Array:
return point_value return point_value
func set_color_point( c : Color ):
color = c
func get_color_point() -> Color:
return color
func set_function( f : String ):
function = f
func get_function() -> String:
return function