1.0.1 • Published 9 months ago

@lgv/calendar v1.0.1

Weekly downloads
-
License
MIT
Repository
gitlab
Last release
9 months ago

Calendar

ES6 d3.js calendar visualization.

Install

# install package
npm install @lgv/calendar

Data Format

The following values are the expected input data structure; id can be omitted.

[
    {
        "id": 1,
        "date_start": "2024-01-01",
        "date_end": "2024-01-02",
        "event_title": "Event A"
    },
    {
        "id": 2,
        "date_start": "2024-01-01",
        "date_end": "2024-01-01",
        "event_title": "Event B"
    },
]

Use Module

import { Calendar } from "@lgv/calendar";

// have some data
let data = [
    {
        "id": 1,
        "date_start": "2024-01-01",
        "date_end": "2024-01-02",
        "event_title": "Event A"
    },
    {
        "id": 2,
        "date_start": "2024-01-01",
        "date_end": "2024-01-01",
        "event_title": "Event B"
    },
];

// initialize
const b = new Calendar(data);

// render visualization
b.render(document.body);

Environment Variables

The following values can be set via environment or passed into the class.

NameTypeDescription
LGV_HEIGHTintegerheight of artboard
LGV_WIDTHintegerwidth of artboard

Events

The following events are dispatched from the svg element. Hover events toggle a class named active on the element.

TargetNameEvent
date digitday-clickon click
date digitday-mouseoveron hover
date digitday-mousemouton un-hover
event barevent-clickon click
event barevent-mouseoveron hover
event barevent-mousemouton un-hover
month namemonth-changeon click
more textmore-clickon click
more textmore-mouseoveron hover
more textmore-mousemouton un-hover

Style

Style is expected to be addressed via css. Any style not met by the visualization module is expected to be added by the importing component.

ClassElement
lgv-celldiv element
lgv-cell-headerdiv element element
lgv-dayh1 element
lgv-dowdiv element holding all column elements
lgv-eventdiv element
lgv-event-griddiv element holding all event divs for a given cell
lgv-morep element indicating more events for a given cell
lgv-statp element indicating total event count for a given day
lgv-weekdayp element for individual column label

Actively Develop

# clone repository
git clone <repo_url>

# update directory context
cd calendar

# run docker container
docker run \
  --rm \
  -it  \
  -v $(pwd):/project \
  -w /project \
  -p 8080:8080 \
  node \
  bash

# FROM INSIDE RUNNING CONTAINER

# install module
npm install .

# run development server
npm run start

# edit src/index.js
# add const c = new Calendar(data);
# add c.render(document.body);
# replace `data` with whatever data you want to develop with

# view visualization in browser at http://localhost:8080
1.0.1

9 months ago

1.0.0

10 months ago

0.0.3

1 year ago

0.0.2

2 years ago

0.0.1

2 years ago