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

update the report viewer to new chart library #1252

Merged
merged 5 commits into from
Sep 1, 2023
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
44 changes: 22 additions & 22 deletions report-viewer/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions report-viewer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
"@fortawesome/free-regular-svg-icons": "^6.4.2",
"@fortawesome/free-solid-svg-icons": "^6.4.2",
"@fortawesome/vue-fontawesome": "^3.0.3",
"chart.js": "^3.9.1",
"chart.js": "^4.3.3",
"chartjs-plugin-datalabels": "^2.2.0",
"highlight.js": "^11.8.0",
"jszip": "^3.10.0",
"pinia": "^2.1.6",
"slash": "^5.1.0",
"vue": "^3.3.4",
"vue-chart-3": "^3.1.8",
"vue-chartjs": "^5.2.0",
"vue-draggable-next": "^2.2.1",
"vue-router": "^4.2.4",
"vue-virtual-scroller": "^2.0.0-beta.8"
Expand Down
40 changes: 19 additions & 21 deletions report-viewer/src/components/ClusterRadarChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
participants in the cluster.
-->
<template>
<div class="flex flex-col">
<div v-if="!hasNoMember" class="flex flex-grow flex-col">
<div class="flex max-h-full flex-col">
<div v-if="!hasNoMember" class="flex max-h-full flex-grow flex-col overflow-hidden">
<DropDownSelector
:options="selectedOptions"
@selectionChanged="(value) => updateChartData(value)"
@selectionChanged="(value) => (idOfShownSubmission = value)"
/>
<RadarChart :chartData="chartData" :options="options" class="flex-grow"></RadarChart>
<div class="flex min-h-0 flex-grow justify-center">
<Radar :data="chartData" :options="options" />
</div>
</div>
<div v-else>
<span>This cluster has no members.</span>
Expand All @@ -23,7 +25,7 @@ import type { ChartData } from 'chart.js'
import type { ClusterListElement } from '@/model/ClusterListElement'

import { computed, ref } from 'vue'
import { RadarChart } from 'vue-chart-3'
import { Radar } from 'vue-chartjs'
import { Chart, registerables } from 'chart.js'
import ChartDataLabels from 'chartjs-plugin-datalabels'
import DropDownSelector from './DropDownSelector.vue'
Expand All @@ -43,7 +45,7 @@ let hasNoMember = props.cluster.members.size == 0

const selectedOptions = computed(() => Array.from(props.cluster.members.keys()))

const idOfFirstSubmission = selectedOptions.value.length > 0 ? selectedOptions.value[0] : ''
const idOfShownSubmission = ref(selectedOptions.value.length > 0 ? selectedOptions.value[0] : '')

/**
* @param member The member to create the labels for.
Expand Down Expand Up @@ -102,22 +104,18 @@ const radarChartOptions = computed(() => {
}
})

const chartData: Ref<ChartData<'radar', (number | null)[], unknown>> = ref({
labels: createLabelsFor(idOfFirstSubmission),
datasets: [
{
...radarChartStyle,
label: idOfFirstSubmission,
data: createDataSetFor(idOfFirstSubmission)
}
]
const chartData: Ref<ChartData<'radar', (number | null)[], unknown>> = computed(() => {
return {
labels: createLabelsFor(idOfShownSubmission.value),
datasets: [
{
...radarChartStyle,
label: idOfShownSubmission.value,
data: createDataSetFor(idOfShownSubmission.value)
}
]
}
})

const options = ref(radarChartOptions)

function updateChartData(value: string) {
chartData.value.datasets[0].data = createDataSetFor(value)
chartData.value.datasets[0].label = value
chartData.value.labels = createLabelsFor(value)
}
</script>
14 changes: 8 additions & 6 deletions report-viewer/src/components/DistributionDiagram.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
Bar diagram, displaying the distribution for the selected metric.
-->
<template>
<BarChart :chartData="chartData" :options="options" />
<div>
<Bar :data="chartData" :options="options" />
</div>
</template>

<script setup lang="ts">
import { computed, type PropType } from 'vue'
import { BarChart } from 'vue-chart-3'
import { Bar } from 'vue-chartjs'
import { Chart, registerables } from 'chart.js'
import ChartDataLabels from 'chartjs-plugin-datalabels'
import { graphColors } from '@/utils/ColorUtils'
Expand Down Expand Up @@ -62,7 +64,7 @@ const options = computed(() => {
return {
responsive: true,
maintainAspectRatio: false,
indexAxis: 'y',
indexAxis: 'y' as 'y',
scales: {
x: {
//Highest count of submissions in a percentage range. We set the diagrams maximum shown value to maxVal + 5,
Expand All @@ -88,10 +90,10 @@ const options = computed(() => {
datalabels: {
color: graphColors.ticksAndFont.value,
font: {
weight: 'bold'
weight: 'bold' as 'bold'
},
anchor: 'end',
align: 'end',
anchor: 'end' as 'end',
align: 'end' as 'end',
clamp: true
},
legend: {
Expand Down
14 changes: 12 additions & 2 deletions report-viewer/src/components/DropDownSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<script setup lang="ts">
import Interactable from '@/components/InteractableComponent.vue'
import { computed } from 'vue'
import { computed, ref } from 'vue'

const props = defineProps({
options: {
Expand All @@ -28,5 +28,15 @@ const props = defineProps({

defineEmits(['selectionChanged'])

const selectedOption = computed(() => (props.options.length > 0 ? props.options[0] : ''))
const _selectedOption = ref('')

const selectedOption = computed({
get: () => {
if (_selectedOption.value === '') {
return props.options[0]
}
return _selectedOption.value
},
set: (value) => (_selectedOption.value = value)
})
</script>
Loading