-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create component for easily adding charts for single entities
- SingleEntityTitheChart.vue
- Loading branch information
1 parent
bc5116e
commit 219761d
Showing
3 changed files
with
106 additions
and
11 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
Tithe-Vue/src/components/Charts/SingleEntityTitheChart.vue
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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<script setup> | ||
import { computed, toRef, ref, watch } from "vue"; | ||
import LineChart from "@/components/Charts/LineChart.vue"; | ||
const props = defineProps({ | ||
data: { | ||
type: Array, | ||
default: () => [], | ||
}, | ||
}); | ||
const chartColors = { | ||
default: { | ||
primary: "#00D1B2", | ||
info: "#209CEE", | ||
danger: "#FF3860", | ||
}, | ||
}; | ||
const datasetObject = (color, titheAmounts) => { | ||
return { | ||
fill: false, | ||
borderColor: chartColors.default[color], | ||
borderWidth: 2, | ||
borderDash: [], | ||
borderDashOffset: 0.0, | ||
pointBackgroundColor: chartColors.default[color], | ||
pointBorderColor: "rgba(255,255,255,0)", | ||
pointHoverBackgroundColor: chartColors.default[color], | ||
pointBorderWidth: 20, | ||
pointHoverRadius: 4, | ||
pointHoverBorderWidth: 15, | ||
pointRadius: 4, | ||
data: titheAmounts, | ||
tension: 0.5, | ||
cubicInterpolationMode: "default", | ||
}; | ||
}; | ||
const chartData = computed(() => { | ||
return { | ||
labels: props.data.map((obj) => obj.timeStamp), | ||
datasets: [ | ||
datasetObject( | ||
"primary", | ||
props.data.map((obj) => obj.titheAmount) | ||
), | ||
], | ||
}; | ||
}); | ||
</script> | ||
|
||
<template> | ||
<div v-if="props.data"> | ||
<LineChart :data="chartData" class="h-96" /> | ||
</div> | ||
</template> |
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