pandemonium_engine_easy_charts/README.md

167 lines
9.5 KiB
Markdown
Raw Normal View History

2020-08-26 02:48:49 +02:00
*Want to stay updated or having an issue?*
<a href="https://discord.gg/KnJGY9S">
<img src="https://github.com/fenix-hub/ColoredBadges/blob/master/svg/social/discord.svg" alt="react" style="vertical-align:top; margin:6px 4px">
</a>
2020-05-14 02:01:23 +02:00
2020-06-03 11:33:50 +02:00
<img src="addons/easy_charts/icon.png" align="left" width="64" height="64">
2020-05-14 13:49:46 +02:00
# Easy Charts
A library of Charts plotted in Control, 2D and 3D nodes to visualize general purpose datasets.
2020-05-14 02:01:23 +02:00
Author: *"Nicolo (fenix) Santilio"*
2020-11-09 20:14:28 +01:00
Version: *0.4.5*
2020-11-25 14:06:56 +01:00
Wiki: *[wip](https://github.com/fenix-hub/godot-engine.easy-charts/wiki)*
2020-05-14 02:01:23 +02:00
Godot Version: *3.2stable*
## What is this?
2020-05-14 14:37:46 +02:00
*Easy Charts* is a collection of Control, 2D and 3D nodes to plot charts.
2020-05-14 02:01:23 +02:00
This plugin was born from the personal necessity to plot some charts and tables for my university degree project.
Here's an example: ![]()
Charts are really useful when it comes to visually represent values in a powerful and more understandable way, mostly when these charts also have visually pleasing features.
2020-05-14 13:38:21 +02:00
If you need to plot a chart with some values in it and just take a screenshot, or use it in your Godot Engine's game or project, you've come to the right place.
2020-05-14 14:00:12 +02:00
![st](imgs/startup_company2.jpg)
2020-05-14 13:38:21 +02:00
[*Startup Company*](https://store.steampowered.com/app/606800/Startup_Company/)
2020-05-14 14:00:12 +02:00
![wa](imgs/workplace_analytics.png)
2020-05-14 13:38:21 +02:00
[*Microsoft Workplace Analytics*](https://www.microsoft.com/microsoft-365/partners/workplaceanalytics)
2020-05-14 02:01:23 +02:00
## How does it work?
*Easy Charts* contains a collection of nodes for each main node in Godot: Control Nodes, 2D Nodes and 3D Spatials.
To plot a chart you only need to:
1. Save in your project a .CSV file containing the table of values you want to represent, just like the following one:
![example1](imgs/EXCEL_mWtvuI90D0.png)
or, of course, the inverted one:
![example2](imgs/EXCEL_Fa2iiie9qC.png)
2. In Godot, choose a Chart you'd like to plot. For istance, let's take a BarChart2D, specifically used to plot chart in a Node2D. You can instance it as a Child Scene or drag it from the Explorer:
![example3](imgs/scene1.png)
![example4](imgs/scene2.png)
3. Once in the tree, move it around as a normal Node, and set it's values directly in editor, like so:
![example5](imgs/editor_gif.gif)
You can directly select the file you want to plot from the editor, and change its values as you prefer. Most of the features will be displayed in real time in Editor while you are editing them.
4. With just one line of code, you will be able to plot the chart. Use the line of code `$BarChart2D.plot()` to plot the chart with the properties edited in the editor.
![code1](imgs/code.png)
Running the project like this, will produce this chart:
![example6](imgs/chart_gif.gif)
5. Moving the cursor around you will be able to see a floating box with the values contained in the chart:
![example7](imgs/values.gif)
2020-05-14 13:38:21 +02:00
## Chart Tools
Chart Tools are a set of utilities parallel to the plot itself.
![signals](imgs/signals.png)
Available Chart Tools are:
- *Legend Output*: once a chart is plotted, you can get an output legend connecting the right signal, or just using custom functions. A legend is a simple `Array` of custom Control nodes, which contains informations about the chart for each function plotted.
Once plotted, the chart will emit a custom `chart_plotted( chart )` signal. To get the legend, you just can connect this signal, or use the `get_legend` functions afterwards. A `legend` variable can then be used to print out or represent in a full customizable way the legend of functions. For example, these lines of codes:
![code1](imgs/legend_code.png)
![tree1](imgs/tree_legend.png)
You can get this result:
![debug](imgs/debug_legend.png)
![editor2](imgs/editor_legend.png)
- *Point Value*: as you can see, each chart is pretty much interactable, giving you the opportunity to visualize the point represented with hovering it with your mouse. But what if you want to use its values for your own purposes? No problem, with the use of the signal `point_pressed ( point : Point )` you will be able to get all the informations about a point you clicked on in the chart.
![codep](imgs/code_point.png)
![debug1](imgs/debug_point.png)
2020-05-14 14:26:27 +02:00
### Table of features
2020-05-14 14:19:47 +02:00
**Chart**
| Function | Description |
| ------------- | ------------- |
|`plot()`|Plot the selected chart with in editor properties|
2020-11-06 19:48:38 +01:00
|`plot_from_csv(csv_file : String, _delimiter : String = delimiter)`|Plot the selected chart defining the source and delimiter from code|
|`plot_from_array(array : Array)`|Plot the selected chart giving an Array of values as a source|
|`update_plot_data(array : Array)`|Update plot data giving an additional entry to the source|
2020-05-14 14:19:47 +02:00
|`get_legend()`|Get the legend of the current chart. Returns an **Array** containing control nodes, which can be added as children |
2020-11-06 19:48:38 +01:00
|*API v2*|*additional functions to define chart's properties from code. Hardcoded properties will overwrite the ones given from editor*|
|`set_chart_name(ch_name : String)`|Set the displayed name of the chart|
|`set_source(source_file : String)`|Set the source of the chart to plot|
|`set_delimiter(delimiter : String)`|Set the delimiter to read data from a CSV file|
|`set_indexes(lb : int = 0, function_names : int = 0)`|Set the optional indexes of chart's data|
|`set_radius(use_height : bool = false, f : float = 0)`|Set the radius of the chart, if it is required. If `use_height` is true, the height of the chart will be used.|
|`set_chart_colors(f_colors : PoolColorArray, o_color : Color, b_color : Color, g_color : Color, h_lines : Color, v_lines : Color)`|Set the colors of the chart|
|`set_chart_fonts(normal_font : Font, bold_font : Font, f_color : Color = Color.white)`|Set fonts and font's color for the chart|
|`set_source(source_file : String)`|Set the source of the chart to plot|
2020-05-14 14:19:47 +02:00
| Signals | Description |
| ------------- | ------------- |
|`chart_plotted(chart : Node)`|Returns the plotted Chart, which is a Node (Control, 2D Node, 3D Node)|
2020-05-14 14:26:27 +02:00
|`point_pressed(point : Point)`|Returns the point pressed with Left Click, which is a custom class *Point*|
2020-05-14 14:19:47 +02:00
**Legend**
| Function | Description |
| ------------- | ------------- |
|`get_function() -> Array`|Get the function's name, also visible in legend|
2020-05-14 14:26:27 +02:00
|`get_function_color() -> Color`|Get the function's color, also visible in legend|
2020-05-14 14:19:47 +02:00
**Point**
| Function | Description |
| ------------- | ------------- |
|`get_value() -> Array`|Get the point values, which are mapped coordinates in the plot. Returns a 2D array, with [0] and [1] as x and y values|
|`get_function() -> String`|Get the point's function name, also visible in legend and chart|
2020-05-14 14:26:27 +02:00
|`get_color_point() -> Color`|Get the point Color, also visible in legend and chart|
**About templates**
2020-05-14 14:37:46 +02:00
Templates are defined in a .json file, and the format is pretty straight forward.
2020-05-14 14:26:27 +02:00
However, adding custom templates is not yet recommended, since it would require to edit the Charts scripts. Templates are anyway accessible and customizable.
```
/addons/easy_charts/templates.json
"default":
{
"function_colors" : ["#1e1e1e","#1e1e1e","#1e1e1e","#1e1e1e"],
"v_lines_color" : "#cacaca",
"h_lines_color" : "#cacaca",
"outline_color" : "#1e1e1e",
"font_color" : "#1e1e1e"
},
```
2020-05-14 13:38:21 +02:00
# Available Charts and when to use them
2020-05-30 01:42:58 +02:00
This library offers a set of charts for each main Godot Node:
2020-05-14 13:38:21 +02:00
- **Control Nodes:** "Control Charts" are fast Charts that can be plotted in a Control space, such as UIs or Control user interactable areas. They offer basic Control properties, such as Margins, size inheritance and control. No animations, no real time changes, just charts.
- **2D Nodes:** "2D Charts" are a set of Charts which can be Used in 2D spaces. They offer additional tools, such as animations and real time changes in editor. They can be used to implement more aesthetic charts in 2D contexts.
- **[wip] 3D Nodes:** "3D Charts" are a set of Charts which can be Used in both 2D and 3D spaces. They offer the possibility to plot 3D datasets, which are common in machine learning contexts or just data analysis. A Camera Control will also be available, which can be used to move around the chart.
*Available Charts*:
- LineChart [Control, 2D, wip 3D]
- BarChart [Control, 2D, wipr 3D]
- ScatterChart [wip Control, wip 2D, 3D]
2020-11-06 19:48:38 +01:00
- Piechart [Control]
2020-05-26 23:53:44 +02:00
- RadarChart [Control]
2020-05-14 13:38:21 +02:00
*Work in progress*:
- Area Chart
- Donut Chart
- Radar Chart
- Bubble Chart
- Parliament Chart
2020-05-14 13:46:12 +02:00
### Some Examples
2020-11-06 19:55:45 +01:00
![example_Piechart](imgs/pie_chart_realtime.gif)
2020-06-03 18:08:50 +02:00
![exampleradar](imgs/radar.png)
2020-05-20 02:08:41 +02:00
![example01](imgs/scatter.gif)
2020-05-30 01:42:58 +02:00
![example02](imgs/example02.png)
2020-05-14 13:46:12 +02:00
![example03](imgs/example03.gif)
2020-05-14 02:01:23 +02:00
2020-05-14 14:48:09 +02:00
##### Some references for charts and plots
2020-05-14 14:48:59 +02:00
[Flourish](https://app.flourish.studio/projects)
[Chart.js](https://www.chartjs.org/samples/latest/)
[Google Charts](https://developers.google.com/chart)
2020-05-14 14:48:09 +02:00
2020-05-14 02:01:23 +02:00
# Disclaimer
This addon was built for a **personal use** intention. It was released as an open source plugin in the hope that it could be useful to the Godot Engine Community.
As a "work in progress" project, there is *no warranty* for any eventual issue and bug that may broke your project.
I don't assume any responsibility for possible corruptions of your project. It is always advisable to keep a copy of your project and check any changes you make in your Github repository.
-----------------
> This text file was created via [TextEditor Integration](https://github.com/fenix-hub/godot-engine.text-editor) inside Godot Engine's Editor.
2020-05-30 01:42:58 +02:00
> This text file was pushed via [GitHub Integration](https://github.com/fenix-hub/godot-engine.github-integretion) inside Godot Engine's Editor.