Update 0.4.5

*added*:  
- class names for all custom Chart classes
- class name for LegendElement

*fixed*:
- minor bugs
- changed FunctionLegend to LegendElement
This commit is contained in:
Nicolò Santilio 2020-11-09 18:16:36 +01:00 committed by GitHub
parent 260a27f0ef
commit e6d91dd707
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 447 additions and 403 deletions

View File

@ -1,5 +1,6 @@
tool
extends Chart
class_name BarChart
"""
[BarChart] - General purpose node for Bar Charts
@ -374,7 +375,7 @@ func draw_chart_outlines():
func create_legend():
legend.clear()
for function in functions:
var function_legend = FunctionLegend.instance()
var function_legend = LegendElement.instance()
var f_name : String
if invert_chart:
f_name = x_datas[function] as String

View File

@ -82,10 +82,10 @@ __meta__ = {
[node name="PointData" parent="PointData" index="0"]
visible = false
margin_left = -223.769
margin_top = -45.5654
margin_right = -223.906
margin_bottom = -44.7655
margin_left = 41.5506
margin_top = -149.501
margin_right = 41.4136
margin_bottom = -148.701
theme = SubResource( 1 )
[editable path="PointData"]

View File

@ -1,5 +1,6 @@
tool
extends Chart2D
class_name BarChart2D
"""
[BarChart2D] - General purpose node for Bar Charts

View File

@ -54,5 +54,9 @@ default_color = Color( 0.117647, 0.117647, 0.117647, 1 )
[node name="PointData" parent="PointData" index="0"]
visible = false
margin_left = 48.6217
margin_top = -122.631
margin_right = 48.4856
margin_bottom = -121.831
[editable path="PointData"]

View File

@ -1,5 +1,6 @@
tool
extends Chart
class_name LineChart
# [Linechart] - General purpose node for Line Charts
# A line chart or line plot or line graph or curve chart is a type of chart which

View File

@ -1,5 +1,6 @@
tool
extends Chart2D
class_name LineChart2D
# [Linechart2D] - General purpose node for Line Charts
# A line chart or line plot or line graph or curve chart is a type of chart which

View File

