npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@avoraui/av-chart-js

v0.0.1

Published

A customizable Angular Chart.js component

Readme

AvChartJs Component (AvoraUI)

A customizable Angular Chart.js component that supports various chart types with advanced features like dual Y-axes, tooltips, and PDF export. This component is built with Angular Material and integrates seamlessly with reactive forms.

Features

  • Multiple Chart Types: Supports pie, bar, doughnut, line, radar, polarArea, bubble, and scatter charts
  • Customizable Tooltips: Configurable tooltips with currency formatting and percentage calculations
  • Dual Y-Axis Support: Allows two Y-axes for complex datasets
  • PDF Export: Export charts as PDF with high-quality rendering
  • Responsive Design: Adjustable responsiveness and aspect ratio
  • Material Design: Built with Angular Material components
  • Dynamic Updates: Updates chart data and configuration dynamically

Dependencies

This component requires the following Angular Material modules:

import { MatCard, MatCardContent, MatCardHeader, MatCardTitle } from '@angular/material/card';
import { MatButton } from '@angular/material/button';
import { MatIcon } from '@angular/material/icon';

External libraries:

  • Chart.js (via CDN: https://cdn.jsdelivr.net/npm/chart.js)
  • html2canvas (^1.4.1)
  • jspdf (^3.0.1)

Installation

  1. Ensure you have Angular Material installed in your project
  2. Include Chart.js in your index.html:
    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
  3. Install dependencies:
    npm install html2canvas@^1.4.1 jspdf@^3.0.1
  4. Import the component in your module or use it directly (standalone component)

Usage

Basic Usage

<av-chart-js
  chartTitle="Title"
  [show_print_button]="true"
  [chartType]="'pie'"
  [data]="[12, 15, 20, 25, 30]"
  [labels]="['Admins', 'Teachers', 'Students', 'Clark', 'Supporters']"
  [legend]="'left'"
  [responsive]="true">
</av-chart-js>

Advanced Usage

// Component
export class MyComponent {
  bookingsDatasets: ChartDataset[] = [
    {
      label: 'Bookings',
      data: [45, 78, 66, 89, 92, 110, 98],
      borderColor: '#4c6ef5',
      backgroundColor: 'rgba(76, 110, 245, 0.1)',
      borderWidth: 3,
      tension: 0.3,
      fill: true
    },
    {
      label: 'Revenue ($)',
      data: [8500, 14200, 12400, 16800, 17500, 20800, 19200],
      borderColor: '#10b981',
      backgroundColor: 'rgba(16, 185, 129, 0.1)',
      borderWidth: 3,
      tension: 0.3,
      fill: true,
      yAxisID: 'y1'
    }
  ];

  labels = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul'];
}
<!-- Template -->
<av-chart-js
  chartTitle="Title"
  [show_print_button]="true"
  [chartType]="'line'"
  [labels]="labels"
  [datasets]="bookingsDatasets"
  [legend]="'top'"
  [dualYAxis]="true"
  [maintainAspectRatio]="false">
</av-chart-js>

Input Properties

| Property | Type | Required | Default | Description | |----------|------|----------|---------|-------------| | chartType | ChartType | No | 'bar' | Type of chart to render | | chartTitle | string | No | '' | Title of the chart | | show_print_button | boolean | No | false | Whether to show the print button | | data | number[] | No | undefined | Data array for single dataset | | backgroundColor | string[] | No | undefined | Background colors for data | | borderColor | string[] | No | undefined | Border colors for data | | borderWidth | number | No | 1 | Width of data borders | | borderRadius | number | No | 0 | Radius for bar chart corners | | toolTipOptions | any | No | {...} | Custom tooltip configuration | | datasets | ChartDataset[] | No | undefined | Array of dataset objects | | labels | string[] | Yes | undefined | Labels for the chart data | | X_Axis_title | AxisTitles | No | undefined | Title and font size for X-axis | | Y_Axis_title | AxisTitles | No | undefined | Title and font size for Y-axis | | legend | Legend | No | 'top' | Position of the legend | | responsive | boolean | No | true | Whether the chart is responsive | | beginAtZero | boolean | No | true | Whether Y-axis starts at zero | | maintainAspectRatio | boolean | No | false | Whether to maintain aspect ratio | | cutout | string | No | undefined | Cutout percentage for doughnut charts | | dualYAxis | boolean | No | false | Enable dual Y-axes | | Y1_Axis_title | AxisTitles | No | undefined | Title and font size for second Y-axis |

Component Behavior

Chart Rendering

  • Renders the specified chart type with provided data and labels
  • Supports dynamic updates when inputs change

Tooltip Customization

  • Displays tooltips with formatted numbers and percentages
  • Customizable via toolTipOptions input

Print Functionality

  • Exports the chart as a PDF when the print button is clicked
  • Uses html2canvas and jsPDF for high-quality rendering

Form Integration

The component can be integrated with forms, though it primarily serves as a display component.

Data Format

Input:

  • data: Array of numbers for a single dataset
  • datasets: Array of ChartDataset objects for multiple datasets
  • labels: Array of strings for chart labels

Output: No direct output; chart is rendered visually.

Error Handling

The component includes error handling for:

  • Missing labels or data/datasets (logs error and prevents rendering)
  • PDF generation errors (logs error to console)

Memory Management

The component automatically:

  • Destroys the previous chart instance before redrawing
  • Manages canvas references via ViewChild

Styling

The component uses CSS classes that can be customized:

  • .chart-card - Main card container
  • .header-container - Header section
  • .centered-title - Chart title styling
  • .chart-card-content - Chart content area

Browser Compatibility

This component uses modern browser APIs:

  • Chart.js for charting
  • html2canvas and jsPDF for PDF export

Ensure your target browsers support these libraries or include appropriate polyfills.

Requirements

  • Angular 17+
  • Angular Material
  • Chart.js (via CDN)
  • html2canvas (^1.4.1)
  • jspdf (^3.0.1)

Browser Support

  • Chrome/Edge 57+
  • Firefox 52+
  • Safari 10.1+

License

This project is licensed under the MIT License - see the LICENSE file for details.

Changelog

v0.0.1

  • Initial release
  • Basic chart rendering with multiple types
  • Tooltip and legend customization
  • PDF export functionality
  • Material design integration