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

@puzzleitc/ng-time-chart

v0.5.26

Published

A library to display durations in a horizontally scrolling calendar. Similar to a Gantt-chart.

Downloads

64

Readme

NgTimeChart

ng-time-chart is a library which can display durations in a calendar

  • Display durations in a horizontally scrolling calendar. Similar to a Gantt-chart.
  • Groups with no active dates in the selected time period are filtered out
  • Durations are part of groups and are displayed together
  • Durations can have 'active' days which are displayed in a darker color
  • Colors can be configured
  • Durations are clickable and the function can be passed into the component
  • The library displays the duration of an entire year
    • The year can be advanced and regressed
  • Library location: projects/ng-time-chart directory of this repository
  • It is developed using Angular >=6.0.0 and its newly introduced ng g library schematics.

Examples/Demo

  • A simple Example can be found under projects/ng-time-chart-showase directory of this repository.
  • The example is deployed: Demo Link

Installation

npm i @puzzleitc/ng-time-chart

Usage

1. Register the NgTimeChartModule

import { NgTimeChartModule } from 'ng-time-chart';

2. Use the component (ng-time-chart) in your component.

2.1 create a group

new Group(
        'Group 0',
        [
          {
            name: 'Timeframe with 4 active days and color set',
            startTime: DateTime.fromISO('2019-02-12'),
            endTime: DateTime.fromISO('2019-05-23'),
            class: 'my-class-a',
            dates: [
              DateTime.fromISO('2019-03-18'),
              DateTime.fromISO('2019-03-19'),
              DateTime.fromISO('2019-03-23'),
              DateTime.fromISO('2019-03-24')
            ]
          },
          {
            name: 'Timeframe in default color',
            startTime: DateTime.fromISO('2018-12-11'),
            endTime: DateTime.fromISO('2019-03-02')
          }
        ],
        () => console.log('clicked'),
      )

2.2 Pick a layout strategy The items within a group can be laid out using two different methods:

  • Stacked: Items in a group are stacked in the order that they are in the group. Every item has its own row.

stacked layout

  • Tiled: If possible, items of a group are displayed in the same row. This does not preserve the order of the items in the group but saves on space.

tiled layout

Select the appropriate LayoutStrategy by either passing LayoutStrategy.Stacked or LayoutStrategy.Tiled to ng-time-chart.

public layoutStrategy: LayoutStrategy = LayoutStrategy.Tiled

2.3 Add HTML Code

<ng-time-chart [groups]="groups" [layoutStrategy]="layoutStrategy">

</ng-time-chart>

ng-time-chart takes all the available space from the parent element. If wrapped in a smaller element vertical and horizontal scrolling is available

2.4 Add scss style

In your styles.scss, add the style definition for the classes you have added in the item. In this case it is my-calss-a

.my-class-a {
  border-color: #CB561E;
  background-color: lighten(#CB561E, 35%);

  .blockade-day {
    background-color: #CB561E;
  }
}

3. The visible period can be configured by setting endDate and startDate.

If the values are changed the calendar will be redrawn. If a date is set, switching years is disabled.

  startDate = DateTime.fromISO('2019-10-10');
  endDate = DateTime.fromISO('2020-03-10');
<ng-time-chart [groups]="groups" [startDate]="startDate" [endDate]="endDate">

</ng-time-chart>

Data model

documentation/data-model.png

Group

This is a grouping of several items.

  • name: The name of the group as displayed in the chart
  • duration: The calculated duration of the whole group. It is automatically calculated as the difference between the earliest start time and the latest end time of all items passed to the constructor.
  • items: The items belonging to the group.
  • onClick: The optional action to execute when the user clicks on the group.

Item

This represents a bar in the time chart.

  • name: The name of the item.
  • startTime: The start date of the item. This is represented in Luxon
  • endTime: The end date of the item.
  • class: The optional css-class of the item.
  • onClick: The optional action to take when the user clicks the item in the chart.
  • details: Additional information for the item. These are displayed when the mouse hovers over the item in the calendar.

Known Issues

  • Warning: Type LayoutStrategy is not assignable to type LayoutStrategy This is a warning displayed by IntelliJ. We have no idea why this is happening. It does not seem to cause any actual problems in code however.