### Install simple-ascii-chart Source: https://github.com/gtktsc/ascii-chart/blob/master/README.md Install the package using yarn or npm. ```bash yarn add simple-ascii-chart # or npm install simple-ascii-chart ``` -------------------------------- ### Input data for multiple series Source: https://github.com/gtktsc/ascii-chart/blob/master/README.md Example of input data formatted as multiple series, where each series is an array of [x, y] points. ```typescript const input = [ [ [0, 18], [1, 1], [2, 3], ], [ [4, 1], [5, 0], [6, 1], ], ]; ``` -------------------------------- ### Input data for a single series Source: https://github.com/gtktsc/ascii-chart/blob/master/README.md Example of input data formatted as a single series of [x, y] points. ```typescript const input = [ [1, 1], [2, 4], [3, 40], ]; ``` -------------------------------- ### Plotting with Custom Line Formatter Source: https://github.com/gtktsc/ascii-chart/blob/master/README.md Illustrates how to customize line rendering using a `lineFormatter` function. This example adds directional arrows based on data trends. ```typescript plot( [ [1, 0], [2, 20], [3, 29], [4, 10], [5, 3], [6, 40], [7, 0], [8, 20], ], { height: 10, width: 30, lineFormatter: ({ y, plotX, plotY, input, index }) => { const output = [{ x: plotX, y: plotY, symbol: '█' }]; if (input[index - 1]?.[1] < y) { return [...output, { x: plotX, y: plotY - 1, symbol: '▲' }]; } return [...output, { x: plotX, y: plotY + 1, symbol: '▼' }]; }, }, ); ``` -------------------------------- ### Customizing chart symbols Source: https://github.com/gtktsc/ascii-chart/blob/master/README.md Example of overriding default symbols used for chart elements like background, border, points, and axes. ```typescript symbols: { background: '.', border: undefined, point: '●', thresholds: { x: '━', y: '┃', }, empty: ' ', axis: { n: '▲', ns: '│', y: '┤', nse: '└', x: '┬', we: '─', e: '▶', }, chart: { we: '━', wns: '┓', ns: '┃', nse: '┗', wsn: '┛', sne: '┏', area: '█', }, } ``` -------------------------------- ### Generate chart via API with URL parameters Source: https://github.com/gtktsc/ascii-chart/blob/master/README.md Generate an ASCII chart by passing input data and settings as URL parameters to the API endpoint. ```bash https://simple-ascii-chart.vercel.app/api?input=[[1,2],[2,3],[3,4]]&settings={%22width%22:50} ``` -------------------------------- ### Settings Type Reference Source: https://context7.com/gtktsc/ascii-chart/llms.txt Complete TypeScript interface for all configuration options. ```APIDOC ## Settings Type Reference Complete TypeScript interface for all configuration options. ```typescript import { Settings, Color, Coordinates } from 'simple-ascii-chart'; const settings: Settings = { color: 'ansiGreen', // Color | Color[] | ColorGetter width: 60, // Plot width in characters height: 20, // Plot height in characters yRange: [0, 100], // Y-axis range [min, max] showTickLabel: true, // Show full tick labels hideXAxis: false, // Hide X-axis line hideXAxisTicks: false, // Hide X-axis tick marks hideYAxis: false, // Hide Y-axis line hideYAxisTicks: false, // Hide Y-axis tick marks customXAxisTicks: [0, 5, 10], // Custom X tick values customYAxisTicks: [0, 50, 100], // Custom Y tick values title: 'My Chart', // Chart title xLabel: 'Time', // X-axis label yLabel: 'Value', // Y-axis label thresholds: [{ x: 5, y: 50 }], // Threshold lines points: [{ x: 3, y: 75 }], // Overlay points fillArea: false, // Fill area under lines legend: { position: 'bottom' }, // Legend configuration axisCenter: [0, 0], // Custom axis origin mode: 'line', // 'line' | 'point' | 'bar' | 'horizontalBar' debugMode: false, // Enable debug logging }; ``` ``` -------------------------------- ### Settings Type Reference Source: https://context7.com/gtktsc/ascii-chart/llms.txt Complete TypeScript interface definition for all available configuration options. ```typescript import { Settings, Color, Coordinates } from 'simple-ascii-chart'; const settings: Settings = { color: 'ansiGreen', // Color | Color[] | ColorGetter width: 60, // Plot width in characters height: 20, // Plot height in characters yRange: [0, 100], // Y-axis range [min, max] showTickLabel: true, // Show full tick labels hideXAxis: false, // Hide X-axis line hideXAxisTicks: false, // Hide X-axis tick marks hideYAxis: false, // Hide Y-axis line hideYAxisTicks: false, // Hide Y-axis tick marks customXAxisTicks: [0, 5, 10], // Custom X tick values customYAxisTicks: [0, 50, 100], // Custom Y tick values title: 'My Chart', // Chart title xLabel: 'Time', // X-axis label yLabel: 'Value', // Y-axis label thresholds: [{ x: 5, y: 50 }], // Threshold lines points: [{ x: 3, y: 75 }], // Overlay points fillArea: false, // Fill area under lines legend: { position: 'bottom' }, // Legend configuration axisCenter: [0, 0], // Custom axis origin mode: 'line', // 'line' | 'point' | 'bar' | 'horizontalBar' debugMode: false, // Enable debug logging }; ``` -------------------------------- ### API Endpoint Usage Source: https://context7.com/gtktsc/ascii-chart/llms.txt Generate charts via HTTP requests using URL parameters or POST bodies. ```bash # GET request with URL parameters curl "https://simple-ascii-chart.vercel.app/api?input=[[1,2],[2,3],[3,4]]&settings={%22width%22:50}" # POST request with input data curl -d input='[[1,2],[2,3],[3,4]]' -G https://simple-ascii-chart.vercel.app/api ``` -------------------------------- ### Plot with Points, Thresholds, and Legend Source: https://github.com/gtktsc/ascii-chart/blob/master/README.md Demonstrates complex configuration including multi-series data, custom colors, a legend, and specific point/threshold markers. ```typescript plot( [ [ [1, 2], [2, -2], [3, 4], [4, 1], ], [ [1, 6], [2, -3], [3, 0], [4, 0], ], ], { width: 40, color: ['ansiGreen', 'ansiMagenta', 'ansiBlack', 'ansiYellow'], legend: { position: 'left', series: ['series 1', 'series 2'], points: ['point 1', 'point 2', 'point 3'], thresholds: ['threshold 1', 'threshold 2'], }, title: 'Points', thresholds: [ { y: 5, x: 2, color: 'ansiBlue', }, { y: 2, color: 'ansiGreen', }, ], points: [ { y: 5, x: 5, color: 'ansiBlue', }, { y: -1, x: 1, color: 'ansiCyan', }, { y: 2, x: 2, color: 'ansiRed', }, ], }, ); ``` -------------------------------- ### CommonJS Usage Source: https://context7.com/gtktsc/ascii-chart/llms.txt Use the package in CommonJS environments by accessing the default export. ```APIDOC ## CommonJS Usage Use the package in CommonJS environments by accessing the default export. ```javascript // Option 1: access default export const plot = require('simple-ascii-chart').default; // Option 2: use named export const { plot } = require('simple-ascii-chart'); const chart = plot( [ [1, 1], [2, 4], [3, 3], ], { width: 20, height: 10 } ); console.log(chart); ``` ``` -------------------------------- ### Basic Plotting Source: https://github.com/gtktsc/ascii-chart/blob/master/README.md Renders a simple line chart using an array of coordinate pairs. ```typescript plot( [ [1, 1], [2, 4], [3, 4], [4, 2], [5, -1], ], { width: 9, height: 6 }, ); ``` -------------------------------- ### Generate chart via API using curl Source: https://github.com/gtktsc/ascii-chart/blob/master/README.md Generate an ASCII chart by sending a POST request to the API endpoint with input data as a JSON string. ```bash curl -d input='[[1,2],[2,3],[3,4]]' -G https://simple-ascii-chart.vercel.app/api ``` -------------------------------- ### Generate chart using plot function Source: https://github.com/gtktsc/ascii-chart/blob/master/README.md Basic usage of the plot function with input data and settings to generate an ASCII chart. ```javascript const graph = plot(input, settings); console.log(graph); ``` -------------------------------- ### CommonJS Usage Source: https://context7.com/gtktsc/ascii-chart/llms.txt Access the library in CommonJS environments using default or named exports. ```javascript // Option 1: access default export const plot = require('simple-ascii-chart').default; // Option 2: use named export const { plot } = require('simple-ascii-chart'); const chart = plot( [ [1, 1], [2, 4], [3, 3], ], { width: 20, height: 10 } ); console.log(chart); ``` -------------------------------- ### API Endpoint Usage Source: https://context7.com/gtktsc/ascii-chart/llms.txt Generate charts via HTTP API by sending data as URL parameters or POST body. ```APIDOC ## API Endpoint Usage Generate charts via HTTP API by sending data as URL parameters or POST body. ```bash # GET request with URL parameters curl "https://simple-ascii-chart.vercel.app/api?input=[[1,2],[2,3],[3,4]]&settings={%22width%22:50}" # POST request with input data curl -d input='[[1,2],[2,3],[3,4]]' -G https://simple-ascii-chart.vercel.app/api ``` ``` -------------------------------- ### Configure Legend for ASCII Chart Source: https://context7.com/gtktsc/ascii-chart/llms.txt Enhance chart readability by adding a legend using the 'legend' option. Configure position, and labels for series, points, and thresholds. ```typescript import plot from 'simple-ascii-chart'; const data = [ [ [1, 2], [2, -2], [3, 4], [4, 1], ], [ [1, 6], [2, -3], [3, 0], [4, 0], ], ]; const chart = plot(data, { width: 40, color: ['ansiGreen', 'ansiMagenta'], legend: { position: 'bottom', series: ['Temperature', 'Humidity'], points: ['Peak', 'Valley'], thresholds: ['Upper limit', 'Lower limit'], }, thresholds: [ { y: 5, color: 'ansiBlue' }, { y: -2, color: 'ansiRed' }, ], points: [ { x: 3, y: 4, color: 'ansiYellow' }, ], }); console.log(chart); ``` -------------------------------- ### Basic Line Chart with Single Series Source: https://context7.com/gtktsc/ascii-chart/llms.txt Generates a basic line chart with a single data series. Ensure the data is provided as an array of [x, y] coordinate pairs. ```typescript import plot from 'simple-ascii-chart'; // Basic line chart with single series const data = [ [1, 1], [2, 4], [3, 4], [4, 2], [5, -1], ]; const chart = plot(data, { width: 9, height: 6 }); console.log(chart); ``` -------------------------------- ### Plot with Title and Custom Size Source: https://github.com/gtktsc/ascii-chart/blob/master/README.md Configures a plot with a specific title and custom dimensions. ```typescript plot( [ [1, 1], [2, 4], [3, 4], [4, 2], [5, -1], [6, 3], [7, -1], [8, 9], ], { title: 'Important data', width: 20, height: 8 }, ); ``` -------------------------------- ### Overlay Points on ASCII Chart Source: https://context7.com/gtktsc/ascii-chart/llms.txt Add individual point markers on top of the chart using the 'points' option. Each point can be customized with coordinates and color. ```typescript import plot from 'simple-ascii-chart'; const data = [ [1, 1], [2, 4], [3, 4], [4, 2], [5, -1], [6, 3], [7, -1], [8, 9], ]; const chart = plot(data, { width: 40, title: 'Data with Points', points: [ { y: 5, x: 5, color: 'ansiBlue' }, { y: -1, x: 1, color: 'ansiRed' }, { y: 2, x: 2, color: 'ansiGreen' }, ], }); console.log(chart); ``` -------------------------------- ### Plot with Colors and Legend Source: https://github.com/gtktsc/ascii-chart/blob/master/README.md Renders multiple data series with specific colors and a legend. ```typescript plot( [ [ [1, 1], [2, 2], [3, 4], [4, 6], ], [ [5, 4], [6, 1], [7, 2], [8, 3], ], ], { width: 20, fillArea: true, color: ['ansiGreen', 'ansiBlue'], legend: { position: 'bottom', series: ['first', 'second'] }, }, ); ``` -------------------------------- ### Import plot function in CommonJS Source: https://github.com/gtktsc/ascii-chart/blob/master/README.md Import the plot function in CommonJS environments. Access it via the default export or named export. ```javascript // Option 1: access default export const plot = require('simple-ascii-chart').default; // Option 2: use named export const { plot } = require('simple-ascii-chart'); ``` -------------------------------- ### Chart Configuration Settings Source: https://github.com/gtktsc/ascii-chart/blob/master/README.md The Settings type defines all available configuration options for the plot function, including dimensions, axis labels, and styling. ```typescript type Settings = { color?: Colors; // Colors for the plot lines or areas width?: number; // Width of the plot height?: number; // Height of the plot yRange?: [number, number]; // Range of y-axis values showTickLabel?: boolean; // Option to show tick labels on the axis hideXAxis?: boolean; // Option to hide the x-axis hideXAxisTicks?: boolean; // Option to hide x-axis ticks and labels hideYAxis?: boolean; // Option to hide the y-axis hideYAxisTicks?: boolean; // Option to hide y-axis ticks and labels customXAxisTicks?: number[]; // Custom values for x-axis ticks customYAxisTicks?: number[]; // Custom values for y-axis ticks title?: string; // Title of the plot xLabel?: string; // Label for the x-axis yLabel?: string; // Label for the y-axis thresholds?: Threshold[]; // Array of threshold lines points?: GraphPoint[]; // Array of points to render fillArea?: boolean; // Option to fill the area under lines legend?: Legend; // Legend settings axisCenter?: MaybePoint; // Center point for axes alignment formatter?: Formatter; // Custom formatter for axis values lineFormatter?: (args: LineFormatterArgs) => CustomSymbol | CustomSymbol[]; // Custom line formatter symbols?: Symbols; // Custom symbols for chart elements mode?: GraphMode; // Graph rendering mode debugMode?: boolean; // Option to enable debug mode }; ``` -------------------------------- ### Add Border Source: https://context7.com/gtktsc/ascii-chart/llms.txt Add a border around the entire chart using a custom border symbol. ```APIDOC ## Border Add a border around the entire chart using a custom border symbol. ```typescript import plot from 'simple-ascii-chart'; const data = [ [1, 1], [2, 4], [3, 4], [4, 2], [5, -1], [6, 3], [7, -1], [8, 9], ]; const chart = plot(data, { symbols: { border: '\u2588' }, xLabel: 'x', yLabel: 'y', width: 20, height: 8, }); console.log(chart); ``` ``` -------------------------------- ### Custom Line Rendering for ASCII Chart Source: https://context7.com/gtktsc/ascii-chart/llms.txt Override default line rendering with custom symbols at each data point using 'lineFormatter'. This allows for advanced visual indicators like arrows for rising/falling values. ```typescript import plot from 'simple-ascii-chart'; import { LineFormatterArgs } from 'simple-ascii-chart'; const data = [ [1, 0], [2, 20], [3, 29], [4, 10], [5, 3], [6, 40], [7, 0], ]; const chart = plot(data, { height: 10, width: 30, lineFormatter: ({ y, plotX, plotY, input, index }: LineFormatterArgs) => { const output = [{ x: plotX, y: plotY, symbol: '\u2588' }]; // Add arrow indicator for rising/falling values if (input[index - 1]?.[1] < y) { return [...output, { x: plotX, y: plotY - 1, symbol: '\u25B2' }]; } return [...output, { x: plotX, y: plotY + 1, symbol: '\u25BC' }]; }, }); console.log(chart); ``` -------------------------------- ### Title and Axis Labels for Charts Source: https://context7.com/gtktsc/ascii-chart/llms.txt Adds a title and labels for the X and Y axes to charts for better annotation. Use 'title', 'xLabel', and 'yLabel' options to customize. ```typescript import plot from 'simple-ascii-chart'; const data = [ [1, 1], [2, 4], [3, 4], [4, 2], [5, -1], [6, 3], [7, -1], [8, 9], ]; const chart = plot(data, { title: 'Sales Data', xLabel: 'Month', yLabel: 'Revenue', width: 20, height: 8, }); console.log(chart); ``` -------------------------------- ### Add a Border to the Chart Source: https://context7.com/gtktsc/ascii-chart/llms.txt Use the symbols configuration to define a custom border character around the chart. ```typescript import plot from 'simple-ascii-chart'; const data = [ [1, 1], [2, 4], [3, 4], [4, 2], [5, -1], [6, 3], [7, -1], [8, 9], ]; const chart = plot(data, { symbols: { border: '\u2588' }, xLabel: 'x', yLabel: 'y', width: 20, height: 8, }); console.log(chart); ``` -------------------------------- ### TypeScript type for input coordinates Source: https://github.com/gtktsc/ascii-chart/blob/master/README.md Defines the structure for input data, which can be a single series or multiple series of points. ```typescript type Coordinates = Point[] | Point[][]; ``` -------------------------------- ### Horizontal Bar Chart with Axis Source: https://github.com/gtktsc/ascii-chart/blob/master/README.md Creates a horizontal bar chart with custom axis centering and tick labels. Useful for displaying rankings or distributions. ```typescript plot( [ [0, 3], [1, 2], [2, 3], [3, 4], [4, -2], [5, -5], [6, 2], [7, 0], ], { mode: 'horizontalBar', showTickLabel: true, width: 40, height: 20, axisCenter: [3, 1], }, ); ``` -------------------------------- ### Multi-Series Plotting Source: https://context7.com/gtktsc/ascii-chart/llms.txt Renders multiple data series on the same chart by passing an array of coordinate arrays. Each series is displayed as a separate line. Specify colors for each series using the 'color' option. ```typescript import plot from 'simple-ascii-chart'; const multiSeriesData = [ [ [0, 18], [1, 1], [2, 3], [3, 11], [4, 5], [5, 16], ], [ [0, 0], [1, 1], [2, 1], [3, 1], [4, 1], [5, 0], ], ]; const chart = plot(multiSeriesData, { width: 40, height: 10, color: ['ansiBlue', 'ansiGreen'], }); console.log(chart); ``` -------------------------------- ### Color Support for Charts Source: https://context7.com/gtktsc/ascii-chart/llms.txt Applies ANSI colors to chart lines using the 'color' option. This can be a single color for all series, an array of colors for multiple series, or a color getter function. Available colors include ansiRed, ansiGreen, ansiBlack, ansiYellow, ansiBlue, ansiMagenta, ansiCyan, ansiWhite. ```typescript import plot from 'simple-ascii-chart'; // Single color const chart1 = plot( [ [1, 2], [2, 4], [3, 3], ], { color: 'ansiGreen', width: 20 } ); // Multiple colors for multiple series const chart2 = plot( [ [ [1, 1], [2, 2], [3, 4], ], [ [1, 4], [2, 1], [3, 2], ], ], { width: 20, fillArea: true, color: ['ansiGreen', 'ansiBlue'], legend: { position: 'bottom', series: ['Series A', 'Series B'] }, } ); console.log(chart2); ``` -------------------------------- ### Bar Chart Mode Source: https://context7.com/gtktsc/ascii-chart/llms.txt Creates vertical bar charts by setting 'mode: 'bar''. This mode is suitable for visualizing categorical data. Use 'showTickLabel: true' to display tick labels on the axis. ```typescript import plot from 'simple-ascii-chart'; const data = [ [0, 3], [1, 2], [2, 3], [3, 4], [4, -2], [5, -5], [6, 2], [7, 0], ]; const chart = plot(data, { title: 'Bar Chart', mode: 'bar', showTickLabel: true, width: 40, axisCenter: [0, 0], }); console.log(chart); ``` -------------------------------- ### Plotting with Large Numbers Source: https://github.com/gtktsc/ascii-chart/blob/master/README.md Demonstrates plotting data points with large numerical values. Adjusts chart dimensions for clarity. ```typescript plot( [ [-9000, 2000], [-8000, -3000], [-2000, -2000], [2000, 2000], [3000, 1500], [4000, 5000], [10000, 1400], [11000, 20000], [12000, 30000], ], { width: 60, height: 20, }, ); ``` -------------------------------- ### Hide Axis and Tick Options Source: https://context7.com/gtktsc/ascii-chart/llms.txt Toggle visibility of axes and tick labels to create minimalist chart designs. ```typescript import plot from 'simple-ascii-chart'; const data = [ [-5, 2], [2, -3], [13, 0.1], [4, 2], [5, -2], [6, 12], ]; // Hide both axes completely const chartNoAxes = plot(data, { width: 40, height: 10, hideYAxis: true, hideXAxis: true, }); console.log(chartNoAxes); // Hide only tick labels const chartNoTicks = plot(data, { width: 40, height: 10, hideYAxisTicks: true, hideXAxisTicks: true, }); console.log(chartNoTicks); ``` -------------------------------- ### Plot with Border Source: https://github.com/gtktsc/ascii-chart/blob/master/README.md Wraps the chart in a custom border symbol. ```typescript plot( [ [1, 1], [2, 4], [3, 4], [4, 2], [5, -1], [6, 3], [7, -1], [8, 9], ], { symbols: { border: '█' }, xLabel: 'x', yLabel: 'y', width: 20, height: 8 }, ); ``` -------------------------------- ### Horizontal Bar Chart Mode Source: https://context7.com/gtktsc/ascii-chart/llms.txt Generates horizontal bar charts by setting 'mode: 'horizontalBar''. This is useful for displaying data where categories are listed vertically and values horizontally. 'showTickLabel: true' displays labels on the axis. ```typescript import plot from 'simple-ascii-chart'; const data = [ [1, 0], [2, 20], [3, 29], ]; const chart = plot(data, { height: 10, mode: 'horizontalBar', width: 20, showTickLabel: true, title: 'Horizontal Bar Chart', }); console.log(chart); ``` -------------------------------- ### Multi-Series Plot Source: https://github.com/gtktsc/ascii-chart/blob/master/README.md Renders multiple data series on the same chart with custom dimensions and colors. ```typescript plot( [ [ [0, 18], [1, 1], [2, 3], [3, 11], [4, 5], [5, 16], [6, 17], [7, 14], [8, 7], [9, 4], ], [ [0, 0], [1, 1], [2, 1], [3, 1], [4, 1], [5, 0], [6, 1], [7, 0], [8, 1], [9, 0], ], ], { width: 40, height: 10, color: ['ansiBlue', 'ansiGreen'] }, ); ``` -------------------------------- ### Plot with Axis Center Source: https://github.com/gtktsc/ascii-chart/blob/master/README.md Configure the plot to center the X and Y axes at specific coordinates, such as [0, 0]. This is helpful for visualizing data that spans positive and negative values. ```typescript plot( [ [ [-8, -8], [-4, -4], [-3, -3], [-2, -2], [-1, -1], [0, 0], [2, 2], [3, 3], [4, 4], [8, 8], ], ], { width: 60, height: 20, axisCenter: [0, 0] }, ); ``` -------------------------------- ### Hide Axis Options Source: https://context7.com/gtktsc/ascii-chart/llms.txt Control visibility of axes and tick marks for minimalist visualizations. ```APIDOC ## Hide Axis Options Control visibility of axes and tick marks for minimalist visualizations. ```typescript import plot from 'simple-ascii-chart'; const data = [ [-5, 2], [2, -3], [13, 0.1], [4, 2], [5, -2], [6, 12], ]; // Hide both axes completely const chartNoAxes = plot(data, { width: 40, height: 10, hideYAxis: true, hideXAxis: true, }); console.log(chartNoAxes); // Hide only tick labels const chartNoTicks = plot(data, { width: 40, height: 10, hideYAxisTicks: true, hideXAxisTicks: true, }); console.log(chartNoTicks); ``` ``` -------------------------------- ### TypeScript type for a single point Source: https://github.com/gtktsc/ascii-chart/blob/master/README.md Defines a single data point with x and y coordinates. ```typescript type Point = [x: number, y: number]; ``` -------------------------------- ### Scaled-Up Plot Source: https://github.com/gtktsc/ascii-chart/blob/master/README.md Renders a larger chart with a wider range of data points. ```typescript plot( [ [1, 1], [2, 4], [3, 40], [4, 2], [5, -1], [6, 3], [7, -1], [8, -1], [9, 9], [10, 9], ], { width: 40, height: 10 }, ); ``` -------------------------------- ### Custom Axis Ticks Source: https://context7.com/gtktsc/ascii-chart/llms.txt Specify exact tick values for the x and y axes instead of automatic calculation. ```APIDOC ## Custom Axis Ticks Specify exact tick values for the x and y axes instead of automatic calculation. ```typescript import plot from 'simple-ascii-chart'; const data = [ [1, 2], [2, 3], [3, 4], [4, 1], [5, -1], [6, 3], [7, -1], [8, 9], [9, 10], [10, 11], ]; const chart = plot(data, { width: 20, height: 10, customYAxisTicks: [-30, -2, 0, 2, 4, 6, 30], customXAxisTicks: [-30, 0, 2, 4, 6, 30], }); console.log(chart); ``` ``` -------------------------------- ### Add Threshold Lines to ASCII Chart Source: https://context7.com/gtktsc/ascii-chart/llms.txt Use the 'thresholds' option to add horizontal and vertical lines to highlight specific values. You can specify y-values, x-values, or both. Colors can also be applied to thresholds. ```typescript import plot from 'simple-ascii-chart'; const data = [ [1, 1], [2, 4], [3, 4], [4, 2], [5, -1], [6, 3], [7, -1], [8, 9], ]; const chart = plot(data, { width: 40, thresholds: [ { y: 5, x: 5 }, { x: 2 }, ], }); console.log(chart); ``` ```typescript // With colors and legend const chartWithColors = plot(data, { width: 40, thresholds: [ { y: 5, x: 5, color: 'ansiBlue' }, { y: 2, color: 'ansiGreen' }, ], legend: { position: 'left', thresholds: ['Max limit', 'Warning'], }, }); console.log(chartWithColors); ``` -------------------------------- ### Plot with Points Overlay Source: https://github.com/gtktsc/ascii-chart/blob/master/README.md Adds specific points to a chart, including points that may fall outside the current visible axis range. ```typescript plot( [ [1, 1], [2, 4], [3, 4], [4, 2], [5, -1], [6, 3], [7, -1], [8, 9], ], { width: 40, title: 'Points', points: [ { y: 5, x: 5, color: 'ansiBlue', }, { y: -1, x: 1, color: 'ansiBlue', }, { y: 205, x: 1005, color: 'ansiBlue', }, { y: 2, x: 2, color: 'ansiRed', }, ], }, ); ``` -------------------------------- ### Import plot function in ESM Source: https://github.com/gtktsc/ascii-chart/blob/master/README.md Import the plot function for use in ESM environments like TypeScript or modern Node.js. Supports default or named imports. ```javascript import plot from 'simple-ascii-chart'; // or, if you prefer named imports: import { plot } from 'simple-ascii-chart'; ``` -------------------------------- ### Plot with Thresholds Source: https://github.com/gtktsc/ascii-chart/blob/master/README.md Configures horizontal and vertical thresholds on a single-series plot. ```typescript plot( [ [1, 1], [2, 4], [3, 4], [4, 2], [5, -1], [6, 3], [7, -1], [8, 9], ], { width: 40, thresholds: [ { y: 5, x: 5, }, { x: 2, }, ], }, ); ``` -------------------------------- ### Plot with Custom Formatter Source: https://github.com/gtktsc/ascii-chart/blob/master/README.md Use a custom formatter function to control how data points are displayed on the Y-axis and how X-axis labels are generated. This is useful for mapping numerical data to categorical labels. ```typescript plot( [ [ [0, -10], [1, 0.001], [2, 10], [3, 200], [4, 10000], [5, 2000000], [6, 50000000], ], ], { width: 30, height: 20, formatter: (n: number, { axis }: FormatterHelpers) => { const labels = ['A', 'B', 'C', 'D', 'E', 'F', 'G']; if (axis === 'y') return n; return labels[n] || 'X'; }, }, ); ``` -------------------------------- ### Bar Chart with Axis Source: https://github.com/gtktsc/ascii-chart/blob/master/README.md Generates a vertical bar chart with visible tick labels and centered axes. Suitable for comparing discrete values. ```typescript plot( [ [0, 3], [1, 2], [2, 3], [3, 4], [4, -2], [5, -5], [6, 2], [7, 0], ], { title: 'bar chart with axis', mode: 'bar', showTickLabel: true, width: 40, axisCenter: [0, 0], }, ); ``` -------------------------------- ### Plot with Custom Symbols Source: https://github.com/gtktsc/ascii-chart/blob/master/README.md Customize the symbols used for different chart elements, including empty spaces, background, axes, and data points. This allows for unique visual representations of the data. ```typescript plot( [ [1, 2], [2, 0], [3, 5], [4, 2], [5, -2], [6, 3], ], { symbols: { empty: 'x', background: '-', axis: { n: 'A', ns: 'i', y: 't', nse: 'o', x: 'j', we: 'm', e: 'B', }, chart: { we: '1', wns: '2', ns: '3', nse: '4', wsn: '5', sne: '6', }, }, width: 40, height: 10, }, ); ``` -------------------------------- ### Customize Symbols in ASCII Chart Source: https://context7.com/gtktsc/ascii-chart/llms.txt Override default chart symbols for background, borders, points, axes, chart lines, and thresholds using the 'symbols' option for complete visual control. ```typescript import plot from 'simple-ascii-chart'; const data = [ [1, 2], [2, 0], [3, 5], [4, 2], [5, -2], [6, 3], ]; const chart = plot(data, { width: 40, height: 10, symbols: { background: '.', border: '\u2588', empty: ' ', point: '\u25CF', axis: { n: 'A', ns: '|', y: '+', nse: 'L', x: '+', we: '-', e: '>', }, chart: { we: '=', wns: '\\', ns: '|', nse: '/', wsn: '/', sne: '\\', area: '#', }, thresholds: { x: '~', y: '!', }, }, }); console.log(chart); ``` -------------------------------- ### Plot with Filled Area Source: https://github.com/gtktsc/ascii-chart/blob/master/README.md Enables area filling for multiple data series. ```typescript plot( [ [ [1, 1], [2, 2], [3, 4], [4, 6], ], [ [1, 4], [2, 1], [3, 2], [4, 3], ], ], { fillArea: true, color: ['ansiGreen', 'ansiBlue'], }, ); ``` -------------------------------- ### Define Custom Axis Ticks Source: https://context7.com/gtktsc/ascii-chart/llms.txt Manually specify tick values for the X and Y axes to override automatic calculations. ```typescript import plot from 'simple-ascii-chart'; const data = [ [1, 2], [2, 3], [3, 4], [4, 1], [5, -1], [6, 3], [7, -1], [8, 9], [9, 10], [10, 11], ]; const chart = plot(data, { width: 20, height: 10, customYAxisTicks: [-30, -2, 0, 2, 4, 6, 30], customXAxisTicks: [-30, 0, 2, 4, 6, 30], }); console.log(chart); ``` -------------------------------- ### Plot with Axis Labels Source: https://github.com/gtktsc/ascii-chart/blob/master/README.md Adds labels to the X and Y axes for better data context. ```typescript plot( [ [1, 1], [2, 4], [3, 4], [4, 2], [5, -1], [6, 3], [7, -1], [8, 9], ], { xLabel: 'x', yLabel: 'y', width: 20, height: 8 }, ); ``` -------------------------------- ### Fill Area Under Line Chart Source: https://context7.com/gtktsc/ascii-chart/llms.txt Fills the area beneath a line chart using the 'fillArea: true' option, creating a solid area chart. This option is particularly effective when plotting multiple series with distinct colors. ```typescript import plot from 'simple-ascii-chart'; const data = [ [ [1, 1], [2, 2], [3, 4], [4, 6], ], [ [1, 4], [2, 1], [3, 2], [4, 3], ], ]; const chart = plot(data, { fillArea: true, color: ['ansiGreen', 'ansiBlue'], }); console.log(chart); ``` -------------------------------- ### Custom Data Formatting for ASCII Chart Axes Source: https://context7.com/gtktsc/ascii-chart/llms.txt Format axis tick labels using a custom function provided to the 'formatter' option. This function receives the value and helper objects for axis information. ```typescript import plot from 'simple-ascii-chart'; import { FormatterHelpers } from 'simple-ascii-chart'; const data = [ [0, -10], [1, 0.001], [2, 10], [3, 200], [4, 10000], [5, 2000000], ]; const chart = plot(data, { width: 30, height: 15, formatter: (value: number, { axis }: FormatterHelpers) => { if (axis === 'y') { if (Math.abs(value) >= 1000000) return `${(value / 1000000).toFixed(1)}M`; if (Math.abs(value) >= 1000) return `${(value / 1000).toFixed(1)}k`; return value; } // Custom x-axis labels const labels = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun']; return labels[value] || value; }, }); console.log(chart); ``` -------------------------------- ### Set Axis Center for ASCII Chart Source: https://context7.com/gtktsc/ascii-chart/llms.txt Adjust the axis origin to a custom position using 'axisCenter' for charts with negative values or centered visualizations. ```typescript import plot from 'simple-ascii-chart'; const data = [ [-8, -8], [-4, -4], [-3, -3], [0, 0], [2, 2], [3, 3], [4, 4], [8, 8], ]; const chart = plot(data, { width: 60, height: 20, axisCenter: [0, 0], }); console.log(chart); ``` -------------------------------- ### Limit Y-Axis Range in ASCII Chart Source: https://context7.com/gtktsc/ascii-chart/llms.txt Focus on specific data regions by limiting the visible y-axis range with the 'yRange' option. Points outside this range are filtered out. ```typescript import plot from 'simple-ascii-chart'; const data = [ [1, 2], [2, 3], [3, 4], [4, 8], ]; const chart = plot(data, { width: 20, height: 10, yRange: [1, 5], // Only show y values between 1 and 5 }); console.log(chart); ``` -------------------------------- ### Plot without Axes Source: https://github.com/gtktsc/ascii-chart/blob/master/README.md Hide both the X and Y axes from the plot by setting `hideYAxis` and `hideXAxis` options to true. This is useful for creating purely visual representations or when axes are implied by context. ```typescript plot( [ [-5, 2], [2, -3], [13, 0.1], [4, 2], [5, -2], [6, 12], ], { width: 40, height: 10, hideYAxis: true, hideXAxis: true, }, ); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.