@robinpath/chart
v0.1.1
Published
> Generate chart images (PNG/JPEG) using Chart.js. Supports bar, line, pie, doughnut, scatter, radar, polarArea, and bubble charts with auto-coloring and customizable titles, legends, and dimensions.
Downloads
209
Keywords
Readme
@robinpath/chart
Generate chart images (PNG/JPEG) using Chart.js. Supports bar, line, pie, doughnut, scatter, radar, polarArea, and bubble charts with auto-coloring and customizable titles, legends, and dimensions.
Why use this module?
The chart module lets you:
- Create a new chart (bar, line, pie, doughnut, scatter, radar, polarArea, bubble)
- Add a dataset to an existing chart
- Update chart options (title, size, legend, type, labels)
- Render chart and save to PNG or JPEG file
- Render chart and return as base64 data URL string
All functions are callable directly from RobinPath scripts with a simple, consistent API.
Installation
npm install @robinpath/chartQuick Start
No credentials needed — start using it right away:
chart.addDataset "c1" {"label": "Costs", "data": [50, 80]}Available Functions
| Function | Description |
|----------|-------------|
| chart.create | Create a new chart (bar, line, pie, doughnut, scatter, radar, polarArea, bubble) |
| chart.addDataset | Add a dataset to an existing chart |
| chart.update | Update chart options (title, size, legend, type, labels) |
| chart.save | Render chart and save to PNG or JPEG file |
| chart.toBase64 | Render chart and return as base64 data URL string |
| chart.toBuffer | Render chart and return as raw Buffer |
| chart.destroy | Remove chart from memory |
Examples
Add a dataset to an existing chart
chart.addDataset "c1" {"label": "Costs", "data": [50, 80]}Update chart options (title, size, legend, type, labels)
chart.update "c1" {"title": "Updated Title", "width": 1200}Render chart and save to PNG or JPEG file
chart.save "c1" "./output/chart.png"Integration with RobinPath
import { RobinPath } from "@wiredwp/robinpath";
import Module from "@robinpath/chart";
const rp = new RobinPath();
rp.registerModule(Module.name, Module.functions);
rp.registerModuleMeta(Module.name, Module.functionMetadata);
const result = await rp.executeScript(`
chart.addDataset "c1" {"label": "Costs", "data": [50, 80]}
`);Full API Reference
See MODULE.md for complete documentation including all parameters, return types, error handling, and advanced examples.
Related Modules
@robinpath/json— JSON module for complementary functionality
License
MIT
