class RatatuiRuby::Widgets::Chart
Plots data points on a Cartesian coordinate system.
Trends and patterns are invisible in raw logs. You need to see the shape of the data to understand the story it tells.
This widget plots X/Y coordinates. It supports multiple datasets, custom axes, and different marker types.
Use it for analytics, scientific data, or monitoring metrics over time.
Example
Run the interactive demo from the terminal:
ruby examples/widget_chart/app.rb
Attributes
Optional wrapping block.
Array of Dataset objects to plot.
Position of the legend.
Corners: :top_left, :top_right, :bottom_left, :bottom_right. Edges: :top, :bottom, :left, :right.
Base style for the chart area.
Configuration for the X Axis.
Configuration for the Y Axis.
Public Class Methods
Source
# File lib/ratatui_ruby/widgets/chart.rb, line 167 def initialize(datasets:, x_axis:, y_axis:, block: nil, style: nil, legend_position: nil, hidden_legend_constraints: []) super end
Creates a new Chart widget.
- datasets
-
Array of Datasets.
x_axis-
X
Axisconfig. y_axis-
Y
Axisconfig. - block
-
Wrapper (optional).
- style
-
Base style (optional).
legend_position-
Symbol — corners:
:top_left,:top_right,:bottom_left,:bottom_right; edges::top,:bottom,:left,:right. hidden_legend_constraints-
Array of two Constraints [width, height] (optional).
