1.0.2 • Published 1 year ago

active-calendar-chart v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

header

Active-Calendar-Chart

contribution calendar component like github (based on vue)

English | 简体中文

Install

npm install active-calendar-chart

Component Props

PropDescriptionTypeDefaultRequired
valuedatasource{[key:string]: { value: number; color: string}}{}No
text-aligntextAlignleft \| right \| centerleftNo
datedate valuenumber \| { start: string; end: string }undefinedNo
default-colorset grid default colorstring#ebedf0No
lessless textstringlessNo
moremore textstringmoreNo
colorscolor rangestring[][]No
gridset grid width and height{ width: string; height: string }{ width: '10px', height: '10px'}No
descriptionset chart descriptionstringundefinedNo

Component Slots

NameDescription
defaultcustomize default content.
first-gridcustomize first grid content.
monthcustomize month grid content.
weekcustomize week grid content.

Usage

Use component

Global Registration

import ActiveCalendarChart from 'active-calendar-chart'
app.use(ActiveCalendarChart)

Local Registration

<script setup>
  import ActiveCalendarChart from 'active-calendar-chart'
  // import { ActiveCalendarChart } from 'active-calendar-chart'
  const data = ref({
    '2023-04-05': {
      color: '#005dd6',
      value: 5.19,
    },
    '2023-04-04': {
      color: '#1e80ff',
      value: 5.19,
    },
    '2023-04-03': {
      color: '#1e80ff',
      value: 5.2,
    },
    //   ...
  })
</script>
<template>
  <!-- default -->
  <ActiveCalendarChart :value="data" />
  <!-- set year -->
  <ActiveCalendarChart :date="2022" :value="data" />
  <!-- set date range -->
  <ActiveCalendarChart
    :date="{ start: '2022-04-01', end: '2022-10-10' }"
    :value="data"
  />
</template>

Demo Preview

demo

Get generated data

Custom ui

// generate data
import { generateChartData } from 'active-calendar-chart'
// default
console.log(generateChartData())
// set year
console.log(generateChartData(2023))
// set date range
console.log(generateChartData('2022-04-01', '2022-10-08'))
1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago