Enhance dashboard charts design

This commit is contained in:
Jonathan Adeline committed 2025-03-10 05:50:54 +00:00
1 parent 1dc9a16030
commit f113354cb8
11 files changed
+279 -138

No files matched your search

@@ -1,3 +1,25 @@
.chart {
max-height: 320px;
}
.chart__no-data {
display: flex;
justify-content: center;
align-items: center;
height: 100%;
padding: 10px 0;
flex-direction: column;
gap: 36px;
}
.chart__no-data-dashed-line {
border-top: 1px dashed $palette-neutral-200;
width: 100%;
height: 1px;
}
.chart__no-data-plain-line {
border-top: 1px solid $palette-neutral-200;
width: 100%;
height: 1px;
}
@@ -1,3 +1,15 @@
.dashboard-chart-widget {
padding: 0 24px 24px;
// nothing
}
.dashboard-chart-widget__content {
height: 280px;
}
.dashboard-chart-widget__loading {
height: 341px;
.dashboard-chart-widget--with-header-description & {
height: 362.8px;
}
}
@@ -1,5 +1,20 @@
<template>
<Bar id="chart-id" :options="chartOptions" :data="chartData" class="chart" />
<Bar
v-if="chartData.datasets.length > 0"
id="chart-id"
:options="chartOptions"
:data="chartData"
class="chart"
/>
<div v-else class="chart__no-data">
<span class="chart__no-data-dashed-line"></span>
<span class="chart__no-data-dashed-line"></span>
<span class="chart__no-data-dashed-line"></span>
<span class="chart__no-data-dashed-line"></span>
<span class="chart__no-data-dashed-line"></span>
<span class="chart__no-data-plain-line"></span>
</div>
</template>
<script>
@@ -50,6 +65,36 @@ export default {
display: true,
align: 'start',
position: 'bottom',
labels: {
usePointStyle: true,
boxWidth: 14,
pointStyle: 'circle',
padding: 20,
},
},
tooltip: {
backgroundColor: '#202128',
padding: 10,
bodyFont: {
size: 12,
},
titleFont: {
size: 12,
},
},
},
elements: {
bar: {
borderRadius: {
topLeft: 4,
topRight: 4,
bottomLeft: 0,
bottomRight: 0,
},
borderWidth: 1,
borderColor: '#5190ef',
backgroundColor: '#5190ef',
hoverBackgroundColor: '#5190ef',
},
},
}
@@ -88,7 +133,7 @@ export default {
datasets.push({
data: seriesData,
label,
backgroundColor: this.chartColors[index],
...this.chartColors[index],
})
}
return {
@@ -107,7 +152,7 @@ export default {
datasets.push({
data: seriesData,
label,
backgroundColor: this.chartColors[index],
...this.chartColors[index],
})
}
return {
@@ -124,7 +169,33 @@ export default {
})
},
chartColors() {
return ['#4E5CFE', '#2BC3F1', '#FFC744', '#E26AB0', '#3E4ACB']
return [
{
backgroundColor: '#5190ef',
borderColor: '#5190ef',
hoverBackgroundColor: '#5190ef',
},
{
backgroundColor: '#2BC3F1',
borderColor: '#2BC3F1',
hoverBackgroundColor: '#2BC3F1',
},
{
backgroundColor: '#FFC744',
borderColor: '#FFC744',
hoverBackgroundColor: '#FFC744',
},
{
backgroundColor: '#E26AB0',
borderColor: '#E26AB0',
hoverBackgroundColor: '#E26AB0',
},
{
backgroundColor: '#3E4ACB',
borderColor: '#3E4ACB',
hoverBackgroundColor: '#3E4ACB',
},
]
},
},
methods: {
@@ -1,38 +1,48 @@
<template>
<div class="dashboard-chart-widget">
<div class="widget-header">
<div class="widget-header__main">
<div class="widget-header__title-wrapper">
<div class="widget-header__title">{{ widget.title }}</div>
<div
v-if="dataSourceMisconfigured"
class="widget-header__fix-configuration"
>
<svg
width="5"
height="6"
viewBox="0 0 5 6"
fill="none"
xmlns="http://www.w3.org/2000/svg"
<div
class="dashboard-chart-widget"
:class="{
'dashboard-chart-widget--with-header-description': widget.description,
}"
>
<template v-if="!loading">
<div
class="widget__header"
:class="{
'widget__header--edit-mode': editMode,
}"
>
<div class="widget__header-main">
<div class="widget__header-title-wrapper">
<div class="widget__header-title">{{ widget.title }}</div>
<Badge
v-if="dataSourceMisconfigured"
color="red"
size="small"
indicator
rounded
>{{ $t('widget.fixConfiguration') }}</Badge
>
<circle cx="2.5" cy="3" r="2.5" fill="#FF5A44" />
</svg>
{{ $t('widget.fixConfiguration') }}
</div>
<div v-if="widget.description" class="widget__header-description">
{{ widget.description }}
</div>
</div>
<div v-if="widget.description" class="widget-header__description">
{{ widget.description }}
</div>
<WidgetContextMenu
v-if="isEditMode"
:widget="widget"
:dashboard="dashboard"
@delete-widget="$emit('delete-widget', $event)"
></WidgetContextMenu>
</div>
<WidgetContextMenu
v-if="isEditMode"
:widget="widget"
:dashboard="dashboard"
@delete-widget="$emit('delete-widget', $event)"
></WidgetContextMenu>
</div>
<Chart :data-source="dataSource" :data-source-data="dataForDataSource">
</Chart>
<div class="dashboard-chart-widget__content widget__content">
<Chart :data-source="dataSource" :data-source-data="dataForDataSource">
</Chart>
</div>
</template>
<div v-else class="dashboard-chart-widget__loading loading-spinner"></div>
</div>
</template>
@@ -57,6 +67,16 @@ export default {
required: false,
default: '',
},
loading: {
type: Boolean,
required: false,
default: false,
},
editMode: {
type: Boolean,
required: false,
default: false,
},
},
computed: {
dataSource() {