@ -19,7 +19,7 @@ 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.
In these cases they are known as run charts."
}
function_colors = [ "#1e1e1e", "#1e1e1e", "#1e1e1e", "#1e1e1e" ]
function_colors = PoolColorArray( 0.117647, 0.117647, 0.117647, 1, 0.117647, 0.117647, 0.117647, 1, 0.117647, 0.117647, 0.117647, 1, 0.117647, 0.117647, 0.117647, 1 )
[node name="Grid" type="Node2D" parent="."]
@ -34,7 +34,7 @@ width = 1.0
default_color = Color( 0.792157, 0.792157, 0.792157, 1 )
[node name="Outlines" type="Line2D" parent="."]
points = PoolVector2Array( 0, 0, 2, 0, 2, 2, 0, 2, 0, 0 )
points = PoolVector2Array( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
width = 2.0
default_color = Color( 0.117647, 0.117647, 0.117647, 1 )
@ -55,5 +55,9 @@ default_color = Color( 0.117647, 0.117647, 0.117647, 1 )
[node name="PointData" parent="PointData" index="0"]
visible = false
margin_left = 52.8643
margin_top = -115.56
margin_right = 52.7283
margin_bottom = -114.76
[editable path="PointData"]

View File

@ -54,9 +54,9 @@ __meta__ = {
[node name="PointData" parent="PointData" index="0"]
visible = false
margin_left = -148.407
margin_top = -156.174
margin_right = -148.543
margin_bottom = -155.375
margin_left = -449.181
margin_top = -266.881
margin_right = -449.318
margin_bottom = -266.082
[editable path="PointData"]

View File

@ -1,5 +1,6 @@
tool
extends Chart
class_name PieChart
var should_draw : bool = false
var area_angles : Array
@ -176,9 +177,15 @@ func calculate_coordinates():
func calculate_circle_arc_polygon(center : Vector2, radius : float, angle_from : float, angle_to : float, color : Color) -> PoolVector2Array:
var nb_points : int = 32
var points_arc : PoolVector2Array = PoolVector2Array()
# var chord_angle : float = ((angle_to - angle_from)/2)+angle_from
# angle_from += 0.2
# angle_to -= 0.2
# var displacement : Vector2 = Vector2(cos(deg2rad(chord_angle)), sin(deg2rad(chord_angle-180))).normalized()*10
# print(displacement)
# center += displacement
# radius+=displacement.length()
points_arc.push_back(center)
var colors : PoolColorArray = PoolColorArray([color])
for i in range(nb_points + 1):
var angle_point = deg2rad(angle_from + i * (angle_to - angle_from) / nb_points - 90)
points_arc.push_back(center + Vector2(cos(angle_point), sin(angle_point)) * radius)

View File

@ -1,5 +1,6 @@
tool
extends Chart
class_name RadarChart
"""
[RadarChart] - General purpose node for Radar Charts

View File

@ -21,7 +21,6 @@ uninformative, but various heuristics, such as algorithms that plot data as the
total area, can be applied to sort the variables (axes) into relative positions that reveal
distinct correlations, trade-offs, and a multitude of other comparative measures."
}
delimiter = ";"
Chart_Properties/are_values_columns = false
Chart_Properties/labels_index = 0
Chart_Properties/function_names_index = 0
@ -78,10 +77,10 @@ __meta__ = {
[node name="PointData" parent="PointData" index="0"]
visible = false
margin_left = -230.138
margin_top = -125.6
margin_right = -230.275
margin_bottom = -124.801
margin_left = 64.178
margin_top = -142.43
margin_right = 64.041
margin_bottom = -141.631
theme = SubResource( 1 )
[editable path="PointData"]

View File

@ -1,5 +1,6 @@
tool
extends Chart
class_name ScatterChart
"""
[ScatterChart] - General purpose node for Scatter Charts

View File

@ -76,10 +76,10 @@ __meta__ = {
[node name="PointData" parent="PointData" index="0"]
visible = false
margin_left = -19.0
margin_top = -63.0
margin_right = -19.136
margin_bottom = -62.2
margin_left = 58.5211
margin_top = -187.685
margin_right = 58.3851
margin_bottom = -186.885
theme = SubResource( 1 )
[editable path="PointData"]

View File

@ -1,5 +1,6 @@
tool
extends Chart2D
class_name ScatterChart2D
"""
[ScatterChart2D] - General purpose node for Scatter Charts

View File

@ -46,5 +46,9 @@ default_color = Color( 0.117647, 0.117647, 0.117647, 1 )
[node name="PointData" parent="PointData" index="0"]
visible = false
margin_left = 71.2491
margin_top = -146.673
margin_right = 71.1131
margin_bottom = -145.873
[editable path="PointData"]

View File

@ -1,5 +1,6 @@
tool
extends Spatial
class_name ScatterChart3D
"""
[ScatterChart] - General purpose node for Scatter Charts

View File

@ -42,4 +42,11 @@ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 9, 0 )
[node name="PointData" parent="." instance=ExtResource( 2 )]
[node name="PointData" parent="PointData" index="0"]
visible = false
margin_left = 47.2074
margin_top = -150.915
margin_right = 47.0714
margin_bottom = -150.115
[editable path="PointData"]

View File

@ -1,5 +1,6 @@
tool
extends VBoxContainer
class_name LegendElement
onready var Function : Label = $Function
onready var FunctionColor : ColorRect = $Color
@ -32,3 +33,9 @@ func set_function_color( c : Color ):
func get_function_color() -> Color:
return color
func get_class() -> String:
return "Legend Element"
func _to_string() -> String:
return "%s (%s, %s) " % [get_class(), get_function(), get_function_color().to_html(true)]

View File

@ -1,8 +1,10 @@
extends Control
class_name Chart
# Classes
# Signals ..................................
signal chart_plotted(chart)
signal chart_plotted(chart) # emit when a chart is plotted (static) or updated (dynamic)
signal point_pressed(point)
# Onready Vars ............................
@ -13,7 +15,7 @@ onready var ChartName : Label = $ChartName
# Scenes and Reosurces ......................
var point_node : PackedScene = preload("../Point/Point.tscn")
var FunctionLegend : PackedScene = preload("../Legend/FunctionLegend.tscn")
var LegendElement : PackedScene = preload("../Legend/FunctionLegend.tscn")
# Enums .....................................
enum PointShapes { Dot, Triangle, Square, Cross }
@ -315,6 +317,8 @@ func plot_from_array(array : Array) -> void:
create_legend()
emit_signal("chart_plotted",self)
# Append new data (in array format) to the already plotted data.
# All data are stored.
func update_plot_data(array : Array) -> void:
if array.empty():
Utilities._print_message("Can't plot a chart without an empty Array.",1)
@ -421,7 +425,7 @@ func function_colors():
func create_legend():
legend.clear()
for function in functions:
var function_legend = FunctionLegend.instance()
var function_legend : LegendElement = LegendElement.instance()
var f_name : String = y_labels[function]
var legend_font : Font
if font != null:
@ -590,7 +594,7 @@ func set_invert_chart(b : bool):
func set_legend(l : Array):
legend = l
func get_legend():
func get_legend() -> Array:
return legend
# ............................. Shared Signals ..............................