mirror of
https://github.com/Relintai/pandemonium_engine_easy_charts.git
synced 2024-11-20 10:47:22 +01:00
fix plot updating
This commit is contained in:
parent
38b78bfd64
commit
687562a7a2
@ -1,5 +1,5 @@
|
||||
tool
|
||||
extends Chart
|
||||
extends ScatterChartBase
|
||||
class_name RadarChart
|
||||
|
||||
"""
|
||||
@ -125,75 +125,76 @@ func _get_property_list():
|
||||
},
|
||||
]
|
||||
|
||||
func structure_data(database : Array):
|
||||
# @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
|
||||
are_values_columns = invert_chart != are_values_columns
|
||||
match are_values_columns:
|
||||
true:
|
||||
for row in database.size():
|
||||
var t_row : Array = []
|
||||
for column in database[row].size():
|
||||
if row == labels_index:
|
||||
if column == function_names_index:
|
||||
pass
|
||||
else:
|
||||
x_labels.append(database[row][column])
|
||||
else:
|
||||
if column == function_names_index:
|
||||
y_labels.append(database[row][column])
|
||||
else:
|
||||
if typeof(database[row][column]) == TYPE_INT or typeof(database[row][column]) == TYPE_REAL:
|
||||
t_row.append(database[row][column] as float)
|
||||
else:
|
||||
t_row.append(database[row][column].replace(",", ".") as float)
|
||||
if not t_row.empty():
|
||||
x_datas.append(t_row)
|
||||
false:
|
||||
for row in database.size():
|
||||
if row == function_names_index:
|
||||
y_labels = database[row] as PoolStringArray
|
||||
|
||||
var x_temp_datas : PoolRealArray = []
|
||||
for column in database[row].size():
|
||||
if column == labels_index:
|
||||
x_labels.append(database[row][column] as String)
|
||||
else:
|
||||
x_temp_datas.append(database[row][column] as float)
|
||||
x_datas.append(x_temp_datas)
|
||||
|
||||
|
||||
if labels_index == -1 :
|
||||
for data in x_datas[0].size():
|
||||
x_labels.append("Element %s" % data)
|
||||
|
||||
if function_names_index == -1 :
|
||||
for data in x_datas.size():
|
||||
y_labels.append("Function %s" % data)
|
||||
|
||||
func build_chart():
|
||||
SIZE = get_size()
|
||||
origin = OFFSET + SIZE/2
|
||||
#func structure_data(database : Array):
|
||||
# # @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
|
||||
# are_values_columns = invert_chart != are_values_columns
|
||||
# match are_values_columns:
|
||||
# true:
|
||||
# for row in database.size():
|
||||
# var t_row : Array = []
|
||||
# for column in database[row].size():
|
||||
# if row == labels_index:
|
||||
# if column == function_names_index:
|
||||
# pass
|
||||
# else:
|
||||
# x_labels.append(database[row][column])
|
||||
# else:
|
||||
# if column == function_names_index:
|
||||
# y_labels.append(database[row][column])
|
||||
# else:
|
||||
# if typeof(database[row][column]) == TYPE_INT or typeof(database[row][column]) == TYPE_REAL:
|
||||
# t_row.append(database[row][column] as float)
|
||||
# else:
|
||||
# t_row.append(database[row][column].replace(",", ".") as float)
|
||||
# if not t_row.empty():
|
||||
# x_datas.append(t_row)
|
||||
# false:
|
||||
# for row in database.size():
|
||||
# if row == function_names_index:
|
||||
# y_labels = database[row] as PoolStringArray
|
||||
#
|
||||
# var x_temp_datas : PoolRealArray = []
|
||||
# for column in database[row].size():
|
||||
# if column == labels_index:
|
||||
# x_labels.append(database[row][column] as String)
|
||||
# else:
|
||||
# x_temp_datas.append(database[row][column] as float)
|
||||
# x_datas.append(x_temp_datas)
|
||||
#
|
||||
#
|
||||
# if labels_index == -1 :
|
||||
# for data in x_datas[0].size():
|
||||
# x_labels.append("Element %s" % data)
|
||||
#
|
||||
# if function_names_index == -1 :
|
||||
# for data in x_datas.size():
|
||||
# y_labels.append("Function %s" % data)
|
||||
#
|
||||
#func build_chart():
|
||||
# SIZE = get_size()
|
||||
# origin = OFFSET + SIZE/2
|
||||
#
|
||||
#
|
||||
#func calculate_pass() :
|
||||
# var ordered_max : Array
|
||||
# for data in x_datas :
|
||||
# var ordered_data : Array = data.duplicate()
|
||||
# ordered_data.sort()
|
||||
# ordered_max.append(ordered_data.pop_back())
|
||||
# ordered_max.sort()
|
||||
# var max_value : float = ordered_max.pop_back()
|
||||
# var dist = full_scale * pow(10.0,str(max_value).length()-2)
|
||||
# var multi = 0
|
||||
# var value = dist * multi
|
||||
# x_chors.append(value as String)
|
||||
# while value < max_value:
|
||||
# multi+=1
|
||||
# value = dist * multi
|
||||
# x_chors.append(value as String)
|
||||
|
||||
var radar_polygon : Array
|
||||
|
||||
func calculate_pass() :
|
||||
var ordered_max : Array
|
||||
for data in x_datas :
|
||||
var ordered_data : Array = data.duplicate()
|
||||
ordered_data.sort()
|
||||
ordered_max.append(ordered_data.pop_back())
|
||||
ordered_max.sort()
|
||||
var max_value : float = ordered_max.pop_back()
|
||||
var dist = full_scale * pow(10.0,str(max_value).length()-2)
|
||||
var multi = 0
|
||||
var value = dist * multi
|
||||
x_chors.append(value as String)
|
||||
while value < max_value:
|
||||
multi+=1
|
||||
value = dist * multi
|
||||
x_chors.append(value as String)
|
||||
|
||||
func calculate_coordinates():
|
||||
for chor in x_chors.size():
|
||||
var inner_polyline : PoolVector2Array
|
||||
|
@ -45,6 +45,8 @@ var y_coordinates : Array
|
||||
|
||||
# data contained in file
|
||||
var data : Array
|
||||
# If using a Dataframe
|
||||
var dataframe: DataFrame
|
||||
|
||||
# amount of functions to represent
|
||||
var functions : int = 0
|
||||
@ -325,10 +327,6 @@ func plot(_dataset: Array = read_data(source, delimiter)) -> void:
|
||||
load_font()
|
||||
data_tooltip.hide()
|
||||
|
||||
if source == "" or source == null:
|
||||
ECUtilities._print_message("Can't plot a chart without a Source file. Please, choose it in editor, or use the custom function _plot().",1)
|
||||
return
|
||||
|
||||
if _dataset.empty():
|
||||
ECUtilities._print_message("Can't plot a chart with an empty Array.",1)
|
||||
return
|
||||
@ -341,9 +339,14 @@ func plot(_dataset: Array = read_data(source, delimiter)) -> void:
|
||||
if not is_connected("item_rect_changed", self, "redraw_plot"): connect("item_rect_changed", self, "redraw_plot")
|
||||
|
||||
func plot_from_source(file : String, _delimiter : String = delimiter) -> void:
|
||||
if source == "" or source == null:
|
||||
ECUtilities._print_message("Can't plot a chart without a Source file. Please, choose it in editor, or use the custom function _plot().",1)
|
||||
return
|
||||
|
||||
plot(read_data(file, _delimiter))
|
||||
|
||||
func plot_from_dataframe(dataframe : DataFrame) -> void:
|
||||
self.dataframe = dataframe
|
||||
plot(dataframe.get_dataset())
|
||||
|
||||
func plot_placeholder() -> void:
|
||||
@ -354,7 +357,7 @@ func plot_placeholder() -> void:
|
||||
# All data are stored.
|
||||
func update_plot(new_data : Array = []) -> void:
|
||||
if not new_data.empty(): data.append(new_data)
|
||||
plot(data)
|
||||
plot(data if dataframe == null else dataframe.get_dataset())
|
||||
|
||||
# Append a new column to data
|
||||
func append_new_column(dataset : Array, column : Array):
|
||||
|
@ -540,8 +540,6 @@ func draw_chart_outlines():
|
||||
func draw_points():
|
||||
for function in point_values.size():
|
||||
var PointContainer : Control = Control.new()
|
||||
PointContainer.name = "PointContainer"
|
||||
|
||||
Points.add_child(PointContainer)
|
||||
|
||||
for function_point in point_values[function].size():
|
||||
|
Loading…
Reference in New Issue
Block a user