-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
197de80
commit d97cbd5
Showing
4 changed files
with
161 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,91 @@ | ||
# vue-calendar-heatmap | ||
|
||
> work in progress | ||
<p align="center"> | ||
<img src="https://i.imgur.com/ntYYTKX.png" alt="Screenshot"/> | ||
</p> | ||
|
||
A calendar heatmap Vuejs component built on SVG, inspired by github's contribution calendar graph | ||
<p align="center"> | ||
<a href="https://www.npmjs.com/package/vue-calendar-heatmap"> | ||
<img src="https://img.shields.io/npm/v/vue-calendar-heatmap.svg"/> | ||
<img src="https://img.shields.io/npm/dm/vue-calendar-heatmap.svg"/> | ||
</a> | ||
<a href="https://vuejs.org/"> | ||
<img src="https://img.shields.io/badge/vue-2.x-brightgreen.svg"/> | ||
</a> | ||
</p> | ||
|
||
## props | ||
A lightweight calendar heatmap Vuejs component built on SVG, inspired by github's contribution calendar graph. With vertical mode, tooltip powered by [v-tooltip](https://github.com/Akryum/v-tooltip). | ||
|
||
| keys | Type | Required | Exemple | | ||
|---|---|---|---| | ||
| values `values` | Array of objects with `date` and `count` keys. `date` values can be a date parseable string, a millisecond timestamp, or a Date object. `count` value should be a number. | true | `:values="[{ date: '2018-9-22', count: 6 }, ...]"` | | ||
| endDate `end-date` | Can be a date parseable string, a millisecond timestamp, or a Date object. The calendar will start automatically one year before this date. | true | `endDate="2018-9-22"` | | ||
| colorRange `color-range` | A Array of 5 strings which represents the colors of the progression. The color at `colorRange[0]` will always represent the values for a `count: 0`. The others are automatically distributed over the maximum value of count, unless you specify `max` props. | false. Default value is equal to the example | `:range-color="['ebedf0', '#ebedf0', '#c0ddf9', '#73b3f3', '#3886e1', '#17459e']"` | ||
| max `max` | Any number which should be the max color | false | `:max="10"` | ||
| tooltip `tooltip` | Boolean for enabble/disable tooltip on square hover. `true` by default | false | `:tooltip="false"` | ||
| tooltipUnit `tooltip-unit` | String representing heatmap's unit of measure. His value is `"contributions"` by default. | false | `tooltip-unit="stars"` | ||
## Getting started | ||
|
||
1. Load Module | ||
``` shell | ||
npm insall --save vue-calendar-heatmap | ||
``` | ||
2. Import in your vuejs application | ||
``` javascript | ||
import CalendarHeatmap from 'vue-calendar-heatmap' | ||
|
||
// in a parent component script | ||
export default { | ||
components: { | ||
CalendarHeatmap | ||
}, | ||
|
||
data () { | ||
return { | ||
today: new Date(), | ||
values: [{ date: '2017-11-09', count: 1 }, { date: '2017-11-20', count: 1 }] | ||
} | ||
// ... | ||
} | ||
``` | ||
``` html | ||
<!-- in a parent component template --> | ||
<template> | ||
<div id="parent"> | ||
<calendar-heatmap :end-date="today" :values="values" /> | ||
</div> | ||
</template> | ||
``` | ||
## Availables props | ||
### **values** - `values` - required | ||
Array of objects with `date` and `count` keys. `date` values can be a date parseable string, a millisecond timestamp, or a Date object. `count` value should be a number. | ||
``` html | ||
<vue-calendar-heatmap :values="[{ date: '2018-9-22', count: 6 }, ...]" ... /> | ||
``` | ||
### **endDate** - `end-date` - required | ||
Can be a date parseable string, a millisecond timestamp, or a Date object. The calendar will start automatically one year before this date. | ||
``` html | ||
<vue-calendar-heatmap endDate="2018-9-22" ... /> | ||
``` | ||
### colorRange - `color-range` | ||
A Array of 5 strings which represents the colors of the progression. The color at `colorRange[0]` will always represent the values for a `count: 0`. The others are automatically distributed over the maximum value of count, unless you specify `max` props. Default value is equal to the example. | ||
``` html | ||
<vue-calendar-heatmap :range-color="['ebedf0', '#ebedf0', '#c0ddf9', '#73b3f3', '#3886e1', '#17459e']" ... /> | ||
``` | ||
### max - `max` | ||
Any number which should be the max color. | ||
``` html | ||
<vue-calendar-heatmap :max="10" ... /> | ||
``` | ||
### tooltip - `tooltip` | ||
Boolean for enabble/disable tooltip on square hover. `true` by default. | ||
``` html | ||
<vue-calendar-heatmap :tooltip="false" ... /> | ||
``` | ||
### tooltipUnit - `tooltip-unit` | ||
String representing heatmap's unit of measure. His value is `"contributions"` by default. | ||
``` html | ||
<vue-calendar-heatmap tooltip-unit="stars" ... /> | ||
``` | ||
### vertical - `vertical` | ||
Boolean to switch to vertical mode. `false` by default. | ||
``` html | ||
<vue-calendar-heatmap :vertical="true" ... /> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "vue-calendar-heatmap", | ||
"version": "0.5.2", | ||
"version": "0.6.0", | ||
"description": "A calendar heatmap Vuejs component built on SVG, inspired by github's contribution calendar graph", | ||
"author": "Julien Rabin <[email protected]>", | ||
"scripts": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters