aienos.com
Source of www.aienos.com, served from my own hardware
Brought by drakestapleton
aienos.com / public / js / post-llm-case.js
| 1 | (function () { |
| 2 | var datasets = { |
| 3 | global: { |
| 4 | values: [{ label: "2025", value: 447 }, { label: "2026", value: 565 }], |
| 5 | max: 600, |
| 6 | ticks: [0, 200, 400, 600], |
| 7 | suffix: " TWh", |
| 8 | color: "#4bd3a1" |
| 9 | }, |
| 10 | ai: { |
| 11 | values: [{ label: "2025", value: 95 }, { label: "2026", value: 175 }, { label: "2027*", value: 258 }], |
| 12 | max: 300, |
| 13 | ticks: [0, 100, 200, 300], |
| 14 | suffix: " TWh", |
| 15 | color: "#ff7864" |
| 16 | } |
| 17 | }; |
| 18 | var NS = "http://www.w3.org/2000/svg"; |
| 19 | function node(name, attrs, text) { |
| 20 | var el = document.createElementNS(NS, name); |
| 21 | Object.keys(attrs || {}).forEach(function (key) { el.setAttribute(key, attrs[key]); }); |
| 22 | if (text !== undefined) el.textContent = text; |
| 23 | return el; |
| 24 | } |
| 25 | function renderChart(id, data) { |
| 26 | var host = document.getElementById(id); |
| 27 | var width = 560, height = 270, left = 52, right = 18, top = 22, bottom = 46; |
| 28 | var plotW = width - left - right, plotH = height - top - bottom; |
| 29 | var svg = node("svg", { viewBox: "0 0 " + width + " " + height, "aria-hidden": "true", focusable: "false" }); |
| 30 | data.ticks.forEach(function (tick) { |
| 31 | var y = top + plotH - (tick / data.max) * plotH; |
| 32 | svg.appendChild(node("line", { x1: left, y1: y, x2: width - right, y2: y, stroke: "currentColor", "stroke-opacity": ".20", "stroke-width": "1" })); |
| 33 | svg.appendChild(node("text", { x: left - 10, y: y + 4, "text-anchor": "end", fill: "currentColor", "fill-opacity": ".66", "font-size": "11", "font-family": "IBM Plex Mono, monospace" }, String(tick))); |
| 34 | }); |
| 35 | var slot = plotW / data.values.length; |
| 36 | var barW = Math.min(96, slot * .48); |
| 37 | data.values.forEach(function (d, i) { |
| 38 | var h = (d.value / data.max) * plotH; |
| 39 | var x = left + slot * i + (slot - barW) / 2; |
| 40 | var y = top + plotH - h; |
| 41 | svg.appendChild(node("rect", { x: x, y: y, width: barW, height: h, fill: data.color })); |
| 42 | svg.appendChild(node("text", { x: x + barW / 2, y: y - 9, "text-anchor": "middle", fill: "currentColor", "font-size": "13", "font-weight": "700", "font-family": "IBM Plex Mono, monospace" }, d.value + data.suffix)); |
| 43 | svg.appendChild(node("text", { x: x + barW / 2, y: height - 17, "text-anchor": "middle", fill: "currentColor", "fill-opacity": ".75", "font-size": "12", "font-family": "IBM Plex Mono, monospace" }, d.label)); |
| 44 | }); |
| 45 | host.appendChild(svg); |
| 46 | } |
| 47 | renderChart("chartGlobal", datasets.global); |
| 48 | renderChart("chartAI", datasets.ai); |
| 49 | var growth = ((datasets.global.values[1].value / datasets.global.values[0].value - 1) * 100).toFixed(1); |
| 50 | document.getElementById("energyValue").setAttribute("title", growth + "% increase from 2025"); |
| 51 | }()); |
| 52 |