-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from ChouquetteCorp/feature/stats-charts
feat: add stats bet section
- Loading branch information
Showing
12 changed files
with
227 additions
and
9 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<script setup lang="ts"> | ||
import chouquette from '@/assets/images/chouquette.png' | ||
defineProps<{ | ||
nbBet: number | ||
}>() | ||
</script> | ||
|
||
<template> | ||
<div class="bet-counter"> | ||
<div class="bet-counter__number"> | ||
<p>{{ nbBet }}</p> | ||
<img :src="chouquette" alt="unit" /> | ||
</div> | ||
<p>{{ $t('EventView.betToast.success.detail', nbBet) }}</p> | ||
</div> | ||
</template> | ||
|
||
<style lang="scss"> | ||
.bet-counter { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
&__number { | ||
display: flex; | ||
justify-content: flex-end; | ||
align-items: baseline; | ||
column-gap: 1rem; | ||
height: 8.5rem; | ||
p { | ||
vertical-align: text-bottom; | ||
font-size: 7rem; | ||
font-weight: 500; | ||
} | ||
img { | ||
height: 3.75rem; | ||
} | ||
} | ||
} | ||
</style> |
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,65 @@ | ||
<script setup lang="ts"> | ||
import Chart from 'primevue/chart' | ||
import { ref, onMounted, watch } from 'vue' | ||
import { colord } from 'colord' | ||
onMounted(() => { | ||
const documentStyle = getComputedStyle(document.body) | ||
colors.value = generateColorsVariant(documentStyle.getPropertyValue('--primary-color')) | ||
chartData.value = setChartData() | ||
}) | ||
interface Props { | ||
datas?: Record<string, number> | ||
} | ||
const props = defineProps<Props>() | ||
watch( | ||
() => props.datas, | ||
() => { | ||
chartData.value = setChartData() | ||
}, | ||
{ deep: true }, | ||
) | ||
const chartData = ref() | ||
const colors = ref<string[]>([]) | ||
const chartOptions = ref({ | ||
plugins: { | ||
legend: { | ||
labels: { | ||
usePointStyle: true, | ||
}, | ||
}, | ||
}, | ||
}) | ||
const generateColorsVariant = (colorHex: string, numberOfColors = 10) => { | ||
let color = colord(colorHex) | ||
const colors = [colorHex] | ||
for (let i = 0; i < numberOfColors; i++) { | ||
color = color.rotate(-30) | ||
colors.push(color.toHex()) | ||
} | ||
return colors | ||
} | ||
const setChartData = () => { | ||
return { | ||
datasets: [ | ||
{ | ||
data: props.datas ? Object.values(props.datas) : [], | ||
backgroundColor: colors.value, | ||
}, | ||
], | ||
labels: props.datas ? Object.keys(props.datas) : [], | ||
} | ||
} | ||
</script> | ||
|
||
<template> | ||
<Chart v-if="chartData" type="pie" :data="chartData" :options="chartOptions" /> | ||
</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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
create or replace function count_guess_for_event(eventid integer) | ||
RETURNS TABLE ( | ||
guess character varying, | ||
sum bigint | ||
) | ||
LANGUAGE plpgsql AS | ||
$func$ | ||
BEGIN | ||
return query | ||
SELECT b.guess, SUM(number) as sum | ||
from bets b | ||
where event_id = eventid | ||
group by b.guess; | ||
END | ||
$func$; |
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