### Run library examples Source: https://github.com/tool3/chartscii/blob/master/README.md Command to execute additional library examples using ts-node. ```bash npx ts-node examples/loaders.ts ``` -------------------------------- ### Install Chartscii Source: https://github.com/tool3/chartscii/blob/master/README.md Use npm to install the package. ```bash npm install chartscii ``` -------------------------------- ### Chartscii Comprehensive Customization Source: https://context7.com/tool3/chartscii/llms.txt Illustrates extensive customization options for Chartscii, including dimensions, colors, characters, themes, display modes, data manipulation, and structural elements. This example showcases a highly configured chart. ```typescript import Chartscii from 'chartscii'; const data = [25, 50, 75, 100, 60]; const chart = new Chartscii(data, { // Dimensions width: 80, height: 15, barSize: 2, padding: 1, // Display options title: 'Performance Metrics', labels: true, colorLabels: true, valueLabels: true, percentage: true, // Styling color: 'cyan', char: '█', fill: '░', theme: 'pastel', // Data manipulation sort: true, reverse: false, scale: 'auto', // Structure naked: false, orientation: 'horizontal', structure: { x: '═', y: '╢', axis: '║', topLeft: '╔', bottomLeft: '╚' } }); console.log(chart.create()); ``` -------------------------------- ### Create a Chart with Options Source: https://github.com/tool3/chartscii/blob/master/README.md Initialize a chart with specific configuration options including theme, color, and orientation. ```typescript import Chartscii from "chartscii"; const data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; const options = { title: "chartscii", width: 50, theme: "pastel", color: "pink", colorLabels: true, barSize: 2, orientation: "vertical" }; const chart = new Chartscii(data, options); console.log(char.create()); ``` -------------------------------- ### Initialize Chartscii with Number Array Source: https://context7.com/tool3/chartscii/llms.txt Demonstrates basic usage of Chartscii by initializing it with an array of numbers and creating a horizontal bar chart. Ensure the 'chartscii' library is imported. ```typescript import Chartscii from 'chartscii'; // Simple usage with number array const data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; const chart = new Chartscii(data); console.log(chart.create()); ``` -------------------------------- ### Create a vertical chart with styl3 formatting Source: https://github.com/tool3/chartscii/blob/master/README.md Demonstrates initializing a Chartscii instance with custom data, colors, and vertical orientation. ```tsx const colors = [ "red", "green", "yellow", "blue", "purple", "pink", "cyan", "orange" ]; const data = []; for (let i = 0; i < colors.length; i++) { const color = colors[i]; data.push({ value: i + 1, color, label: `@invert ${i}@`, theme: "pastel" }); } const chart = new Chartscii(data, { fill: "░", colorLabels: true, orientation: "vertical" }); console.log(chart.create()); ``` -------------------------------- ### Create ASCII Chart with Options Source: https://context7.com/tool3/chartscii/llms.txt Generates an ASCII chart using the create() method after instantiating Chartscii with specific options like title, color, and label coloring. The output is a formatted string ready for console display. ```typescript import Chartscii from 'chartscii'; const data = [5, 10, 15, 20]; const chart = new Chartscii(data, { title: 'Sales Report', color: 'green', colorLabels: true }); const output: string = chart.create(); console.log(output); ``` -------------------------------- ### Create Naked Charts and Loaders Source: https://context7.com/tool3/chartscii/llms.txt Generates borderless charts suitable for dynamic loading indicators. ```typescript import Chartscii from 'chartscii'; const createLoader = () => { const data = [ { value: Math.random() * 10, label: 'Task 1' }, { value: Math.random() * 10, label: 'Task 2' }, { value: Math.random() * 10, label: 'Task 3' } ]; const chart = new Chartscii(data, { width: 40, naked: true, // No border characters fill: '░', // Fill empty space color: 'green', colorLabels: true, theme: 'pastel', padding: 1 }); return chart.create(); }; // Animate loader setInterval(() => { process.stdout.write('\x1Bc'); // Clear screen console.log(createLoader()); }, 300); ``` -------------------------------- ### Create a Simple Chart from Numbers Source: https://github.com/tool3/chartscii/blob/master/README.md Generate a basic chart using an array of numbers. ```typescript import Chartscii from "chartscii"; const data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; const chart = new Chartscii(data); console.log(chart.create()); ``` -------------------------------- ### Display Percentages Source: https://context7.com/tool3/chartscii/llms.txt Enables automatic calculation and display of bar proportions relative to the total dataset. ```typescript import Chartscii from 'chartscii'; const marketShare = [ { value: 45, label: 'Product A', color: 'blue' }, { value: 30, label: 'Product B', color: 'green' }, { value: 15, label: 'Product C', color: 'yellow' }, { value: 10, label: 'Product D', color: 'red' } ]; const chart = new Chartscii(marketShare, { title: 'Market Share Distribution', percentage: true, // Shows (45.00%), (30.00%), etc. colorLabels: true, width: 50 }); console.log(chart.create()); // Output includes: Product A (45.00%)╢████████████████████████ ``` -------------------------------- ### Apply Colors to Charts Source: https://context7.com/tool3/chartscii/llms.txt Demonstrates applying named colors, hex codes, ANSI codes, and theme colors to chart bars. ```typescript import Chartscii from 'chartscii'; const data = [ { value: 30, color: 'red', label: 'Named Color' }, { value: 45, color: '#FF6B6B', label: 'Hex Color' }, { value: 60, color: '196', label: 'ANSI Code' }, { value: 75, color: 'marine', label: 'Theme Color' } ]; const chart = new Chartscii(data, { colorLabels: true, theme: 'pastel', // Available themes from styl3 width: 50 }); console.log(chart.create()); ``` -------------------------------- ### Create a Chart with ChartPoint Objects Source: https://github.com/tool3/chartscii/blob/master/README.md Use an array of objects to define custom labels, values, and colors for each bar. ```typescript import Chartscii from "chartscii"; const data = [ { label: "label", value: 2, color: "pink" }, { label: "label", value: 2, color: "purple" }, { label: "label", value: 2, color: "marine" } ]; const chart = new Chartscii(data, { colorLabels: true, valueLabels: true }); console.log(chart.create()); ``` -------------------------------- ### Default Chart Options Source: https://github.com/tool3/chartscii/blob/master/README.md View the default configuration object used by Chartscii. ```typescript const options: ChartOptions = { percentage: false, colorLabels: false, sort: false, reverse: false, naked: false, labels: true, color: undefined, fill: undefined, width: 100, height: 10, padding: 0, barSize: 1, title: "", char: "█", orientation: "horizontal", theme: "", structure: { x: "═", y: "╢", axis: "║", topLeft: "╔", bottomLeft: "╚" } }; ``` -------------------------------- ### Format Value Labels Source: https://context7.com/tool3/chartscii/llms.txt Configures numeric value displays with prefixes and decimal precision. ```typescript import Chartscii from 'chartscii'; const salesData = [ { value: 1250.5, label: 'Q1' }, { value: 2100.75, label: 'Q2' }, { value: 1875.25, label: 'Q3' }, { value: 3200.00, label: 'Q4' } ]; const chart = new Chartscii(salesData, { title: 'Quarterly Sales', valueLabels: true, valueLabelsPrefix: '$', // Prefix for values valueLabelsFloatingPoint: 2, // Decimal places color: 'green', colorLabels: true, width: 60 }); console.log(chart.create()); ``` -------------------------------- ### Animate Sine Wave Source: https://context7.com/tool3/chartscii/llms.txt Creates a real-time animated vertical chart using interval-based updates. ```typescript import Chartscii from 'chartscii'; const colors = ['red', 'orange', 'yellow', 'green', 'cyan', 'blue', 'purple', 'pink']; const createSineWave = () => { const data = []; const time = Date.now() * 0.005; for (let i = 0; i < 8; i++) { const value = Math.sin((i * 0.5) + time); data.push({ value, color: colors[i], label: String(i) }); } return new Chartscii(data, { title: 'Sine Wave', orientation: 'vertical', width: 80, height: 12, barSize: 2, padding: 2, fill: '░', theme: 'pastel', labels: true }); }; setInterval(() => { process.stdout.write('\x1Bc'); console.log(createSineWave().create()); }, 50); ``` -------------------------------- ### Chartscii Customization Options Source: https://github.com/tool3/chartscii/blob/master/README.md This section outlines the available options for customizing Chartscii charts. These options can be passed as parameters to control how the chart is rendered. ```APIDOC ## Chartscii Customization Options This section details the various options available for customizing Chartscii charts. These options can be passed as parameters to control how the chart is rendered. ### Options | name | description | type | default | | ------------------------ | ----------------------------------------------------------------------------------------------------------- | -------------------- | -------------------------------------------------------------- | | percentage | calculate and show percentage data | `boolean` | `false` | | colorLabels | color labels with provided color per label, or color provided to option | `boolean` | `false` | | valueLabels | show values of each bar | `boolean` | `false` | | valueLabelsPrefix | prefix for the value labels (for example to be used with currency) | `string` | `undefined` | | valueLabelsFloatingPoint | sets decimal place precision for value labels; defaults to printing entire number, excluding extra zeroes | `number` | `undefined` | | sort | sort the input data | `boolean` | `false` | | reverse | reverse the input data | `boolean` | `false` | | naked | don’t print chart structure ascii characters | `boolean` | `false` | | labels | show labels | `boolean` | `true` | | color | fallback color or unified char bars color | `string` | `undefined` | | fill | use this character to fill remaining chart bar space | `string` | `undefined` | | scale | values are scaled proportionate to this value. otherwise the max will be calculated from the provided data. | `number` or `string` | `auto` | | width | width of chart | `number` | `100` | | height | height of chart | `number` | `10` | | padding | padding between bars | `number` | `0` | | barSize | size of each bar | `number` | `1` | | title | chart title | `string` | `undefined` | | char | use this character to draw the chart bars | `string` | `█` | | orientation | horizontal or vertical | `string` | `horizontal` | ``` -------------------------------- ### Customize Characters and Fill Source: https://context7.com/tool3/chartscii/llms.txt Applies custom Unicode or emoji characters for bar and fill styling. ```typescript import Chartscii from 'chartscii'; // Using emoji characters const emojiChart = new Chartscii([3, 6, 9, 12], { char: '🔥', fill: '❄️', width: 20, colorLabels: true }); console.log(emojiChart.create()); // Using Unicode block characters const blockChart = new Chartscii([5, 10, 15, 20], { char: '▓', // Filled block fill: '░', // Light block for remaining space color: 'cyan', width: 40 }); console.log(blockChart.create()); ``` -------------------------------- ### Implement Conditional Coloring Source: https://context7.com/tool3/chartscii/llms.txt Dynamically assigns colors to bars based on threshold logic. ```typescript import Chartscii from 'chartscii'; const metrics = []; const threshold = 5; for (let i = 0; i < 10; i++) { const value = Math.floor(Math.random() * 10) + 1; const isAboveThreshold = value > threshold; metrics.push({ value, label: isAboveThreshold ? '✓' : '✗', color: isAboveThreshold ? 'green' : 'red' }); } const chart = new Chartscii(metrics, { title: 'Threshold Analysis', colorLabels: true, width: 60, char: '■' }); console.log(chart.create()); ``` -------------------------------- ### Chartscii with ChartPoint Input Format Source: https://context7.com/tool3/chartscii/llms.txt Utilizes the ChartPoint input format for per-bar customization, allowing individual specification of label, value, and color for each data point. This provides enhanced flexibility in chart design. ```typescript import Chartscii from 'chartscii'; const data = [ { label: 'January', value: 120, color: 'blue' }, { label: 'February', value: 85, color: 'cyan' }, { label: 'March', value: 200, color: 'green' }, { label: 'April', value: 150, color: 'yellow' } ]; const chart = new Chartscii(data, { title: 'Monthly Revenue', colorLabels: true, valueLabels: true, width: 60 }); console.log(chart.create()); ``` -------------------------------- ### Generate Vertical Bar Chart Source: https://context7.com/tool3/chartscii/llms.txt Creates a vertical bar chart by setting the 'orientation' option to 'vertical'. This configuration displays bars growing upwards with labels positioned at the bottom. ```typescript import Chartscii from 'chartscii'; const data = [ { value: 8, color: 'red', label: 'Mon' }, { value: 12, color: 'green', label: 'Tue' }, { value: 6, color: 'blue', label: 'Wed' }, { value: 15, color: 'yellow', label: 'Thu' }, { value: 10, color: 'purple', label: 'Fri' } ]; const chart = new Chartscii(data, { title: 'Weekly Activity', orientation: 'vertical', width: 50, height: 10, barSize: 2, padding: 2, colorLabels: true, theme: 'pastel' }); console.log(chart.create()); ``` -------------------------------- ### Customize Chart Structure Characters Source: https://context7.com/tool3/chartscii/llms.txt Define custom characters for chart borders and axes using the 'structure' option. This allows for unique visual styling of terminal charts. Ensure the characters are supported by your terminal's font. ```typescript import Chartscii from 'chartscii'; const data = [10, 20, 30, 40, 50]; const chart = new Chartscii(data, { title: 'Custom Borders', color: 'cyan', width: 40, structure: { x: '─', y: '┤', axis: '│', topLeft: '┌', bottomLeft: '└' } }); console.log(chart.create()); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.