Skip to content

Commit

Permalink
Improve tooltips
Browse files Browse the repository at this point in the history
  • Loading branch information
ajuvonen committed Dec 23, 2024
1 parent 8cec249 commit 7eb5b81
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
6 changes: 5 additions & 1 deletion src/assets/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,17 @@ body {
@apply outline-sky-500;
}

canvas {
image-rendering: pixelated;
}

.tippy-box {
@apply mx-2;
@apply bg-sky-950;
}

.tippy-content {
@apply p-2 text-sm;
@apply px-2 text-sm;
@apply text-slate-50;
}

Expand Down
1 change: 0 additions & 1 deletion src/components/charts/AllTimeCategoriesChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ const chartOptions = computed(() => {
callbacks: {
title: ([{label}]) => t(`categories.${label}`),
},
boxPadding: 5,
},
datalabels: {
...defaultOptions.plugins?.datalabels,
Expand Down
8 changes: 2 additions & 6 deletions src/components/charts/CategoryStatusChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const getFavorites = (category: Category) =>
props.favorites[category].map(([veggie, amount], index) => {
let translation = t(`veggies.${veggie}`);
translation = translation.charAt(0).toUpperCase() + translation.slice(1);
return t('categoryStatus.entry', [medalEmojis[index], translation, amount]).trim();
return t('categoryStatus.entry', [medalEmojis[index], translation, amount]);
});
const chartData = computed(() => {
Expand Down Expand Up @@ -73,11 +73,7 @@ const chartOptions = computed(() => {
...defaultOptions.plugins?.tooltip,
callbacks: {
title: ([{label}]) => t(`categories.${label}`),
label: props.totals
? ({formattedValue, label}) => {
return [formattedValue, ...getFavorites(label as Category)];
}
: undefined,
footer: props.totals ? ([{label}]) => [...getFavorites(label as Category)] : undefined,
},
},
datalabels: {
Expand Down
3 changes: 0 additions & 3 deletions src/components/charts/WeeklyAmountsChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ const chartOptions = computed(() => {
const defaultChartOptions = getChartOptions<'line'>(true, false);
return {
...defaultChartOptions,
plugins: {
...defaultChartOptions.plugins,
},
};
});
Expand Down
5 changes: 5 additions & 0 deletions src/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ export const getChartOptions = <T extends keyof ChartTypeRegistry>(
bodyFont: {
size: 14,
},
footerFont: {
size: 14,
weight: 'normal',
},
displayColors: false,
backgroundColor: COLORS.darkBlue,
bodyColor: COLORS.offWhite,
titleColor: COLORS.offWhite,
Expand Down

0 comments on commit 7eb5b81

Please sign in to comment.