Client - add missing translations on chart + message when no workouts

This commit is contained in:
Sam
2021-09-21 08:51:07 +02:00
parent 795599ad46
commit 5dadbee29c
12 changed files with 117 additions and 43 deletions

View File

@ -9,6 +9,7 @@
import ChartDataLabels from 'chartjs-plugin-datalabels'
import { ComputedRef, PropType, computed, defineComponent } from 'vue'
import { BarChart, useBarChart } from 'vue-chart-3'
import { useI18n } from 'vue-i18n'
import { IStatisticsChartDataset, TDatasetKeys } from '@/types/statistics'
import { formatTooltipValue } from '@/utils/tooltip'
@ -36,6 +37,7 @@
},
},
setup(props) {
const { t } = useI18n()
// eslint-disable-next-line
function getNumber(value: any): number {
return isNaN(value) ? 0 : +value
@ -103,7 +105,7 @@
},
callbacks: {
label: function (context) {
let label = context.dataset.label || ''
let label = t(`sports.${context.dataset.label}.LABEL`) || ''
if (label) {
label += ': '
}
@ -120,7 +122,10 @@
tooltipItems.map((tooltipItem) => {
sum += tooltipItem.parsed.y
})
return 'Total: ' + formatTooltipValue(props.displayedData, sum)
return (
`${t('statistics.TOTAL')}: ` +
formatTooltipValue(props.displayedData, sum)
)
},
},
},

View File

@ -8,7 +8,7 @@
</div>
</template>
<script lang="ts" scoped>
<script lang="ts">
import { ComputedRef, PropType, computed, defineComponent } from 'vue'
import Chart from '@/components/Common/StatsChart/Chart.vue'
@ -68,7 +68,7 @@
})
</script>
<style lang="scss">
<style lang="scss" scoped>
@import '~@/scss/base';
.stat-chart {
.chart {