### Create and Render a Streamlinechart with Real-time Updates Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/streamlinechart.md This example demonstrates how to create a streamlinechart, set its style, and continuously push new data while rendering it in a loop. It requires the 'ntcharts' gem to be installed. ```ruby require "ntcharts" chart = Ntcharts::Streamlinechart.new(60, 12) chart.style = Ntcharts::Style.new.foreground("#00D4FF") loop do value = Math.sin(Time.now.to_f) * 4 + 5 chart.push(value) system("clear") puts chart.render sleep 0.1 end ``` -------------------------------- ### Install Ruby Dependencies Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/README.md Installs the necessary Ruby gems for the project. Ensure you have Ruby 3.2+ installed. ```bash bundle install ``` -------------------------------- ### Linechart Range Configuration Examples Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/errors.md Illustrates the two valid ways to initialize a Linechart: auto-ranging and fixed-ranging. ```ruby # Auto-ranging (calculates bounds automatically) auto_chart = Ntcharts::Linechart.new(50, 12) # Fixed-ranging (specify bounds explicitly) fixed_chart = Ntcharts::Linechart.new(50, 12, -10.0, 10.0, -5.0, 5.0) ``` -------------------------------- ### Linechart Example Configuration Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/configuration.md Configure a Linechart with fixed ranges, X and Y axis step intervals, and line style. ```ruby chart = Ntcharts::Linechart.new(50, 12, 0.0, 10.0, -5.0, 5.0) chart.x_step = 2 chart.y_step = 5 chart.style = Ntcharts::Style.new.foreground("#00FF00") ``` -------------------------------- ### Install ntcharts Gem Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/README.md Add the ntcharts gem to your Gemfile or install it directly using the gem command. ```ruby gem "ntcharts" ``` ```bash gem install ntcharts ``` -------------------------------- ### Barchart Example Configuration Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/configuration.md Configure a Barchart for horizontal orientation, bar width, gap, axis display, maximum value, and style. ```ruby chart = Ntcharts::Barchart.new(50, 12) chart.horizontal = true chart.bar_width = 3 chart.bar_gap = 1 chart.show_axis = true chart.max = 200.0 red = Ntcharts::Style.new.foreground("#FF0000") chart.style = red ``` -------------------------------- ### Sparkline Chart Example Configuration Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/configuration.md Configure a Sparkline chart's style, maximum value, and auto-max value scaling. ```ruby chart = Ntcharts::Sparkline.new(40, 6) chart.style = Ntcharts::Style.new.foreground("#FF6B6B") chart.max = 100.0 chart.auto_max_value = false ``` -------------------------------- ### Graceful Style Conversion Handling Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/errors.md An example of handling ArgumentErrors during style conversion and applying a default style as a fallback. ```ruby def apply_style(chart, style) begin chart.style = Ntcharts.convert_style(style) rescue ArgumentError => e # Fallback to default style chart.style = Ntcharts::Style.new warn "Failed to apply custom style: #{e.message}" end end ``` -------------------------------- ### to_s() Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/linechart.md An alias for the `view()` method, providing an alternative way to get the rendered line chart as a string. ```APIDOC ## to_s() ### Description Alias for `view()`. Returns the rendered line chart as a string. ### Method Ruby ### Parameters None ### Returns `String` — The rendered chart as a terminal string ### Source `ext/ntcharts/linechart.c:288-290` ``` -------------------------------- ### to_s Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/barchart.md An alias for the `view()` method, providing an alternative way to get the rendered bar chart as a string. ```APIDOC ## to_s ### Description Alias for `view()`. Returns the rendered bar chart as a string. ### Signature ```ruby def to_s ``` ### Returns `String` - The rendered chart as a terminal string ``` -------------------------------- ### Create BarData with styled segments Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/types.md Initializes a BarData object representing a bar with multiple styled value segments. This example demonstrates using Hashes with style objects for initialization. ```ruby red = Ntcharts::Style.new.foreground("#FF0000") green = Ntcharts::Style.new.foreground("#00FF00") bar = Ntcharts::BarData.new( label: "Q1", values: [ { name: "Sales", value: 50, style: red }, { name: "Costs", value: 30, style: green } ] ) chart.push(bar) ``` -------------------------------- ### Recovering from Invalid Style Conversion Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/errors.md Provides an example of how to handle ArgumentErrors during style conversion and fall back to a default style. ```ruby style = Ntcharts::Style.new.foreground("#FF0000") converted = Ntcharts.convert_style(style) # returns style unchanged # Or use a valid Lipgloss::Style require "lipgloss" lipgloss_style = Lipgloss::Style.new.foreground("#FF0000") converted = Ntcharts.convert_style(lipgloss_style) ``` -------------------------------- ### Add Data Points to a Streamlinechart Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/streamlinechart.md This example shows how to create a streamlinechart and continuously add random data points to it within a loop, rendering the chart after each addition. Ensure the 'ntcharts' gem is required. ```ruby chart = Ntcharts::Streamlinechart.new(60, 12) loop do value = rand(0..100) chart.push(value) puts chart.render sleep 0.5 end ``` -------------------------------- ### Render all datasets and get view Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/wavelinechart.md Renders all plotted datasets, including the default one, and returns the chart as a string. Use this when you need to display multiple series. ```ruby chart = Ntcharts::Wavelinechart.new(60, 15) (0..40).each do |i| chart.plot_data_set("series_a", i.to_f, Math.cos(i * 0.15) * 4 + 5) chart.plot_data_set("series_b", i.to_f, Math.sin(i * 0.1) * 3 + 5) end chart.draw_all puts chart.view ``` -------------------------------- ### Set Fixed Y-axis Range for Streamlinechart Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/streamlinechart.md This example shows how to initialize a streamlinechart and then set a fixed minimum and maximum value for the Y-axis using `set_y_range`. This ensures consistent scaling. ```ruby chart = Ntcharts::Streamlinechart.new(60, 12) chart.set_y_range(0.0, 100.0) ``` -------------------------------- ### Define Line Style Constants Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/README.md Provides examples of accessing predefined line style constants available for various line chart types. These constants represent different character sets for drawing lines. ```ruby Ntcharts::Linechart::LINE_STYLE_THIN # Box-drawing characters (value: 0) Ntcharts::Linechart::LINE_STYLE_ARC # Curved arc characters (value: 1) ``` -------------------------------- ### Clear All Data from a Streamlinechart Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/streamlinechart.md This example illustrates how to create a streamlinechart, add data, and then completely clear all existing data points using the `clear_data` method. The 'ntcharts' gem is required. ```ruby chart = Ntcharts::Streamlinechart.new(60, 12) chart.push(50) chart.clear_data ``` -------------------------------- ### Get Ntcharts Gem and Upstream Version Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/module.md Retrieves the version information for both the ntcharts gem and the upstream Go library. This is useful for debugging and ensuring compatibility. ```ruby puts Ntcharts.version # Output: ntcharts v0.1.2 (upstream 0.3.1) [Go native extension] ``` -------------------------------- ### Get Upstream Ntcharts Go Library Version Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/module.md Retrieves the specific version string of the underlying NimbleMarkets ntcharts Go library. This is helpful for checking the exact version of the native component being used. ```ruby puts Ntcharts.upstream_version # Output: 0.3.1 ``` -------------------------------- ### Get Sparkline View as String Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/sparkline.md Retrieves the rendered sparkline as a string, including ANSI formatting. This is useful for printing or logging the chart. ```ruby chart = Ntcharts::Sparkline.new(40, 6) [1, 4, 2, 7, 3, 9, 5].each { |v| chart.push(v) } chart.draw output = chart.view puts output ``` -------------------------------- ### Get Barchart View Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/barchart.md Returns the rendered bar chart as a string, formatted with ANSI escape codes for terminal display. Call after `draw()`. ```ruby chart = Ntcharts::Barchart.new(50, 12) chart.push(label: "Go", values: [{ value: 85 }]) chart.draw output = chart.view puts output ``` -------------------------------- ### Get TimeseriesLineChart Height Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/timeserieslinechart.md Retrieves the current height of the chart in terminal rows. ```ruby def height() ``` ``` -------------------------------- ### Create and Configure Style Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/style.md Demonstrates creating a new style object and applying foreground, background, and bold formatting. This style can then be assigned to a chart. ```ruby require "ntcharts" style = Ntcharts::Style.new style = style.foreground("#FF0000") style = style.background("#000000") style = style.bold(true) chart = Ntcharts::Sparkline.new(40, 6) chart.style = style ``` -------------------------------- ### Get TimeseriesLineChart Width Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/timeserieslinechart.md Retrieves the current width of the chart in terminal columns. ```ruby def width() ``` ``` -------------------------------- ### Get Maximum X-Axis Value Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/linechart.md Returns the maximum value displayed on the X-axis. ```ruby def max_x() end ``` -------------------------------- ### Run Streaming Demo Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/README.md Executes the streaming demo, likely showcasing dynamic chart updates. ```bash ./demo/streaming ``` -------------------------------- ### Get Minimum X-Axis Value Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/linechart.md Returns the minimum value displayed on the X-axis. ```ruby def min_x() end ``` -------------------------------- ### Initialize Wavelinechart Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/configuration.md Create a new Wavelinechart instance with specified width and height. ```ruby chart = Ntcharts::Wavelinechart.new(width, height) ``` -------------------------------- ### Get StreamlineChart Height Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/streamlinechart.md Returns the current height of the chart in terminal rows. ```ruby def height() end ``` -------------------------------- ### Run Linechart Demo Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/README.md Executes the demo for the Linechart chart type. ```bash ./demo/linechart ``` -------------------------------- ### Create and Render a Barchart Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/README.md Instantiate a Barchart and push data with labels and styles. The chart is rendered using `chart.render`. ```ruby chart = Ntcharts::Barchart.new(50, 12) chart.push(label: "Go", values: [{ value: 85, style: style }]) chart.push(label: "Ruby", values: [{ value: 92, style: style }]) chart.push(label: "Python", values: [{ value: 78, style: style }]) puts chart.render ``` -------------------------------- ### Get StreamlineChart Width Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/streamlinechart.md Returns the current width of the chart in terminal columns. ```ruby def width() end ``` -------------------------------- ### Run Wavelinechart Demo Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/README.md Executes the demo for the Wavelinechart chart type. ```bash ./demo/wavelinechart ``` -------------------------------- ### Get Maximum Y-axis Value Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/timeserieslinechart.md Retrieves the maximum numerical value plotted on the Y-axis. ```ruby def max_y() ``` ``` -------------------------------- ### Build Go Library and Compile Ruby Extension Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/README.md Builds the Go backend library and compiles the Ruby extension. Requires Go 1.23+. ```bash bundle exec rake go:build bundle exec rake compile ``` -------------------------------- ### Get Minimum Y-axis Value Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/timeserieslinechart.md Retrieves the minimum numerical value plotted on the Y-axis. ```ruby def min_y() ``` ``` -------------------------------- ### Run Barchart Demo Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/README.md Executes the demo for the Barchart chart type. ```bash ./demo/barchart ``` -------------------------------- ### Get Sparkline Height Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/sparkline.md Retrieves the current height of the sparkline in rows. This is a read-only property. ```ruby def height end ``` -------------------------------- ### Get Sparkline Width Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/sparkline.md Retrieves the current width of the sparkline in columns. This is a read-only property. ```ruby def width end ``` -------------------------------- ### Get StreamlineChart Maximum Y Value Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/streamlinechart.md Returns the maximum value on the Y-axis that the chart is configured to display. ```ruby def max_y() end ``` -------------------------------- ### Get StreamlineChart Minimum Y Value Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/streamlinechart.md Returns the minimum value on the Y-axis that the chart is configured to display. ```ruby def min_y() end ``` -------------------------------- ### Initialize Timeserieslinechart Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/configuration.md Create a Timeserieslinechart instance specifying width and height. ```ruby chart = Ntcharts::Timeserieslinechart.new(width, height) ``` -------------------------------- ### Chained Style Configuration Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/style.md Demonstrates fluent method chaining to configure foreground, background, and bold attributes on a Style object. ```ruby style = Ntcharts::Style.new .foreground("#FF6B6B") .background("#1E1E1E") .bold(true) # Can also be written as: style = Ntcharts::Style.new style = style.foreground("#FF6B6B") style = style.background("#1E1E1E") style = style.bold(true) ``` -------------------------------- ### Get Visible Maximum Y Value Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/linechart.md Returns the maximum Y value currently visible in the chart's viewport. ```ruby def view_max_y() end ``` -------------------------------- ### Run Sparkline Demo Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/README.md Executes the demo for the Sparkline chart type. ```bash ./demo/sparkline ``` -------------------------------- ### Get Visible Minimum Y Value Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/linechart.md Returns the minimum Y value currently visible in the chart's viewport. ```ruby def view_min_y() end ``` -------------------------------- ### Initialize Ntcharts::Barchart Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/barchart.md Creates a new bar chart instance with specified dimensions. Requires the 'ntcharts' gem. ```ruby require "ntcharts" chart = Ntcharts::Barchart.new(50, 12) chart.push(label: "Go", values: [{ value: 85 }]) chart.push(label: "Ruby", values: [{ value: 92 }]) chart.draw puts chart.view ``` -------------------------------- ### Create Linechart with Optional Bounds Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/README.md Demonstrates how to initialize a Linechart, optionally specifying the minimum and maximum values for the X and Y axes for fixed ranging, in addition to the required dimensions. ```ruby # Auto-ranging chart = Ntcharts::Linechart.new(50, 12) # Fixed-ranging chart = Ntcharts::Linechart.new(50, 12, min_x, max_x, min_y, max_y) ``` -------------------------------- ### Get StreamlineChart Graph Height Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/streamlinechart.md Returns the height available specifically for plotting data within the chart. ```ruby def graph_height() end ``` -------------------------------- ### Run Streamlinechart Demo Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/README.md Executes the demo for the Streamlinechart chart type. ```bash ./demo/streamlinechart ``` -------------------------------- ### Get StreamlineChart Graph Width Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/streamlinechart.md Returns the width available specifically for plotting data within the chart. ```ruby def graph_width() end ``` -------------------------------- ### Style.new() Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/style.md Creates a new style object with default (no styling) settings. This is the entry point for creating a style configuration. ```APIDOC ## Style.new() ### Description Creates a new style object with default (no styling) settings. ### Method `initialize` ### Parameters None ### Returns `Ntcharts::Style` — A new, unstyled style instance ### Example ```ruby require "ntcharts" style = Ntcharts::Style.new style = style.foreground("#FF0000") style = style.background("#000000") style = style.bold(true) chart = Ntcharts::Sparkline.new(40, 6) chart.style = style ``` ``` -------------------------------- ### Run TimeSeriesLineChart Demo Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/README.md Executes the demo for the TimeSeriesLineChart chart type. ```bash ./demo/timeserieslinechart ``` -------------------------------- ### Create bars using Hash shorthand Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/types.md Shows how to push bar data directly as Hashes to a Barchart instance, simplifying the creation of bars without explicit BarData objects. ```ruby chart = Ntcharts::Barchart.new(50, 12) # Direct Hash creation chart.push(label: "A", values: [{ value: 50 }]) chart.push(label: "B", values: [{ value: 75 }]) ``` -------------------------------- ### Get Maximum X-axis Value Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/timeserieslinechart.md Retrieves the latest timestamp present in the chart data as a Ruby Time object. ```ruby def max_x ``` ``` -------------------------------- ### Initialize Ntcharts::Linechart Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/linechart.md Creates a new line chart instance. Use the 2-argument constructor for auto-ranging or the 6-argument constructor for fixed-range mode. ```ruby require "ntcharts" # Auto-range mode chart1 = Ntcharts::Linechart.new(50, 12) # Fixed-range mode with explicit bounds chart2 = Ntcharts::Linechart.new(50, 12, 0.0, 10.0, 0.0, 10.0) chart2.draw_axes puts chart2.view ``` -------------------------------- ### Get Minimum X-axis Value Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/timeserieslinechart.md Retrieves the earliest timestamp present in the chart data as a Ruby Time object. ```ruby def min_x ``` ``` -------------------------------- ### Get Y-Axis Step Interval Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/linechart.md Returns the interval for Y-axis labels. A value of 0 indicates that labels are hidden. ```ruby def y_step() end ``` -------------------------------- ### Initialize Streamlinechart Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/configuration.md Instantiate a Streamlinechart with the given width and height. ```ruby chart = Ntcharts::Streamlinechart.new(width, height) ``` -------------------------------- ### Draw Axes and Render Chart Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/linechart.md Initializes a line chart, draws a rune, then draws the axes and renders the chart view. Use this to visualize data points and axes. ```ruby chart = Ntcharts::Linechart.new(50, 12, 0.0, 10.0, 0.0, 10.0) chart.draw_rune(5.0, 5.0, "*") chart.draw_axes puts chart.view ``` -------------------------------- ### Get X-Axis Step Interval Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/linechart.md Returns the interval for X-axis labels. A value of 0 indicates that labels are hidden. ```ruby def x_step() end ``` -------------------------------- ### Get Sparkline Scale Factor Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/sparkline.md Retrieves the current scale factor used for rendering the sparkline. This is a read-only property. ```ruby def scale end ``` -------------------------------- ### Create and Populate Sparkline Chart Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/README.md Demonstrates the basic creation of a Sparkline chart and pushing numeric values to it. Requires the 'ntcharts' gem. ```ruby require "ntcharts" chart = Ntcharts::Sparkline.new(40, 6) [1, 4, 2, 7, 3, 9, 5].each { |v| chart.push(v) } chart.draw puts chart.view ``` -------------------------------- ### Get Sparkline Max Value Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/sparkline.md Retrieves the maximum value currently configured for scaling the sparkline. This is a read-only property. ```ruby def max_value end ``` -------------------------------- ### Create and Draw a TimeSeriesLineChart Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/README.md Instantiate a TimeSeriesLinechart and push time-value pairs. The chart uses time-based X-axis labels and braille rendering. ```ruby chart = Ntcharts::Timeserieslinechart.new(70, 15) now = Time.now (0..60).each do |i| time = now - (60 - i) * 60 value = Math.sin(i * 0.1) * 10 + 50 chart.push(time, value) end chart.draw_braille puts chart.view ``` -------------------------------- ### Create and Draw a Sparkline Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/README.md Instantiate a Sparkline, push data points, and draw it. The view can be accessed via `chart.view`. ```ruby require "ntcharts" chart = Ntcharts::Sparkline.new(40, 6) [1, 4, 2, 7, 3, 9, 5, 8, 2, 6].each { |v| chart.push(v) } chart.draw puts chart.view ``` -------------------------------- ### Get TimeseriesLineChart Graph Height Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/timeserieslinechart.md Retrieves the height available specifically for plotting the graph data, excluding labels and axes. ```ruby def graph_height() ``` ``` -------------------------------- ### Get TimeseriesLineChart Graph Width Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/timeserieslinechart.md Retrieves the width available specifically for plotting the graph data, excluding labels and axes. ```ruby def graph_width() ``` ``` -------------------------------- ### Wavelinechart.new Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/wavelinechart.md Creates a new wavelinechart with specified dimensions. The chart is initialized with a given width and height in terminal columns and rows, respectively. ```APIDOC ## Wavelinechart.new ### Description Creates a new wavelinechart with specified dimensions. ### Method `initialize(width, height)` ### Parameters #### Path Parameters - **width** (Integer) - Required - Width of chart in terminal columns - **height** (Integer) - Required - Height of chart in terminal rows ### Returns `Ntcharts::Wavelinechart` - A new wavelinechart instance ### Example ```ruby require "ntcharts" chart = Ntcharts::Wavelinechart.new(60, 15) # Plot default dataset (0..40).each { |i| chart.plot(i.to_f, Math.sin(i * 0.15) * 5 + 5) } chart.draw_all puts chart.view ``` ``` -------------------------------- ### Get Visible Maximum X Value Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/linechart.md Returns the maximum X value currently visible in the chart's viewport. ```ruby def view_max_x() end ``` -------------------------------- ### Barchart Constructor Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/configuration.md Instantiate a Barchart with specified width and height. ```ruby chart = Ntcharts::Barchart.new(width, height) ``` -------------------------------- ### Get Visible Minimum X Value Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/linechart.md Returns the minimum X value currently visible in the chart's viewport. ```ruby def view_min_x() end ``` -------------------------------- ### Create and Render a Scrolling StreamLineChart Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/README.md Instantiate a Streamlinechart, apply styling, and push values within a loop to create a real-time scrolling effect. Clears the screen before rendering each frame. ```ruby chart = Ntcharts::Streamlinechart.new(60, 12) chart.style = Lipgloss::Style.new.foreground("#00D4FF") loop do value = Math.sin(Time.now.to_f) * 4 + 5 chart.push(value) system("clear") puts chart.render sleep 0.1 end ``` -------------------------------- ### view() Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/linechart.md Returns the rendered line chart as a string, including ANSI formatting for terminal display. This is the primary method for outputting the chart. ```APIDOC ## view() ### Description Returns the rendered line chart as a string. ### Method Ruby ### Parameters None ### Returns `String` — The rendered chart as a terminal string (ANSI-formatted) ### Source `ext/ntcharts/linechart.c:280-286` ``` -------------------------------- ### Plot Multiple Datasets on WavelineChart Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/README.md Instantiate a Wavelinechart and plot multiple named datasets using `plot_data_set`. All datasets are drawn with `draw_all`. ```ruby chart = Ntcharts::Wavelinechart.new(60, 15) (0..40).each { |i| chart.plot(i.to_f, Math.sin(i * 0.15) * 5 + 5) } (0..40).each do |i| chart.plot_data_set("series_a", i.to_f, Math.cos(i * 0.15) * 4 + 5) chart.plot_data_set("series_b", i.to_f, Math.sin(i * 0.1) * 3 + 5) end chart.draw_all puts chart.view ``` -------------------------------- ### Create Chart with Required Dimensions Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/README.md Illustrates the mandatory step of initializing any Ntcharts chart with specific width and height values, representing terminal columns and rows respectively. ```ruby chart = Ntcharts::SomeChart.new(width, height) ``` -------------------------------- ### Rendering Chart Output Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/README.md Methods to render charts and retrieve their output. `draw` renders, `view` returns a string, and `render` combines both. `draw_all`, `render_all`, `draw_braille`, and `render_braille` offer variations for multiple datasets and braille output. ```ruby # All charts support: # draw() — Render the chart (returns self) # view() — Get rendered output as string # render() — Combined: draw() + view() # to_s() — Alias for view() # For multi-dataset charts: # draw_all() — Render all datasets # render_all() — Combined: draw_all() + view() # For braille rendering: # draw_braille() — Render with smooth braille dots # render_braille() — Combined: draw_braille() + view() ``` -------------------------------- ### Create and Draw a Styled Sparkline with Lipgloss Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/README.md Apply a Lipgloss style to a Sparkline before pushing data and drawing. Supports `Lipgloss::Style` or `Ntcharts::Style`. ```ruby require "lipgloss" style = Lipgloss::Style.new.foreground("#FF6B6B") chart = Ntcharts::Sparkline.new(40, 6) chart.style = style # Accepts Lipgloss::Style or Ntcharts::Style [5, 3, 7, 2, 9, 4, 6, 1, 8, 3].each { |v| chart.push(v) } chart.draw_braille puts chart.view ``` -------------------------------- ### Linechart Constructor (Auto-Range) Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/configuration.md Instantiate a Linechart with specified width and height, allowing auto-calculated axis ranges. ```ruby chart = Ntcharts::Linechart.new(width, height) ``` -------------------------------- ### Render Streamlinechart Output to String Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/streamlinechart.md This snippet demonstrates how to create a streamlinechart, push a single data point, and then retrieve the rendered chart as a string using the `render` method. The 'ntcharts' gem must be required. ```ruby chart = Ntcharts::Streamlinechart.new(60, 12) chart.push(50) puts chart.render ``` -------------------------------- ### Configure Wavelinechart Styles Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/configuration.md Set default and specific dataset styles for a Wavelinechart. Requires Ntcharts::Style or Lipgloss::Style objects for colors and predefined line styles. ```ruby chart = Ntcharts::Wavelinechart.new(60, 15) chart.set_y_range(0.0, 100.0) red = Ntcharts::Style.new.foreground("#FF0000") blue = Ntcharts::Style.new.foreground("#0000FF") chart.set_styles(Ntcharts::Wavelinechart::LINE_STYLE_THIN, red) chart.set_data_set_styles("series_b", Ntcharts::Wavelinechart::LINE_STYLE_ARC, blue) ``` -------------------------------- ### Linechart Constructor (Fixed-Range) Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/configuration.md Instantiate a Linechart with specified width, height, and fixed X and Y axis ranges. ```ruby chart = Ntcharts::Linechart.new(width, height, min_x, max_x, min_y, max_y) ``` -------------------------------- ### Render and Retrieve Chart Output Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/README.md Illustrates the process of rendering a chart to the terminal and obtaining its string representation. The 'draw' method renders the chart, and 'view' retrieves the output. ```ruby chart.draw # Render the chart output = chart.view # Get rendered output as string puts output # Display in terminal ``` -------------------------------- ### Sparkline Chart Constructor Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/configuration.md Instantiate a Sparkline chart with specified width and height. ```ruby chart = Ntcharts::Sparkline.new(width, height) ``` -------------------------------- ### Linechart Constructor Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/linechart.md Initializes a new line chart. It can be created in auto-range mode with width and height, or in fixed-range mode with explicit minimum and maximum values for both X and Y axes. ```APIDOC ## Linechart.new ### Description Creates a new line chart. Can be initialized in auto-range mode (2 args) or fixed-range mode (6 args). ### Signature ```ruby def initialize(*args) ``` ### Parameters #### Path Parameters - **width** (Integer) - Required - Width of chart in terminal columns - **height** (Integer) - Required - Height of chart in terminal rows - **min_x** (Float) - Optional - Minimum X-axis value (default: 0.0) - **max_x** (Float) - Optional - Maximum X-axis value (default: 10.0) - **min_y** (Float) - Optional - Minimum Y-axis value (default: 0.0) - **max_y** (Float) - Optional - Maximum Y-axis value (default: 10.0) ### Returns `Ntcharts::Linechart` — A new linechart instance ### Raises - **ArgumentError**: If given 2 or 6 arguments, any other count raises an error. ### Example ```ruby # Auto-range mode chart1 = Ntcharts::Linechart.new(50, 12) # Fixed-range mode with explicit bounds chart2 = Ntcharts::Linechart.new(50, 12, 0.0, 10.0, 0.0, 10.0) chart2.draw_rune(2.5, 5.0, "*") chart2.draw_axes puts chart2.view ``` ``` -------------------------------- ### Create and Populate Timeserieslinechart Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/timeserieslinechart.md Initializes a new Timeserieslinechart and populates it with data points using Ruby Time objects. This is useful for displaying historical data over a specific period. ```ruby require "ntcharts" chart = Ntcharts::Timeserieslinechart.new(70, 15) now = Time.now (0..60).each do |i| time = now - (60 - i) * 60 value = Math.sin(i * 0.1) * 10 + 50 chart.push(time, value) end chart.draw_braille puts chart.view ``` -------------------------------- ### Push Bar Data using Hash or Object Form Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/README.md Demonstrates two ways to push data to a chart that accepts BarData: using a Hash literal or an Ntcharts::BarData object instance. Both methods achieve the same result. ```ruby # Hash form chart.push(label: "Q1", values: [{ value: 100 }]) # Object form chart.push(Ntcharts::BarData.new(label: "Q1", values: [{ value: 100 }])) ``` -------------------------------- ### Build Bar Data Programmatically Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/types.md Construct a bar's data by adding individual values with names and styles. This method allows for more granular control over bar composition. ```ruby bar = Ntcharts::BarData.new(label: "Monthly Sales") Ntcharts::Style.new.foreground("#00FF00") .tap { |style| bar.add_value(name: "Online", value: 150, style: style) } Ntcharts::Style.new.foreground("#0000FF") .tap { |style| bar.add_value(name: "Retail", value: 120, style: style) } chart.push(bar) ``` -------------------------------- ### Integrate Lipgloss Styles with Ntcharts Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/README.md Shows how to use styles defined with the Lipgloss gem directly with Ntcharts charts. Ntcharts automatically converts compatible Lipgloss styles, or an explicit conversion can be performed. ```ruby require "lipgloss" lipgloss_style = Lipgloss::Style.new.foreground("#FF6B6B") chart.style = lipgloss_style # Automatically converted # Or explicit conversion ntcharts_style = Ntcharts.convert_style(lipgloss_style) ``` -------------------------------- ### Enable Bold Formatting Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/style.md Applies bold formatting to a new Style object. Pass `true` to enable and `false` to disable. ```ruby style = Ntcharts::Style.new .foreground("#FF0000") .bold(true) chart = Ntcharts::Sparkline.new(40, 6) chart.style = style ``` -------------------------------- ### Draw Runes on a LineChart Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/README.md Instantiate a Linechart with specified dimensions and coordinate ranges. Draw individual points using `draw_rune` and display axes. ```ruby chart = Ntcharts::Linechart.new(50, 12, 0.0, 10.0, 0.0, 10.0) (0..10).each do |i| x = i.to_f y = Math.sin(i * 0.5) * 4 + 5 chart.draw_rune(x, y, "*") end chart.draw_axes puts chart.view ``` -------------------------------- ### render_all Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/wavelinechart.md A convenience method that first calls `draw_all()` to render all datasets and then returns the rendered output as a string. ```APIDOC ## render_all ### Description Convenience method that calls `draw_all()` and returns the rendered output. ### Method `render_all` ### Parameters: None ### Returns `String` - The rendered chart as a terminal string ``` -------------------------------- ### Catching Ntcharts::Error Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/errors.md Demonstrates how to rescue custom Ntcharts errors using a begin-rescue block. ```ruby begin # ntcharts operations rescue Ntcharts::Error => e puts "Ntcharts error: #{e.message}" end ``` -------------------------------- ### Render Barchart to String Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/barchart.md A convenience method that combines drawing and viewing the chart into a single call, returning the rendered string. ```ruby chart = Ntcharts::Barchart.new(50, 12) chart.push(label: "A", values: [{ value: 50 }]) puts chart.render ``` -------------------------------- ### Streamlinechart.new Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/streamlinechart.md Creates a new streamlinechart with specified dimensions. The chart is initialized with the given width and height in terminal columns and rows, respectively. ```APIDOC ## Streamlinechart.new ### Description Creates a new streamlinechart with specified dimensions. The chart is initialized with the given width and height in terminal columns and rows, respectively. ### Signature ```ruby def initialize(width, height) ``` ### Parameters #### Path Parameters - **width** (Integer) - Required - Width of chart in terminal columns - **height** (Integer) - Required - Height of chart in terminal rows ### Returns `Ntcharts::Streamlinechart` - A new streamlinechart instance ### Example ```ruby require "ntcharts" chart = Ntcharts::Streamlinechart.new(60, 12) chart.style = Ntcharts::Style.new.foreground("#00D4FF") loop do value = Math.sin(Time.now.to_f) * 4 + 5 chart.push(value) system("clear") puts chart.render sleep 0.1 end ``` ``` -------------------------------- ### to_s Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/sparkline.md An alias for the `view()` method, returning the rendered sparkline as a string. ```APIDOC ## to_s ### Description Alias for `view()`. Returns the rendered sparkline as a string. ### Signature def to_s ### Returns `String` - The rendered chart as a terminal string ``` -------------------------------- ### Initializing Linechart with Invalid Argument Count Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/errors.md Demonstrates the ArgumentError when Linechart is initialized with an incorrect number of arguments. ```ruby # Valid: 2 args (auto-range) chart1 = Ntcharts::Linechart.new(50, 12) # Valid: 6 args (fixed-range) chart2 = Ntcharts::Linechart.new(50, 12, 0.0, 10.0, 0.0, 10.0) # Invalid: 3 args chart3 = Ntcharts::Linechart.new(50, 12, 0.0) # raises ArgumentError ``` -------------------------------- ### Add Data Points to Timeserieslinechart Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/timeserieslinechart.md Demonstrates adding data points to a Timeserieslinechart. It shows how to use both Ruby Time objects and Unix timestamps for the time parameter. ```ruby chart = Ntcharts::Timeserieslinechart.new(70, 15) # Using Ruby Time objects now = Time.now (0..60).each do |i| time = now - (60 - i) * 60 value = 50 + (i % 20) chart.push(time, value) end # Or using Unix timestamps chart.push(1234567890, 100) ``` -------------------------------- ### view Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/barchart.md Returns the rendered bar chart as a string, formatted with ANSI escape codes for terminal display. ```APIDOC ## view ### Description Returns the rendered bar chart as a string. ### Signature ```ruby def view ``` ### Parameters None ### Returns `String` - The rendered chart as a terminal string (ANSI-formatted) ### Example ```ruby chart = Ntcharts::Barchart.new(50, 12) chart.push(label: "Go", values: [{ value: 85 }]) chart.draw output = chart.view puts output ``` ``` -------------------------------- ### to_s Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/wavelinechart.md An alias for the `view()` method. It returns the rendered wavelinechart as a string, formatted for terminal display. ```APIDOC ## to_s ### Description Alias for `view()`. Returns the rendered wavelinechart as a string. ### Method `to_s` ### Parameters: None ### Returns `String` - The rendered chart as a terminal string ``` -------------------------------- ### view Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/wavelinechart.md Returns the rendered wavelinechart as a string. The output is formatted with ANSI escape codes for terminal display. ```APIDOC ## view ### Description Returns the rendered wavelinechart as a string. ### Method `view` ### Parameters: None ### Returns `String` - The rendered chart as a terminal string (ANSI-formatted) ``` -------------------------------- ### handle() Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/style.md Returns the internal handle for the underlying Go style object. This is used internally by ntcharts. ```APIDOC ## handle() ### Description Returns the internal handle for the underlying Go style object. This is used internally by ntcharts. ### Method `handle` ### Parameters None ### Returns `Integer` — The opaque handle to the internal style structure ``` -------------------------------- ### Apply Ntcharts::Style Styling to Charts Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/README.md Configure chart styling using `Ntcharts::Style` for foreground, background, and bold attributes. ```ruby style = Ntcharts::Style.new .foreground("#00FF00") .background("#000033") .bold(true) chart.style = style ``` -------------------------------- ### background(color) Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/style.md Sets the background color for the style. Accepts various color formats including hex codes, ANSI names, and 256-color codes. ```APIDOC ## background(color) ### Description Sets the background color. Returns a new Style object with the color applied. ### Method `background` ### Parameters #### Path Parameters - **color** (String) - Required - Color as hex code, ANSI color name, or ANSI 256-color code ### Returns `Ntcharts::Style` — A new Style with background color applied ### Example ```ruby # Using hex color style = Ntcharts::Style.new.background("#000033") # Using ANSI color code style = Ntcharts::Style.new.background("16") chart = Ntcharts::Sparkline.new(40, 6) chart.style = style ``` ``` -------------------------------- ### view Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/sparkline.md Returns the currently rendered sparkline as a string. The output includes ANSI formatting for terminal display. ```APIDOC ## view ### Description Returns the rendered sparkline as a string. ### Signature def view ### Parameters None ### Returns `String` - The rendered chart as a terminal string (ANSI-formatted) ### Example ```ruby chart = Ntcharts::Sparkline.new(40, 6) [1, 4, 2, 7, 3, 9, 5].each { |v| chart.push(v) } chart.draw output = chart.view puts output ``` ``` -------------------------------- ### view Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/timeserieslinechart.md Returns the rendered time-series chart as a string, suitable for printing to the terminal. The output includes ANSI formatting. ```APIDOC ## view() ### Description Returns the rendered time-series chart as a string. ### Parameters None ### Returns `String` - The rendered chart as a terminal string (ANSI-formatted) ``` -------------------------------- ### Push Multiple Numeric Values to Time-Series Chart Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/README.md Shows how to efficiently add multiple numeric data points to time-series charts like Sparkline and Streamlinechart using the 'push_all' method with an array of values. ```ruby chart.push(numeric_value) chart.push_all([1, 2, 3, 4, 5]) ``` -------------------------------- ### render_braille() Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/timeserieslinechart.md Renders the chart using braille characters. This method is a shortcut for `draw_braille()` and returns the output as a string. ```APIDOC ## render_braille() ### Description Convenience method that calls `draw_braille()` and returns the rendered output. ### Method ```ruby def render_braille ``` ### Parameters None ### Returns `String` — The rendered chart as a terminal string ``` -------------------------------- ### draw Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/barchart.md Renders the bar chart, preparing it for display. This method should be called before retrieving the chart's string representation. ```APIDOC ## draw ### Description Renders the bar chart. ### Signature ```ruby def draw ``` ### Parameters None ### Returns `self` - Returns the barchart instance for method chaining ### Example ```ruby chart = Ntcharts::Barchart.new(50, 12) chart.push(label: "A", values: [{ value: 50 }]) chart.draw puts chart.view ``` ``` -------------------------------- ### push_all Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/barchart.md Adds multiple bars to the chart simultaneously. This is useful for efficiently adding several bars at once from an array. ```APIDOC ## push_all ### Description Adds multiple bars to the chart at once. ### Signature ```ruby def push_all(bar_data_array) ``` ### Parameters #### Path Parameters - **bar_data_array** (Array) - Required - Array of BarData objects or Hashes ### Returns `self` - Returns the barchart instance for method chaining ### Raises - **ArgumentError** - If array contains items that are not BarData objects or Hashes ### Example ```ruby chart = Ntcharts::Barchart.new(50, 12) bars = [ { label: "Q1", values: [{ value: 100 }] }, { label: "Q2", values: [{ value: 150 }] }, { label: "Q3", values: [{ value: 120 }] } ] chart.push_all(bars) ``` ``` -------------------------------- ### label_style=(value) Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/barchart.md Sets the style for bar labels. Returns the set style object. ```APIDOC ## label_style=(value) ### Description Sets the style for bar labels. ### Method ```ruby def label_style=(value) ``` ### Parameters #### Parameters - **value** (Ntcharts::Style or Lipgloss::Style) - Required - Style to apply to labels ### Returns `Ntcharts::Style` — The set style object ### Example ```ruby chart = Ntcharts::Barchart.new(50, 12) label_style = Ntcharts::Style.new.foreground("#888888") chart.label_style = label_style ``` ``` -------------------------------- ### Ntcharts.version Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/module.md Returns the gem version and upstream ntcharts version information. ```APIDOC ## Ntcharts.version() ### Description Returns the gem version and upstream ntcharts version information. ### Method `self.version` ### Parameters None ### Returns `String` - A formatted version string containing both the gem version and upstream ntcharts version, e.g. "ntcharts v0.1.2 (upstream 0.3.1) [Go native extension]" ### Request Example ```ruby puts Ntcharts.version # Output: ntcharts v0.1.2 (upstream 0.3.1) [Go native extension] ``` ### Response #### Success Response `String` - A formatted version string. #### Response Example ``` ntcharts v0.1.2 (upstream 0.3.1) [Go native extension] ``` ``` -------------------------------- ### Draw Braille Lines on a LineChart Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/README.md Create a Linechart and draw smooth curves using `draw_braille_line` between consecutive points. Axes are then drawn. ```ruby chart = Ntcharts::Linechart.new(60, 15, 0.0, 30.0, -5.0, 10.0) points = (0..30).map { |i| [i.to_f, Math.sin(i * 0.2) * 4 + 3] } points.each_cons(2) do |(x1, y1), (x2, y2)| chart.draw_braille_line(x1, y1, x2, y2) end chart.draw_axes puts chart.view ``` -------------------------------- ### Recovering from Invalid Barchart Push Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/errors.md Shows how to correctly push data to Barchart using either a Hash or BarData object. ```ruby chart = Ntcharts::Barchart.new(50, 12) # Use Hash chart.push(label: "Q1", values: [{ value: 100 }]) # Or use BarData chart.push(Ntcharts::BarData.new(label: "Q1", values: [{ value: 100 }])) ``` -------------------------------- ### Apply Lipgloss Styling to Charts Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/README.md Set chart, axis, and label styles using `Lipgloss::Style` objects. This applies to various chart types that support styling. ```ruby require "lipgloss" chart_style = Lipgloss::Style.new.foreground("#FF6B6B") axis_style = Lipgloss::Style.new.foreground("#666666") label_style = Lipgloss::Style.new.foreground("#888888") chart.style = chart_style chart.axis_style = axis_style chart.label_style = label_style ``` -------------------------------- ### push_all Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/sparkline.md Adds multiple numeric data points to the sparkline at once. This is useful for populating the sparkline with a collection of data. ```APIDOC ## push_all ### Description Adds multiple numeric data points to the sparkline at once. ### Signature def push_all(values) ### Parameters #### Path Parameters - **values** (Array) - Required - Array of numeric values to add ### Returns `self` - Returns the sparkline instance for method chaining ### Example ```ruby chart = Ntcharts::Sparkline.new(40, 6) chart.push_all([1, 4, 2, 7, 3, 9, 5, 8]) ``` ``` -------------------------------- ### to_s Source: https://github.com/marcoroth/ntcharts-ruby/blob/main/_autodocs/api-reference/streamlinechart.md An alias for the `view()` method. It returns the rendered streamlinechart as a string. ```APIDOC ## to_s ### Description An alias for the `view()` method. It returns the rendered streamlinechart as a string. ### Signature ```ruby def to_s ``` ### Returns `String` - The rendered chart as a terminal string ```