@@ -16,27 +16,26 @@ import {
1616 TransformComponent ,
1717} from ' echarts/components'
1818import VChart from ' vue-echarts'
19-
2019import type {
2120 BarSeriesOption ,
2221 EChartsOption ,
2322 EChartsType ,
2423} from ' echarts'
24+ import type { RewardsChartFilter } from ' ../chart/DashboardChartRewardsFilter.vue'
25+
2526import {
2627 getChartTextColor ,
2728 getChartTooltipBackgroundColor ,
2829 getRewardChartColors ,
2930 getRewardsChartLineColor ,
3031} from ' ~/utils/colors'
3132import type { GetValidatorDashboardRewardsChartResponse } from ' ~/types/api/validator_dashboard'
32- import type {
33- ChartData , ChartSeries ,
34- } from ' ~/types/api/common'
33+ import type { ChartSeries } from ' ~/types/api/common'
3534import { DashboardChartRewardsTooltip } from ' #components'
3635
37- const {
38- getTimestampFromEpoch ,
39- } = useNetworkStore ()
36+ const { filter } = defineProps <{
37+ filter : RewardsChartFilter ,
38+ }> ()
4039
4140use ([
4241 GridComponent ,
@@ -55,26 +54,33 @@ const {
5554 dashboardKey,
5655} = useDashboardKey ()
5756
58- const data = ref <ChartData <number , string > | undefined >()
59-
60- const { status } = useAsyncData (
57+ const {
58+ data,
59+ status,
60+ } = useAsyncData (
6161 ' validator_dashboard_rewards_chart' ,
6262 async () => {
6363 if (dashboardKey .value === undefined ) {
64- data .value = undefined
6564 return
6665 }
67- const res = await fetch <GetValidatorDashboardRewardsChartResponse >(
66+ return await fetch <GetValidatorDashboardRewardsChartResponse >(
6867 ' DASHBOARD_VALIDATOR_REWARDS_CHART' ,
69- undefined ,
68+ {
69+ query: {
70+ ... filter ,
71+ group_ids: filter .group_ids .join (' ,' ),
72+ },
73+ },
7074 { dashboardKey: dashboardKey .value },
7175 )
72- data .value = res .data
7376 },
7477 {
7578 immediate: true ,
7679 server: false ,
77- watch: [ dashboardKey ],
80+ watch: [
81+ dashboardKey ,
82+ filter ,
83+ ],
7884 },
7985)
8086
@@ -106,7 +112,7 @@ const {
106112 selectedCurrencyMain,
107113} = useCurrency ()
108114
109- const categoryCount = computed (() => data .value ?.categories ?.length ?? 0 )
115+ const categoryCount = computed (() => data .value ?.data . categories ?.length ?? 0 )
110116
111117const isGwei = ref (false )
112118
@@ -153,7 +159,7 @@ const autoFormatAmount = (values: string[], {
153159 return result
154160}
155161
156- const clSeries = computed (() => data .value ?.series ?.filter (series => series .property === ' cl' ) ?? [])
162+ const clSeries = computed (() => data .value ?.data . series ?.filter (series => series .property === ' cl' ) ?? [])
157163const clSeriesGroupTotal = computed (() => {
158164 let total = Array (categoryCount .value ).fill (' 0' )
159165 clSeries .value .forEach ((group ) => {
@@ -170,7 +176,7 @@ const clSeriesGroupTotal = computed(() => {
170176})
171177const clSeriesGroupTotalFormatted = computed (() => autoFormatAmount (clSeriesGroupTotal .value ))
172178
173- const elSeries = computed (() => data .value ?.series ?.filter (series => series .property === ' el' ) ?? [])
179+ const elSeries = computed (() => data .value ?.data . series ?.filter (series => series .property === ' el' ) ?? [])
174180const elSeriesGroupTotal = computed (() => {
175181 let total = Array (categoryCount .value ).fill (' 0' )
176182 elSeries .value .forEach ((group ) => {
@@ -230,7 +236,7 @@ type DataZoomEvent = {
230236 start: number ,
231237 type: ' datazoom' ,
232238}
233- const dataZoomStart = ref (60 )
239+ const dataZoomStart = ref (0 )
234240const dataZoomEnd = ref (100 )
235241// position of tooltip get's lost due to rerendering of `options` (> computed > currency recalculations > latest-state)
236242const onDatazoom = ({
@@ -318,8 +324,7 @@ const option = computed<EChartsOption>(() => {
318324 },
319325 end: dataZoomEnd .value ,
320326 labelFormatter : (_value : number , valueStr : string ) => {
321- const unixTimestamp = getTimestampFromEpoch (Number (valueStr ))
322- return getDateTime (unixTimestamp , { hasTime: false })
327+ return getDateTime (Number (valueStr ), { hasTime: false })
323328 },
324329 start: dataZoomStart .value ,
325330 type: ' slider' ,
@@ -360,10 +365,9 @@ const option = computed<EChartsOption>(() => {
360365 const paramsConsensusLayer = params .find (param => param .seriesId === seriesId .cl )
361366 const paramsExecutionLayer = params .find (param => param .seriesId === seriesId .el )
362367 const currentIndex = params [0 ].dataIndex
363- const currentTimestamp = getTimestampFromEpoch (Number (params [0 ].name ))
364368 const currentEpoch = {
365369 index: params [0 ].name ,
366- timestamp: currentTimestamp ,
370+ timestamp: Number ( params [ 0 ]. name ) ,
367371 }
368372 const currentGroupTotalCl = clSeriesGroupTotal .value [currentIndex ]
369373 const currentGroupTotalEl = elSeriesGroupTotal .value [currentIndex ]
@@ -418,14 +422,13 @@ const option = computed<EChartsOption>(() => {
418422 axisLabel: {
419423 fontSize: textSize ,
420424 fontWeight: fontWeightMedium ,
421- formatter : (epoch : number ) => {
422- const unixTimestamp = getTimestampFromEpoch (epoch )
423- const date = getDateTime (unixTimestamp , { hasTime: false })
424- return ` ${date }\n ${$t (' common.epoch' )} ${epoch } `
425+ formatter : (timestamp : number ) => {
426+ const date = getDateTime (timestamp , { hasTime: false })
427+ return date
425428 },
426429 lineHeight: 20 ,
427430 },
428- data: data .value ?.categories ,
431+ data: data .value ?.data . categories ,
429432 type: ' category' ,
430433 },
431434 yAxis: {
@@ -446,6 +449,8 @@ const option = computed<EChartsOption>(() => {
446449 },
447450 }
448451})
452+
453+ onUpdated (() => hideTooltip ())
449454 </script >
450455
451456<template >
@@ -473,14 +478,14 @@ const option = computed<EChartsOption>(() => {
473478 class =" no-data"
474479 alignment =" center"
475480 >
476- {{ $t("dashboard.validator.summary .chart.error") }}
481+ {{ $t("dashboard.validator.rewards .chart.error") }}
477482 </div >
478483 <div
479484 v-if =" status === 'success' && !clSeries.length"
480485 class =" no-data"
481486 alignment =" center"
482487 >
483- {{ $t("dashboard.validator.summary .chart.no_data") }}
488+ {{ $t("dashboard.validator.rewards .chart.no_data") }}
484489 </div >
485490 </div >
486491</template >
0 commit comments