pandemonium_engine_easy_charts/addons/easy_charts/LineChart/line_chart.tscn
Nicolò Santilio 1e388f49a0
Scatter (#51)
* Refactor so it works with the new data format.

Restructured some functions in smaller pieces and changed it so they can work with data in the new format.

Main way to use it will be with the new plot_function but old functions support is requiered through structure_datas (WIP)

* structure_datas rework

structure_datas structure the data to match the new format.

* Add new plotting methods

Also renamed identifiers array to the already existing y_labels and a fix to correctly calculate tics.

* Add autoscale or user-defined range

* Add color definition from plot_function call

Introduction of a param_dic parameter on plot_function that allows for specific parameters definitions for that curve only without changing the full Chart.

Also moved the label identier string to a parameter on this dicionary so it can be called without specifying a label name.

* Fix representation of negative values

Using negative numbers should now work on both axis. For this I created two new methods calcualte_interval_tics and calculate_number_integer_digits to avoid code repetition.

I'd like to work more on this, since now the representation is correct but can look very weird for some values with a lot of empty space on the chart.

* Correctly calculates tics for numbers between 0 and 1

Also some small fixes to update_function and delete_function. Changed the tic little line to point outside the chart instead of inside so it doesn't overlap with the grid line.

* Correctly (almost) center axis labels

Needs a little of research for the vertical centering since get_string_size doesn't behave as expected.

* Add some style representation customization

Width of the grid and function lines.

Made drawing points for LineChart optional (especially useful when using a huge number of points to avoid overclustering). For this I had to rewrite the draw_lines function to work similar to draw_points using point_positions instead of information of the point nodes.

The string position of the labels is correctly calculated now. It uses a new variable: label_displacement so it don't look too close to the axis and the border.

Set some default values  that make more sense to the instanciable scenes.

* Fix clearing of data structures with multiple calls to plot_from_x

* Fix show_x_values_as_labels

Correctly sets the x position when show_x_values_as_labels is active.

* Fix show_x_values_as_labels when the label is a String

Co-authored-by: Jorge <63685920+JFerrerBeired@users.noreply.github.com>
2021-08-09 20:09:49 +02:00

96 lines
3.1 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[gd_scene load_steps=4 format=2]
[ext_resource path="res://addons/easy_charts/Utilities/Point/point_data.tscn" type="PackedScene" id=1]
[ext_resource path="res://addons/easy_charts/LineChart/line_chart.gd" type="Script" id=4]
[sub_resource type="Theme" id=1]
[node name="LineChart" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
rect_min_size = Vector2( 70, 50 )
mouse_filter = 2
script = ExtResource( 4 )
__meta__ = {
"_edit_use_anchors_": false,
"_editor_description_": "[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
displays information as a series of data points called 'markers'
connected by straight line segments.
It is a basic type of chart common in many fields. It is similar to a scatter plot
except that the measurement points are ordered (typically by their x-axis value)
and joined with straight line segments.
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."
}
Chart_Properties/are_values_columns = false
Chart_Properties/labels_index = 0
Chart_Properties/show_x_values_as_labels = false
Chart_Display/autoscale_x = true
Chart_Display/x_decim = 1.0
Chart_Display/autoscale_y = true
Chart_Display/y_decim = 1.0
Chart_Style/points_shape = [ ]
Chart_Style/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 )
Chart_Style/function_line_width = 2
Chart_Style/box_color = Color( 0.117647, 0.117647, 0.117647, 1 )
Chart_Style/grid_lines_width = 1
Chart_Style/v_lines_color = Color( 0.792157, 0.792157, 0.792157, 1 )
Chart_Style/h_lines_color = Color( 0.792157, 0.792157, 0.792157, 1 )
Chart_Style/font = null
Chart_Style/bold_font = null
Chart_Style/font_color = Color( 0.117647, 0.117647, 0.117647, 1 )
Chart_Style/use_template = true
Chart_Style/template = 0
Chart_Modifiers/treshold = Vector2( 0, 0 )
Chart_Modifiers/only_disp_values = Vector2( 0, 0 )
Chart_Modifiers/invert_chart = false
Chart_Display/show_points = true
[node name="Background" type="ColorRect" parent="."]
visible = false
show_behind_parent = true
anchor_right = 1.0
anchor_bottom = 1.0
color = Color( 0.882353, 0.882353, 0.882353, 1 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="ChartName" type="Label" parent="."]
anchor_right = 1.0
margin_bottom = 14.0
align = 1
valign = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Points" type="Control" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Legend" type="HBoxContainer" parent="."]
visible = false
margin_right = 1024.0
margin_bottom = 64.0
alignment = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="PointData" parent="." instance=ExtResource( 1 )]
[node name="PointData" parent="PointData" index="0"]
margin_left = -458.75
margin_top = -164.504
margin_right = -458.886
margin_bottom = -163.704
theme = SubResource( 1 )
[editable path="PointData"]