Skip to content

Commit

Permalink
label position
Browse files Browse the repository at this point in the history
  • Loading branch information
Kr0nox committed Oct 1, 2023
1 parent ee8e836 commit 1e260c4
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions report-viewer/src/components/ClusterGraph.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import ChartDataLabels from 'chartjs-plugin-datalabels'
import { EdgeLine, GraphController, GraphChart } from 'chartjs-chart-graph'
import { store } from '@/stores/store'
import { graphColors } from '@/utils/ColorUtils'
import { start } from 'repl'

Check warning on line 16 in report-viewer/src/components/ClusterGraph.vue

View workflow job for this annotation

GitHub Actions / check

'start' is defined but never used
const props = defineProps({
cluster: {
Expand Down Expand Up @@ -85,21 +86,41 @@ const graphData = computed(() => {
}
})
const yPadding = 40
const xPadding = computed(() => {
const avgCharacterLength = 8
const widths = labels.value.map((label) => label.length * avgCharacterLength)
const maxWidth = Math.max(...widths)
// Space needed for the longest name, but at most 200
console.log(maxWidth)
return Math.min(200, maxWidth)
})
const graphOptions = computed(() => {
return {
layout: {
padding: {
top: yPadding,
bottom: yPadding,
left: xPadding.value,
right: xPadding.value
}
},
animation: false as false,
plugins: {
legend: { display: false },
datalabels: {
display: true,
font: {
weight: 'bold' as 'bold',
size: 16
size: 12
},
formatter: (value: any, ctx: any) => {
return labels.value[ctx.dataIndex]
},
offset: 12,
align: (ctx: any) => (-360 * ctx.dataIndex) / keys.value.length,
offset: 8,
color: graphColors.ticksAndFont.value
},
tooltip: {
Expand All @@ -124,7 +145,6 @@ function drawGraph() {
loaded.value = false
return
}
console.log(graphCanvas.value)
chart.value = new Chart(ctx, {
type: 'graph',
data: graphData.value,
Expand Down

0 comments on commit 1e260c4

Please sign in to comment.