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
638 stars 48 forks source link

[FEATURE] custom axis label value also in tooltips #101

Closed jospic closed 4 months ago

jospic commented 5 months ago

Hi, when overwriting axis labels, through the property x_label (or y_labels), it would be useful to update the corresponding value also in the tooltip. Thanks in advance. -j

In the flollow screenshot the x axis labels are a short date format like gg/mm: image

fenix-hub commented 4 months ago

Hi @jospic next release will implement this feature image

A new method has been introduced in order to assign labels on x and y labels. Instead of passing an array (which is independent from your data, resulting in several bugs and more logic to handle in order to synchronize data and labels), now a function can be directly passed to your chart in order to automatically generate labels at runtime, by specifying the format you would like to apply to your values.

ex.

    # Let's give our chart a custom labelling on the X axis, by passing a function
    chart.x_labels_function = func(n: float) -> String: return "%s (s)" % str( log(n / 10) ) 

    # Now let's plot our data
    chart.plot([f1], cp)

your function will be automatically called when drawing labels for your plot. If no function is specified, raw data will be used by default.

jospic commented 4 months ago

Perfect! Thanks