Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Beds 577/fix summary chart tooltip #1172

Open
wants to merge 2 commits into
base: staging
Choose a base branch
from
Open
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
2 changes: 0 additions & 2 deletions frontend/assets/css/prime.scss
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,6 @@ div.p-checkbox {
// Multiselect drop-down

div.p-multiselect {
@include fonts.button_text;
color: var(--input-active-text-color);
background: var(--input-background);
border: 1px solid var(--input-border-color);
Expand All @@ -402,7 +401,6 @@ div.p-multiselect {
margin-left: var(--padding-small);

.p-multiselect-label {
font-size: var(--tiny_text_font_size);
font-weight: var(--standard_text_font_weight);
}
}
Expand Down
45 changes: 27 additions & 18 deletions frontend/components/dashboard/chart/DashboardChartSummaryChart.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
<script lang="ts" setup>
import {
h, render,
h,
render,
} from 'vue'
import { use } from 'echarts/core'
import { CanvasRenderer } from 'echarts/renderers'
import { LineChart } from 'echarts/charts'
import { type ECharts } from 'echarts'
import {
type ECharts,
type EChartsOption,
} from 'echarts'
import { get } from 'lodash-es'
import {
DataZoomComponent,
Expand Down Expand Up @@ -84,15 +88,8 @@ const aggregation = ref<AggregationTimeframe>('hourly')
const isLoading = ref(false)
let reloadCounter = 0
interface SeriesObject {
data: number[],
name: string,
smooth: boolean,
symbol: string,
type: string,
}
// we don't want the series to be responsive to not trigger an auto update of the option computed
const series = ref<SeriesObject[]>([])
const series = ref<echarts.SeriesOption[]>([])
const chartCategories = ref<number[]>([])
const categories = computed<number[]>(() => {
Expand Down Expand Up @@ -171,7 +168,7 @@ const loadData = async () => {
return
}
isLoading.value = true
const newSeries: SeriesObject[] = []
const newSeries: echarts.SeriesOption[] = []
try {
const res = await fetch<GetValidatorDashboardSummaryChartResponse>(
API_PATH.DASHBOARD_SUMMARY_CHART,
Expand Down Expand Up @@ -204,7 +201,7 @@ const loadData = async () => {
else {
name = getGroupLabel($t, element.id, groups.value, allGroups)
}
const newObj: SeriesObject = {
const newObj: echarts.SeriesOption = {
data: element.data,
name,
smooth: false,
Expand Down Expand Up @@ -285,9 +282,8 @@ const formatTimestamp = (value: string) => {
return date
}
}
// chart options
const option = computed(() => {
const toogleTrigger = ref(false)
const option = computed<EChartsOption>(() => {
return {
color: colors.value.groups,
dataZoom: {
Expand All @@ -312,6 +308,9 @@ const option = computed(() => {
legend: {
bottom: 40,
orient: 'horizontal',
pageTextStyle: {
color: colors.value.label,
},
textStyle: {
color: colors.value.label,
fontSize: textSize,
Expand All @@ -327,10 +326,14 @@ const option = computed(() => {
fontWeight: fontWeightLight,
},
tooltip: {
alwaysShowContent: true,
borderColor: colors.value.background,
confine: true,
formatter(params: any): HTMLElement {
const ts = parseInt(params[0].axisValue)
enterable: true,
extraCssText: 'z-index: 100;',
formatter(params) {
if (!Array.isArray(params)) return ''
const ts = parseInt(params[0].name)
let lastDif = 0
let highlightGroup = ''
const groupInfos = params.map((param: any) => {
Expand Down Expand Up @@ -367,6 +370,7 @@ const option = computed(() => {
order: 'seriesAsc',
padding: 0,
trigger: 'axis',
triggerOn: toogleTrigger.value ? 'click' : 'mousemove|click',
},
xAxis: [
{
Expand Down Expand Up @@ -402,7 +406,7 @@ const option = computed(() => {
name: $t(
`dashboard.validator.summary.chart.efficiency.${props.filter?.efficiency}`,
),
nameLocation: 'center',
nameLocation: 'middle',
nameTextStyle: {
padding: [
0,
Expand Down Expand Up @@ -602,6 +606,10 @@ const onDatazoom = () => {
const onMouseMove = (e: MouseEvent) => {
lastMouseYPos = e.offsetY
}
const onMouseUp = () => {
// using mouseup event here, as `click` or `mousedown` would close `tooltip`
toogleTrigger.value = !toogleTrigger.value
}
</script>

<template>
Expand All @@ -615,6 +623,7 @@ const onMouseMove = (e: MouseEvent) => {
class="chart"
:option
autoresize
@zr:mouseup="onMouseUp"
@datazoom="onDatazoom"
/>
<BcLoadingSpinner
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ const selectedLabel = computed(() => {
max-width: 200px;
@media (max-width: 1000px) {
max-width: 90px;
max-width: min-content
}
}
:deep(> .p-dropdown) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ defineProps<Props>()
border: 1px transparent solid;
line-height: 1.5;
padding: var(--padding);
max-height: 18.75rem;
.line-container {
display: flex;
Expand Down
3 changes: 2 additions & 1 deletion frontend/components/dashboard/chart/TooltipHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ const title = computed(() => {

<template>
<b>
<div>{{ title }} {{ dateText }}</div>
<div>{{ title }}</div>
<div>{{ dateText }}</div>
<div>{{ t("common.epoch") }} {{ epochText }}</div>
</b>
</template>