Introduction
img-charts is a TypeScript library that provides a fluent API for managing ECharts visualizations. It allows you to create, update, and export charts with ease.
Features
- Fluent API for chart management
- Type-safe chart configurations
- Export charts as PNG, JPEG, SVG, or WebP
- Built-in performance logging
- Custom error handling
Usage
Create a Chart
const option: ChartOption = {
width: 1024,
height: 768,
// ...other ECharts options...
};
const img = document.querySelector('img#chart');
const chart = createChart(option);
img.src = chart.generateSvg(2);
Update a Chart
chart.update({
width: 1200,
// ...other ECharts options...
});
Export as Image
const blob = await createChartImage({
option,
type: 'png',
quality: 2,
});
Get Image URL
const imageUrl = await createChartImgSrc({
option,
type: 'jpeg',
quality: 2,
});
Installation
npm install https://github.com/jibbex/img-charts.git