Skip to content

Commit

Permalink
chore(ui): legends are now working
Browse files Browse the repository at this point in the history
  • Loading branch information
MilosPaunovic authored and brian-mulier-p committed Nov 29, 2024
1 parent 2901726 commit 889499c
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
customBarLegend: {
containerID,
uppercase: true,
length: generated.value.length,
},
}
: {}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
? {
totalsLegend: {
containerID,
length: generated.value.length,
},
}
: {}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
customBarLegend: {
containerID,
uppercase: true,
length: generated.value.length,
},
}
: {}),
Expand Down
16 changes: 5 additions & 11 deletions ui/src/components/dashboard/components/charts/legend.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {getConsistentHEXColor} from "../../../../utils/charts.js";

const getOrCreateLegendList = (chart, id, direction = "row") => {
const legendContainer = document.getElementById(id);
let listContainer = legendContainer.querySelector("ul");
let listContainer = legendContainer?.querySelector("ul");

if (!listContainer) {
listContainer = document.createElement("ul");
Expand All @@ -14,17 +14,15 @@ const getOrCreateLegendList = (chart, id, direction = "row") => {
listContainer.style.margin = 0;
listContainer.style.padding = 0;

legendContainer.appendChild(listContainer);
legendContainer?.appendChild(listContainer);
}

return listContainer;
};

export const barLegend = {
id: "barLegend",
afterUpdate(chart, args, options, length) {
if (!length) return;

afterUpdate(chart, args, options) {
const ul = getOrCreateLegendList(chart, options.containerID);

while (ul.firstChild) {
Expand Down Expand Up @@ -99,9 +97,7 @@ export const barLegend = {

export const customBarLegend = {
id: "customBarLegend",
afterUpdate(chart, args, options, length) {
if (!length) return;

afterUpdate(chart, args, options) {
const ul = getOrCreateLegendList(chart, options.containerID);

while (ul.firstChild) {
Expand Down Expand Up @@ -170,9 +166,7 @@ export const customBarLegend = {

export const totalsLegend = {
id: "totalsLegend",
afterUpdate(chart, args, options, length) {
if (!length) return;

afterUpdate(chart, args, options) {
const ul = getOrCreateLegendList(chart, options.containerID, "column");

while (ul.firstChild) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,3 @@
);
onMounted(() => generate());
</script>

<style lang="scss" scoped>
$height: 200px;
.chart {
max-height: $height;
}
</style>

0 comments on commit 889499c

Please sign in to comment.