razorness / vue3-calendar-heatmap

A lightweight calendar heatmap Vue 3 component built on SVG, inspired by julienr114's vue-calendar-heatmap and github's contribution calendar graph
https://razorness.github.io/vue3-calendar-heatmap
MIT License
90 stars 18 forks source link

TypeError: Cannot read properties of undefined (reading 'map') #18

Closed t170815518 closed 1 year ago

t170815518 commented 1 year ago

I am pretty new to Vue, and when I followed the instructions to import the component locally:

<template>
<CalendarHeatmap></CalendarHeatmap>
</template>
import { CalendarHeatmap } from 'vue3-calendar-heatmap'
export default {
    components: {
        CalendarHeatmap
    },
    // ...
}

I got the error Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'map')?

Thank you for the help in advance :)

razorness commented 1 year ago

Your SFC structure should look like this:

<template>
   // your template stuff
   <CalendarHeatmap></CalendarHeatmap>
</template>

<script>
import { CalendarHeatmap } from 'vue3-calendar-heatmap'
export default {
    components: {
        CalendarHeatmap
    },
    // ...
}
</script>

May that's your error. Further more you need to add required informations:

A fully working erxample can be found here: https://github.com/razorness/vue3-calendar-heatmap/blob/master/docs/.vuepress/components/Demo.vue

And here: https://github.com/razorness/vue3-calendar-heatmap/blob/master/src/App.vue

You can clone this repository and play with the dev environment which runs App.vue to get a better understanding:

git clone https://github.com/razorness/vue3-calendar-heatmap.git
cd vue3-calendar-heatmap
yarn
yarn dev
t170815518 commented 1 year ago

Thank you very much for the help, @razorness, I missed the required parameters like values and endDate as you pointed out.

After adding them, the heatmap can be displayed properly. :)