Skip to content

@synerity/charts is a modern, framework-agnostic chart library built with D3.js and Tailwind CSS. It provides enterprise-level data visualization capabilities with beautiful animations, extensive customization options, and comprehensive export functionality.

Notifications You must be signed in to change notification settings

synerity-ai/charts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

11 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

@synerity/charts

A comprehensive, framework-agnostic chart library built with D3 and Tailwind CSS. Supports multiple chart types with beautiful animations and export functionality.

πŸš€ Quick Start

Installation

npm install @synerity/charts

Basic Usage

<!DOCTYPE html>
<html>
<head>
  <script src="https://cdn.tailwindcss.com"></script>
</head>
<body>
  <div id="chart" class="w-full h-96"></div>
  
  <script type="module">
    import { BarChart } from '@synerity/charts';
    
    const data = [
      { label: 'Q1', value: 120 },
      { label: 'Q2', value: 180 },
      { label: 'Q3', value: 150 },
      { label: 'Q4', value: 220 }
    ];

    new BarChart({
      container: '#chart',
      data: data
    });
  </script>
</body>
</html>

πŸ“Š Chart Types

Bar Chart

import { BarChart } from '@synerity/charts';

new BarChart({
  container: '#bar-chart',
  data: [
    { label: 'Q1', value: 120, color: '#3B82F6' },
    { label: 'Q2', value: 180, color: '#10B981' }
  ],
  options: {
    animate: true,
    showValues: true,
    showGrid: true,
    barPadding: 0.1,
    borderRadius: 4
  }
});

Line Chart

import { LineChart } from '@synerity/charts';

new LineChart({
  container: '#line-chart',
  data: [
    { label: 'Jan', value: 65, color: '#3B82F6' },
    { label: 'Feb', value: 78, color: '#10B981' }
  ],
  options: {
    animate: true,
    showPoints: true,
    showGrid: true,
    curveType: 'monotoneX',
    strokeWidth: 2
  }
});

Pie Chart

import { PieChart } from '@synerity/charts';

new PieChart({
  container: '#pie-chart',
  data: [
    { label: 'Desktop', value: 45, color: '#3B82F6' },
    { label: 'Mobile', value: 35, color: '#10B981' }
  ],
  options: {
    animate: true,
    showLabels: true,
    showValues: true,
    innerRadius: 0,
    outerRadius: 150
  }
});

Scatter Plot

import { ScatterPlot } from '@synerity/charts';

new ScatterPlot({
  container: '#scatter-plot',
  data: [
    { x: 10, y: 20, label: 'Point 1', color: '#3B82F6' },
    { x: 20, y: 35, label: 'Point 2', color: '#10B981' }
  ],
  options: {
    animate: true,
    showGrid: true,
    showTrendLine: true,
    pointRadius: 6,
    pointOpacity: 0.7
  }
});

πŸ“€ Export Functionality

Export Manager

import { ExportManager } from '@synerity/charts';

const exportManager = new ExportManager(container);

// Export as PNG
const pngBlob = await exportManager.exportPNG({
  format: 'png',
  width: 800,
  height: 600,
  quality: 0.9
});

// Export as SVG
const svgString = await exportManager.exportSVG({
  format: 'svg',
  includeStyles: true
});

// Export as PDF (requires jsPDF)
const pdfBlob = await exportManager.exportPDF({
  format: 'pdf',
  title: 'Chart Export',
  author: 'Synerity Charts'
});

// Export data as CSV
const csvString = exportManager.exportCSV(data, 'chart-data.csv');

// Export data as JSON
const jsonString = exportManager.exportJSON(data, 'chart-data.json');

πŸ› οΈ Development

Build the Library

npm run build

Development Mode

npm run dev

Testing

npm test
npm run test:coverage

Demos

  • Open demo.html for basic bar chart demo
  • Open demo-all-charts.html for comprehensive demo with all chart types and export functionality

✨ Features

Chart Types

  • 🎯 Bar Charts: Animated bars with customizable styling
  • πŸ“ˆ Line Charts: Smooth curves with data points
  • πŸ₯§ Pie Charts: Interactive slices with labels
  • πŸ”΅ Scatter Plots: Data points with trend lines

Export Formats

  • πŸ–ΌοΈ PNG: High-resolution image export
  • 🎨 SVG: Vector graphics with embedded styles
  • πŸ“„ PDF: Document export with metadata
  • πŸ“Š CSV: Data export with headers
  • πŸ“‹ JSON: Structured data export

Core Features

  • 🎨 Beautiful Design: Tailwind CSS color palette
  • πŸ“Š Framework Agnostic: Works with any JavaScript framework
  • ⚑ Lightweight: Only depends on D3.js
  • 🎭 Customizable: Extensive options for styling
  • πŸ“± Responsive: Built-in responsive design
  • 🎯 TypeScript: Full TypeScript support
  • 🎬 Animations: Smooth transitions and effects
  • πŸ”„ Data Updates: Real-time data updates with proper cleanup

πŸ“š API Reference

Chart Configuration

interface ChartConfig {
  container: string | HTMLElement;
  data: ChartData[] | ScatterData[];
  options?: BarChartOptions | LineChartOptions | PieChartOptions | ScatterPlotOptions;
}

Data Types

interface ChartData {
  label: string;
  value: number;
  color?: string;
}

interface ScatterData {
  x: number;
  y: number;
  label?: string;
  color?: string;
}

Export Configuration

interface ExportConfig {
  format: 'png' | 'svg' | 'pdf';
  filename?: string;
  width?: number;
  height?: number;
  backgroundColor?: string;
  quality?: number;
}

🎯 Browser Support

  • Chrome 90+
  • Firefox 88+
  • Safari 14+
  • Edge 90+

πŸ“„ License

MIT License - see LICENSE file for details.

About

@synerity/charts is a modern, framework-agnostic chart library built with D3.js and Tailwind CSS. It provides enterprise-level data visualization capabilities with beautiful animations, extensive customization options, and comprehensive export functionality.

Resources

Stars

Watchers

Forks

Packages

No packages published