mirror of
https://github.com/Relintai/pandemonium_engine_easy_charts.git
synced 2025-04-13 21:00:46 +02:00
update slicing
This commit is contained in:
parent
f16becf79e
commit
a5ce0a5cd6
@ -331,8 +331,15 @@ func plot(_dataset: Array = read_data(source, delimiter)) -> void:
|
|||||||
ECUtilities._print_message("Can't plot a chart with an empty Array.",1)
|
ECUtilities._print_message("Can't plot a chart with an empty Array.",1)
|
||||||
return
|
return
|
||||||
|
|
||||||
data = _dataset
|
are_values_columns = invert_chart != are_values_columns
|
||||||
structure_data(slice_data(data))
|
|
||||||
|
# Read the dataset in the proper way
|
||||||
|
var database : Array = _dataset \
|
||||||
|
if not are_values_columns \
|
||||||
|
else MatrixGenerator.transpose(Matrix.new(_dataset)).to_array()
|
||||||
|
|
||||||
|
data = slice_data(database)
|
||||||
|
structure_data(data)
|
||||||
compute_display()
|
compute_display()
|
||||||
display_plot()
|
display_plot()
|
||||||
emit_signal("chart_plotted",self)
|
emit_signal("chart_plotted",self)
|
||||||
@ -382,22 +389,20 @@ func read_data(source : String, _delimiter : String = delimiter):
|
|||||||
file.close()
|
file.close()
|
||||||
return content.duplicate(true)
|
return content.duplicate(true)
|
||||||
|
|
||||||
func slice_data(data: Array) -> Array:
|
func slice_data(database : Array) -> Array:
|
||||||
var data_to_display : Array
|
var data_to_display : Array
|
||||||
data_to_display.resize(data.size())
|
data_to_display.resize(database.size())
|
||||||
if only_disp_values == Vector2(0,0) :
|
if only_disp_values == Vector2(): return database.duplicate(true)
|
||||||
data_to_display = data.duplicate(true)
|
if only_disp_values.x == 0 and only_disp_values.y < database.size():
|
||||||
elif only_disp_values.x == 0 and only_disp_values.y < data[0].size():
|
data_to_display = [database[0]] + database.slice(database.size()-only_disp_values.y, database.size()-1)
|
||||||
for row_idx in data.size():
|
elif only_disp_values.y == 0 and only_disp_values.x < database[0].size():
|
||||||
data_to_display[row_idx] = [data[row_idx][0]] + data[row_idx].slice(data[row_idx].size()-only_disp_values.y, data[row_idx].size()-1)
|
for row_idx in database.size():
|
||||||
elif only_disp_values.y == 0 and only_disp_values.x < data[0].size():
|
data_to_display[row_idx] = [database[row_idx][0]] + Array(database[row_idx]).slice(database[row_idx].size() - only_disp_values.x, database[row_idx].size() -1 )
|
||||||
for row_idx in data.size():
|
elif only_disp_values.x != 0 and only_disp_values.y != 0 and only_disp_values.y < database[0].size() and only_disp_values.x < database[0].size():
|
||||||
data_to_display[row_idx] = [data[row_idx][0]] + data[row_idx].slice(1, only_disp_values.x)
|
for row_idx in database.size():
|
||||||
elif only_disp_values.x != 0 and only_disp_values.y != 0 and only_disp_values.y < data[0].size() and only_disp_values.x < data[0].size():
|
data_to_display[row_idx] = [database[row_idx][0]] + database[row_idx].slice(only_disp_values.x, database[row_idx].size()-only_disp_values.y)
|
||||||
for row_idx in data.size():
|
|
||||||
data_to_display[row_idx] = [data[row_idx][0]] + data[row_idx].slice(only_disp_values.x, data[row_idx].size()-only_disp_values.y)
|
|
||||||
else:
|
else:
|
||||||
data_to_display = data.duplicate(true)
|
data_to_display = database.duplicate(true)
|
||||||
return data_to_display
|
return data_to_display
|
||||||
|
|
||||||
# ................................. Display and Draw functions .......................
|
# ................................. Display and Draw functions .......................
|
||||||
|
@ -363,7 +363,7 @@ func generate_identifier():
|
|||||||
return "f%d" % (y_labels.size() + 1)
|
return "f%d" % (y_labels.size() + 1)
|
||||||
|
|
||||||
|
|
||||||
func structure_data(dataset : Array):
|
func structure_data(database : Array):
|
||||||
# @labels_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
|
||||||
# @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
|
||||||
|
|
||||||
@ -371,13 +371,6 @@ func structure_data(dataset : Array):
|
|||||||
#This function is called from the "old" methods such as plot_from_array and
|
#This function is called from the "old" methods such as plot_from_array and
|
||||||
#for the moment it doesn't clean this variables on clean_variable.
|
#for the moment it doesn't clean this variables on clean_variable.
|
||||||
|
|
||||||
are_values_columns = invert_chart != are_values_columns
|
|
||||||
|
|
||||||
# Read the dataset in the proper way
|
|
||||||
var database : Array = dataset \
|
|
||||||
if not are_values_columns \
|
|
||||||
else MatrixGenerator.transpose(Matrix.new(dataset)).to_array()
|
|
||||||
|
|
||||||
var x_values := []
|
var x_values := []
|
||||||
var y_values := []
|
var y_values := []
|
||||||
x_domain = [[], []]
|
x_domain = [[], []]
|
||||||
|
Loading…
Reference in New Issue
Block a user