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

ng-git-calendar

v0.1.8

Published

ng-git-calendar is an angular interface component that implements a committing calendar similar to that of github, which can be used for various uses, such as fault logging and other records like any other calendar.

Downloads

10

Readme

NgGitCalendar

ng-git-calendar is an angular interface component that implements a committing calendar similar to that of github, which can be used for various uses, such as fault logging and other records like any other calendar.

This component is a Ui component containing css, html, js / ts files. There is no functionality linked to the github website here.

Getting Started

To start with ng-git-calendar, you can download it with the command :

npm install ng-git-calendar

Or clone git repository: ​

git clone https://github.com/SergioNoivak/ng-git-calendar

Or download *.zip file in git repo :octopus:

https://github.com/SergioNoivak/ng-git-calendar

Usage

To use ng-git-calendar you need to import the NgGitCalendarModule into your application:

// app.module.ts

import { AppComponent } from './app.component';
import { NgGitCalendarModule } from '../../../ng-git-calendar/src/lib/ng-git-calendar.module';


@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
	// ... another import
      
    NgGitCalendarModule  

  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

After that, just use the tag lib-ng-git-calendar to render the ng-git-calendar graph :

<p>
    Oww cool!
</p>

<lib-ng-git-calendar
 year="2020"
 colorLevel1="#c6e48b"
 colorLevel2="#7bc96f"
 colorLevel3="#196127"
 [data]="data"
    ></lib-ng-git-calendar>

The data attribute represents the days that will be marked with some color / level. This data attribute consists of a two-dimensional vector in which each line contains a vector with two elements, the first element being the date to be marked in the format mm / dd / yyyy followed by the level to be marked (can be 1,2 or 3) .

import { Component } from '@angular/core';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})
export class AppComponent {
    
    /*
    
    mm / dd / yyyy , level
    	
    */
  data=[
    ['01/21/2020','1'],
    ['06/20/2020','2'],
    ['12/25/2020','3'],
    ['11/05/2020','3'],

  ]

constructor(){}
}

In this last example, relatively small data was entered, resulting in the following git-calendar:

The section below builds a more complex example of a random git-calendar.

More complex example: Github random commits

In this example, the data attribute will be generated randomly and will produce a graph of commits

<!-- app.component.html -->

<p>
    Git random colors
</p>

<lib-ng-git-calendar
 year="2020"
 colorLevel1="#c6e48b"
 colorLevel2="#7bc96f"
 colorLevel3="#196127"
 [data]="data"
    ></lib-ng-git-calendar>

To define attribute data, just click on any component, in matrix format, each data row is a vector of specified data once selected level

import { Component } from '@angular/core';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})
export class AppComponent {
  title = 'aplicacao-teste';

  data = []
  format(data){
    var
        dia  = data.getDate().toString(),
        diaF = (dia.length == 1) ? '0'+dia : dia,
        mes  = (data.getMonth()+1).toString(), //+1 pois no getMonth Janeiro começa com zero.
        mesF = (mes.length == 1) ? '0'+mes : mes,
        anoF = data.getFullYear();
    return mesF+"/"+diaF+"/"+anoF;
}


constructor(){

  this.generateData()

}

   generateData(){


    let start = new Date("01/01/"+('2020'));
    let end = new Date("12/31/"+('2020'));

    let listaDiv:HTMLElement = document.getElementById('squares')
    console.log(listaDiv)
    let loop = new Date(start);
    while(loop <= end){
      //  console.log(loop);
       let stringData = this.format(loop)
        this.data.push([stringData,""+this.getRandom()])
       var newDate = loop.setDate(loop.getDate() + 1);
       loop = new Date(newDate);
    }


   }

   getRandom(){
    let rand=Math.random()
    console.log(rand)
    if(rand<0.3)
      return 0;

      if(rand>0.3&&rand<0.5)
      return 1;


      if(rand>0.5&&rand<0.75)
      return 2;


      if(rand>0.75)
      return 3;

}
}

Graph attributes

To render the chart ng-git-calendar, you need: the year attribute that represents the year that the calendar will represent, and the colorLevel1, colorLevel2, colorLevel3 attributes represents the three possible levels for each day of the calendar. It is only possible to have three levels and colors, if the variables colorLevel1, colorLevel2, colorLevel3, the chart is assumed to be gray with level 0.

The data attribute represents the days that will be marked with some color / level. This data attribute consists of a two-dimensional vector in which each line contains a vector with two elements, the first element being the date to be marked in the format mm / dd / yyyy followed by the level to be marked (can be 1,2 or 3) .

Contact-me

[email protected]