Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions public/_locales/ca/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
},
"account": "Compte",
"accountEmpty": "Aquest compte està buit, no hi ha cap correu electrònic.",
"addressCopied": "Copiat al porta-retalls",
"allAccounts": "Tots els comptes",
"charts": {
"contactsJunk": {
Expand Down
1 change: 1 addition & 0 deletions public/_locales/cs/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
},
"account": "Účet",
"accountEmpty": "Tento účet je prázdný, nejsou tu žádné e-maily.",
"addressCopied": "Zkopírováno do schránky",
"allAccounts": "Všechny účty",
"charts": {
"contactsJunk": {
Expand Down
1 change: 1 addition & 0 deletions public/_locales/de/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
},
"account": "Konto",
"accountEmpty": "Dieses Konto ist leer und enthält keine E-Mails.",
"addressCopied": "In die Zwischenablage kopiert",
"allAccounts": "Alle Konten",
"charts": {
"contactsJunk": {
Expand Down
1 change: 1 addition & 0 deletions public/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
},
"account": "Account",
"accountEmpty": "This account is empty, no emails here.",
"addressCopied": "Copied to clipboard",
"allAccounts": "All Accounts",
"charts": {
"contactsJunk": {
Expand Down
1 change: 1 addition & 0 deletions public/_locales/es/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
},
"account": "Cuenta",
"accountEmpty": "Esta cuenta está vacía, aquí no hay correos.",
"addressCopied": "Copiado al portapapeles",
"allAccounts": "Todas las cuentas",
"charts": {
"contactsJunk": {
Expand Down
1 change: 1 addition & 0 deletions public/_locales/fi/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
},
"account": "Tili",
"accountEmpty": "Tämä tili on tyhjä, sillä ei ole sähköposteja.",
"addressCopied": "Kopioitu leikepöydälle",
"allAccounts": "Kaikki tilit",
"charts": {
"contactsJunk": {
Expand Down
1 change: 1 addition & 0 deletions public/_locales/fr/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
},
"account": "Compte",
"accountEmpty": "Ce compte est vide, il n'y a pas d'emails.",
"addressCopied": "Copié dans le presse-papiers",
"allAccounts": "Tous les comptes",
"charts": {
"contactsJunk": {
Expand Down
1 change: 1 addition & 0 deletions public/_locales/gl/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
},
"account": "Conta",
"accountEmpty": "Esta conta non ten ningún correo.",
"addressCopied": "Copiado ao portapapeis",
"allAccounts": "Todas as contas",
"charts": {
"contactsJunk": {
Expand Down
1 change: 1 addition & 0 deletions public/_locales/hi/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
},
"account": "खाता",
"accountEmpty": "इस खाते में कोई मेल नहीं है।",
"addressCopied": "क्लिपबोर्ड पर कॉपी किया गया",
"allAccounts": "सभी खाते",
"charts": {
"contactsJunk": {
Expand Down
1 change: 1 addition & 0 deletions public/_locales/hu/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
},
"account": "Fiók",
"accountEmpty": "Ez a postafiók üres, itt nincsenek levelek.",
"addressCopied": "Vágólapra másolva",
"allAccounts": "Minden postafiók",
"charts": {
"contactsJunk": {
Expand Down
1 change: 1 addition & 0 deletions public/_locales/id/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
},
"account": "Akun",
"accountEmpty": "Akun ini kosong, tidak ada email di sini.",
"addressCopied": "Disalin ke clipboard",
"allAccounts": "Semua Akun",
"charts": {
"contactsJunk": {
Expand Down
1 change: 1 addition & 0 deletions public/_locales/it/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
},
"account": "Conto",
"accountEmpty": "Questo account è vuoto, non ci sono email qui.",
"addressCopied": "Copiato negli appunti",
"allAccounts": "Tutti i account",
"charts": {
"contactsJunk": {
Expand Down
1 change: 1 addition & 0 deletions public/_locales/ja/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
},
"account": "アカウント",
"accountEmpty": "このアカウントにはメールはありません。",
"addressCopied": "クリップボードにコピーしました",
"allAccounts": "すべてのアカウント",
"charts": {
"contactsJunk": {
Expand Down
1 change: 1 addition & 0 deletions public/_locales/nl/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
},
"account": "Rekening",
"accountEmpty": "Deze rekening is leeg, geen e-mails hier.",
"addressCopied": "Gekopieerd naar klembord",
"allAccounts": "Alle Rekeningen",
"charts": {
"contactsJunk": {
Expand Down
1 change: 1 addition & 0 deletions public/_locales/pl/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
},
"account": "Konto",
"accountEmpty": "To konto jest puste, nie ma żadnych e-maili.",
"addressCopied": "Skopiowano do schowka",
"allAccounts": "Wszystkie konta",
"charts": {
"contactsJunk": {
Expand Down
1 change: 1 addition & 0 deletions public/_locales/pt-BR/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
},
"account": "Conta",
"accountEmpty": "Esta conta está vazia, sem e-mails por aqui.",
"addressCopied": "Copiado para a área de transferência",
"allAccounts": "Todas as Contas",
"charts": {
"contactsJunk": {
Expand Down
1 change: 1 addition & 0 deletions public/_locales/pt/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
},
"account": "Conta",
"accountEmpty": "Essa conta está vazia, sem e-mails aqui.",
"addressCopied": "Copiado para a área de transferência",
"allAccounts": "Todas as contas",
"charts": {
"contactsJunk": {
Expand Down
1 change: 1 addition & 0 deletions public/_locales/ru/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
},
"account": "Аккаунт",
"accountEmpty": "Пустой аккаунт, писем нет.",
"addressCopied": "Скопировано в буфер обмена",
"allAccounts": "Все Аккаунты",
"charts": {
"contactsJunk": {
Expand Down
1 change: 1 addition & 0 deletions public/_locales/sk/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
},
"account": "Účet",
"accountEmpty": "Tento účet je prázdny, nie sú tu žiadne emaily.",
"addressCopied": "Skopírované do schránky",
"allAccounts": "Všetky účty",
"charts": {
"contactsJunk": {
Expand Down
1 change: 1 addition & 0 deletions public/_locales/sv/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
},
"account": "Konto",
"accountEmpty": "Detta konto är tomt, inga mejl hittas.",
"addressCopied": "Kopierat till urklipp",
"allAccounts": "Alla Konton",
"charts": {
"contactsJunk": {
Expand Down
1 change: 1 addition & 0 deletions public/_locales/th/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
},
"account": "บัญชีผู้ใช้",
"accountEmpty": "บัญชีนี้ว่างเปล่า ไม่พบอีเมล",
"addressCopied": "คัดลอกไปยังคลิปบอร์ดแล้ว",
"allAccounts": "บัญชีผู้ใช้ทั้งหมด",
"charts": {
"contactsJunk": {
Expand Down
1 change: 1 addition & 0 deletions public/_locales/tr/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
},
"account": "Hesap",
"accountEmpty": "Bu hesap boş, e-posta yok.",
"addressCopied": "Panoya kopyalandı",
"allAccounts": "Tüm hesaplar",
"charts": {
"contactsJunk": {
Expand Down
1 change: 1 addition & 0 deletions public/_locales/uk/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
},
"account": "Обліковий запис",
"accountEmpty": "Цей обліковий запис не містить електронних листів.",
"addressCopied": "Скопійовано в буфер обміну",
"allAccounts": "Усі облікові записи",
"charts": {
"contactsJunk": {
Expand Down
1 change: 1 addition & 0 deletions public/_locales/uz/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
},
"account": "Аккаунт",
"accountEmpty": "Бу аккаунт бўш, бу ерда електрон почта хабарлари йўқ.",
"addressCopied": "Vaqtinchalik xotiraga nusxalandi",
"allAccounts": "Барча Аккаунтлар",
"charts": {
"contactsJunk": {
Expand Down
1 change: 1 addition & 0 deletions public/_locales/zh-Hans-CN/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
},
"account": "账号",
"accountEmpty": "此账号为空,没有邮件。",
"addressCopied": "已复制到剪贴板",
"allAccounts": "所有帐户",
"charts": {
"contactsJunk": {
Expand Down
1 change: 1 addition & 0 deletions public/_locales/zh-Hant-TW/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
},
"account": "帳號",
"accountEmpty": "當前帳號為空,並沒有任何郵件。",
"addressCopied": "已複製到剪貼簿",
"allAccounts": "所有帳號",
"charts": {
"contactsJunk": {
Expand Down
55 changes: 54 additions & 1 deletion src/charts/BarChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,25 @@
<p v-if="description">{{ description }}</p>
<div class="chart-container">
<canvas :id="id"></canvas>
<div v-if="copiedFeedback" class="copy-feedback" :style="{ top: `${copiedFeedback.top}px` }">
{{ t('stats.addressCopied') }}
</div>
</div>
</div>
</template>

<script setup>
import { computed, onMounted, watch } from 'vue';
import { computed, onMounted, ref, watch } from 'vue';
import { useI18n } from 'vue-i18n';
import { Chart, transparentGradientBar } from '@/chart.config.js';

const { t } = useI18n();

let chart = null;
const id = Math.random().toString(36).substring(7);
// visible while a copied-address confirmation is shown, positioned next to the clicked bar
const copiedFeedback = ref(null);
let copiedFeedbackTimeout = null;

const props = defineProps({
title: String,
Expand Down Expand Up @@ -113,6 +122,37 @@ const draw = () => {
},
},
});
if (props.horizontal) {
chart.canvas.addEventListener('click', onBarClick);
chart.canvas.addEventListener('mousemove', onBarHover);
chart.canvas.addEventListener('mouseleave', resetCursor);
}
};

// finds the bar under/nearest a given mouse event, matching by row regardless of
// exact x position within it, so the whole row is a fair-sized click target
// (bars are never auto-skipped for space the way axis labels are, so unlike
// hit-testing against tick positions, every row stays reliably clickable)
const barElementAt = (nativeEvent) => {
const elements = chart.getElementsAtEventForMode(nativeEvent, 'index', { axis: 'y', intersect: false }, true);
return elements.length ? elements[0] : null;
};

const resetCursor = () => {
chart.canvas.style.cursor = '';
};

const onBarHover = (nativeEvent) => {
chart.canvas.style.cursor = barElementAt(nativeEvent) ? 'pointer' : '';
};

const onBarClick = (nativeEvent) => {
const hit = barElementAt(nativeEvent);
if (!hit) return;
navigator.clipboard.writeText(props.labels[hit.index]);
clearTimeout(copiedFeedbackTimeout);
copiedFeedback.value = { top: hit.element.y };
copiedFeedbackTimeout = setTimeout(() => (copiedFeedback.value = null), 1200);
};

onMounted(() => {
Expand Down Expand Up @@ -159,4 +199,17 @@ watch(
flex: 1 1 auto;
}
}

.copy-feedback {
position: absolute;
left: 0.5rem;
transform: translateY(-50%);
padding: 0.25rem 0.5rem;
border-radius: 3px;
font-size: 0.75rem;
white-space: nowrap;
pointer-events: none;
color: var(--color-white);
background: rgba(var(--color-black-rgb), 0.75);
}
</style>