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 🙏

© 2024 – Pkg Stats / Ryan Hefner

ngx-heatmap-calendar

v1.0.1

Published

A simple visualizer to display values by date, based on Github contribution history.

Downloads

26

Readme

Ngx Heatmap Calendar

This is a simple heatmap calendar component for Angular 17+.

Installation

npm install ngx-heatmap-calendar

[!WARNING] Be careful with the dates: if you use the dates in this way, new Date('2024-01-01') the result is one day before because of your timezone. but if yo set the date like this new Date(2024,0,1) the reslt is 2024-01-01T00:00:00.000 because the timezone is not considered and the day is correct. This library uses the date format set by your browser, and assumes that you are passing the correct day with the times in 00:00:00, so it can correctly match with the array of dates You can control by yourself the date format and the time, or you can use a library like date-fns or dayjs to handle the dates.

Inputs

| Input | Type | Required | Description | | -------------- | :-------------: | -------: | -----------------------------------------: | | startDate | Date | Yes | Start date for the calendar | | endDate | Date | Yes | End date for the calendar | | dates | HeatMapDate[] | No | Dates to be displayed on the calendar | | showMonthLabel | boolean | No | Show the month label on the calendar | | showDayLabel | boolean | No | Show the day label on the calendar | | rectSize | number | No | Size of the rectangle on the calendar | | gap | number | No | Gap between the rectangles on the calendar | | classForValue | Function | No | Function to return a class for the value |

Outputs

| Output | Type | Description | | ---------------- | --------------------------- | ---------------------------------- | | onClickCell | EventEmitter<HeatMapDate> | Emits when a cell is clicked | | onMouseEnterCell | EventEmitter<HeatMapDate> | Emits when the mouse enters a cell | | onMouseLeaveCell | EventEmitter<HeatMapDate> | Emits when the mouse leaves a cell |

Examples

Basic usage:

The ngx-heatmap-calendar needs a start and end date to display the calendar. With these inputs, the calendar will display each day with the time in 00:00:00.

startDate = new Date(2024, 0, 1);
endDate = new Date(2024, 11, 31);

<ngx-heatmap-calendar
  [startDate]="startDate"
  [endDate]="endDate"
/>

With dates:

startDate = new Date(2024, 0, 1);
endDate = new Date(2024, 11, 31);

dates: HeatMapDate[] = [
  { date: new Date(2024,0,1), value: 1 },
  { date: new Date(2024,0,2), value: 2 },
  { date: new Date(2024,0,4), value: 1 },
  { date: new Date(2024,0,5), value: 1 },
  { date: new Date(2024,0,8), value: 2 },
]

<ngx-heatmap-calendar
  [dates]="dates"
  [startDate]="startDate"
  [endDate]="endDate"
/>

With custom class for value:

startDate = new Date(2024, 0, 1);
endDate = new Date(2024, 11, 31);

callBackCssClass = ({ value }: HeatMapDate) => {
  if (value === 1) {
    return 'fill-value-1';
  }

  if (value === 2) {
    return 'fill-value-2';
  }

  return 'fill-empty';
};

dates: HeatMapDate[] = [
  { date: new Date(2024,0,1), value: 1 },
  { date: new Date(2024,0,2), value: 2 },
  { date: new Date(2024,0,4), value: 1 },
  { date: new Date(2024,0,5), value: 1 },
  { date: new Date(2024,0,8), value: 2 },
]

<ngx-heatmap-calendar
  [dates]="dates"
  [startDate]="startDate"
  [endDate]="endDate"
  [classForValue]="callBackCssClass"
/>