fenix-hub / godot-engine.easy-charts

A Godot Engine addon for plotting general purpose charts. A collection of Control, 2D and 3D Nodes to plot every chart possible.
MIT License
647 stars 48 forks source link

[FEATURE] (Documentation) Having Real Difficulty Getting Started #99

Open chaojian-zhang opened 9 months ago

chaojian-zhang commented 9 months ago

Describe the solution you'd like Thanks for the library! The functionalities seems promising and the examples are cool but I have difficulty setting things up from scratch. In below I am referring to Godot 4.2

Describe an implementation suggestion From the Wiki page https://github.com/fenix-hub/godot-engine.easy-charts/wiki/Static-and-Dynamic-data-plotting-with-PieChart it mentioned two functions plot_from_csv() and plot_from_array() - but none of those exist in the current code base at all. Can you please update the wiki with a very basic Getting Started - in an empty Godot project, how does one add and make use of your library, e.g. to draw a simple line chart? Thanks!

Additional context

chaojian-zhang commented 9 months ago

In the meantime, I figured out a simple setup by utilizing examples, though as examples uses a "control" scene (aka. res://addons/easy_charts/control_charts/), I am not sure whether it's the most efficient way to utilize this addon:

  1. Create empty project
  2. Use Asset Lib to download Easy Chart
  3. Duplicate one of the examples to serve as main file
  4. Essentially in a scene we just need to reference res://addons/easy_charts/control_charts/chart.tscn as a node/control
  5. Then in the script we just do the follow for setting up the intended plot
extends Control

@onready var chart: Chart = $VBoxContainer/Chart

func _ready():
    # Y values can be n-size array of arrays.
    # x.size() == y.size() or`x.size() == y[n].size()
    var x: PackedFloat32Array = ArrayOperations.multiply_float(range(-10, 11, 1), 0.5)
    var y: Array = ArrayOperations.multiply_int(ArrayOperations.cos(x), 20)

    # More like chart properties, which can be distinct from trace properties
    var properties: ChartProperties = ChartProperties.new()
    properties.colors.frame = Color("#161a1d")
    properties.colors.background = Color.TRANSPARENT
    properties.colors.grid = Color("#283442")
    properties.colors.ticks = Color("#283442")
    properties.colors.text = Color.WHITE_SMOKE
    properties.draw_bounding_box = false
    properties.title = "Air Quality Monitoring"
    properties.x_label = "Time"
    properties.y_label = "Sensor values"
    properties.x_scale = 5
    properties.y_scale = 10
    properties.interactive = true # false by default, it allows the chart to create a tooltip to show point values and interecept clicks on the plot

    var options = Function.new( # Function is a weird name for trace options
        x, y, "Pressure", 
        { 
            color = Color("#36a2eb"),
            marker = Function.Marker.CIRCLE,
            type = Function.Type.LINE,
            interpolation = Function.Interpolation.STAIR
        }
    )

    chart.plot([options], properties)

The scene looks like this:

image

The setup is available here: https://github.com/Charles-Zhang-Godot/Sample_Plotting_with_EasyChart/tree/main/templates/line_chart_template

fenix-hub commented 9 months ago

Hi, and welcome. Thank you for your effort! I'm sorry about the lack of documentation. I'm not able to provide one at the moment due to personal business and the fact that this is still a "work in progress" project. So any suggestion is always welcomed. I'll make sure to start recording a couple of videos as a getting started guide.

chaojian-zhang commented 9 months ago

Videos would be helpful! Thanks again for sharing!

fenix-hub commented 9 months ago

you are welcome! thank you.