<p>Pick a value in the dropdown and see the color of the div change.</p><selectclass="input"ref:value="colorBoxValue"><optionvalue="mt3 w3 h3 bg-red"selected>Red</option><optionvalue="mt3 w3 h3 bg-orange">Orange</option><optionvalue="mt3 w3 h3 bg-gold">Gold</option><optionvalue="mt3 w3 h3 bg-yellow">Yellow</option><optionvalue="mt3 w3 h3 bg-purple">Purple</option><optionvalue="mt3 w3 h3 bg-pink">Pink</option><optionvalue="mt3 w3 h3 bg-green">Green</option><optionvalue="mt3 w3 h3 bg-navy">Navy</option><optionvalue="mt3 w3 h3 bg-blue">Blue</option></select><divlink:class="colorBoxValue"></div>
Pick a value in the dropdown and see the color of the div change.
Imagine that you have a database with millions of data points that you would
like to display in a line graph.
That already sounds challenging, doesn't it?
This is one of those use cases where reference actions can really come in handy.
It does not have to be hard at all.
You don't have to pay in complexity, visual fidelity, accuracy, or
performance. 🤯
1 2 3 4 5 6 7 8 910111213141516171819202122232425
<pclass="mt0">
The point is not the graph, but the fact that it is a completely normal
<code>svg</code> element, with no charting libraries or any kind of special
rendering needed.
</p><inputtype="hidden"name="chartWidth"link:value="referenceChartWidth"on:attr:value="sendChartWidth"on="sendChartWidth"debounce="100"src="/reference-chart"result="referenceChart"><svgclass="chart"height="500"ref:width="referenceChartWidth"measure="devicePixelContentBoxSize"render="referenceChart"position="replaceWith"></svg>
12345
// obtain an absurd number of data points// this will be an array with ten million numbers!// again, like all the other demos, this is 100% true and 100% real// no cutting corners here ;)server.series=generateSeries(10_000_000);
{{
// available area for rendering from the client
const width = +server.getParam("chartWidth");
// pick at most the number of available pixels worth of data points
// this is going to look identical in the UI, but is no longer absurd
const data = server.sampleSeries(server.series, width);
// prepare svg compatible values
const chart = server.generateChart(server.series, data, width, 500);
}}
<svgclass="chart"height="500"ref:width="referenceChartWidth"measure="devicePixelContentBoxSize"render="referenceChart"position="replaceWith"viewBox="0 0 { width } 500"><path{chart.path}/><line{chart.xAxis}/><line{chart.yAxis}/>
{{ for (const tick of chart.xTicks) { }}
<text{tick.text}>{ tick.label }</text><line{tick.line}/>
{{ } }}
{{ for (const tick of chart.yTicks) { }}
<text{tick.text}>{ tick.label }</text><line{tick.line}/>
{{ } }}
</svg>
The point is not the graph, but the fact that it is a completely normal
svg element, with no charting libraries or any kind of special
rendering needed.