Skip to content

Commit

Permalink
Merge pull request #16703 from davelopez/fix_dashboard_chart_legend
Browse files Browse the repository at this point in the history
[23.1] Fix legend not scrollable in storage overview charts
  • Loading branch information
dannon authored Sep 18, 2023
2 parents 60b7d65 + 8093dc0 commit 4bfd5b4
Showing 1 changed file with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import { BCard } from "bootstrap-vue";
import { computed, onMounted, ref, watch } from "vue";
import * as d3 from "d3";
import type { DataValuePoint } from ".";
interface BarChartProps {
Expand Down Expand Up @@ -184,6 +183,17 @@ function createLegend() {
.attr("fill", "black")
.text((d) => props.labelFormatter(d));
// Set the width of the SVG to the width of the widest entry
let maxWidth = 0;
for (const node of entries.nodes()) {
const width = (node as HTMLElement).getBoundingClientRect().width;
maxWidth = Math.max(maxWidth, width);
}
const svg = container.node()?.closest("svg");
if (svg) {
svg.setAttribute("width", `${maxWidth}`);
}
return entries;
}
Expand Down Expand Up @@ -294,7 +304,7 @@ function setTooltipPosition(mouseX: number, mouseY: number): void {
</script>

<template>
<b-card class="mb-3 mx-3">
<b-card class="mb-3">
<template v-slot:header>
<h3 class="text-center my-1">
<slot name="title">
Expand Down Expand Up @@ -337,7 +347,7 @@ function setTooltipPosition(mouseX: number, mouseY: number): void {
}
.bar-chart {
float: right;
float: left;
&:deep(svg) {
overflow: visible;
Expand All @@ -349,12 +359,9 @@ function setTooltipPosition(mouseX: number, mouseY: number): void {
}
.legend {
float: left;
float: right;
height: 400px;
&:deep(svg) {
overflow: visible;
}
overflow: auto;
&:deep(.legend-item) {
font-size: 14px;
Expand Down

0 comments on commit 4bfd5b4

Please sign in to comment.