diff --git a/account.html b/account.html index 3daa866..a61e263 100644 --- a/account.html +++ b/account.html @@ -16,23 +16,23 @@ #resource-container { display: grid; grid-template-columns: repeat(auto-fill, calc(100% / 6)); - grid-gap: 0px; + grid-gap: 0; justify-content: space-between; } } - @media screen and (width <= 1264px) and (width >= 480px) { + @media screen and (width <= 1264px) and (width >= 680px) { #resource-container { display: grid; grid-template-columns: repeat(auto-fill, 200px); - grid-gap: 0px; + grid-gap: 0; justify-content: space-between; } } - @media screen and (width <= 480px) { + @media screen and (width <= 680px) { #resource-container { display: flex; flex-direction: column; - gap: 0px; + gap: 0; flex-wrap: nowrap; justify-content: center; } diff --git a/scripts/account.js b/scripts/account.js index 35b5f04..c96904e 100644 --- a/scripts/account.js +++ b/scripts/account.js @@ -98,6 +98,8 @@ function createResourceUsageChart (container, resourceName, resourceAvail, resou }, ariaLabel: `${resourceName} used ${usedStr} of ${maxStr}` }; + chart.style = "margin: 10px;"; + chart.responsive = "680px"; } function parseNumber (value, unitData) { diff --git a/scripts/chart.js b/scripts/chart.js index 7958eb0..2078080 100644 --- a/scripts/chart.js +++ b/scripts/chart.js @@ -1,31 +1,90 @@ class CustomChart extends HTMLElement { - constructor (data) { + constructor () { super(); this.attachShadow({ mode: "open" }); this.shadowRoot.innerHTML = ` -
- -
+ +
+
+ +
+
+
`; + this.responsiveStyle = this.shadowRoot.querySelector("#responsive-style"); this.canvas = this.shadowRoot.querySelector("canvas"); + this.caption = this.shadowRoot.querySelector("figcaption"); } set data (data) { + if (data.chart?.options?.plugins?.title.display) { + data.chart.options.plugins.title.display = false; + for (let line of data.chart.options.plugins.title.text) { + this.caption.innerHTML += `${line}` + } + } this.canvas.role = "img"; this.canvas.ariaLabel = data.ariaLabel; createChart(this.canvas, data.chart); + + } get data () { return null; } + + set responsive (breakpoint) { + this.breakpoint = breakpoint; + if (breakpoint) { + this.responsiveStyle.media = `screen and (width <= ${breakpoint})`; + } + else { + this.responsiveStyle.media = "not all"; + } + } + + get responsive () { + return this.breakpoint; + } } function createChart (ctx, data) {