Open
Description
Preliminary Checks
- This issue is not a duplicate. Before opening a new issue, please search existing issues: https://github.com/HugoBlox/hugo-blox-builder/issues?q=is%3Aissue
- This issue is not a question, feature request, or anything other than a bug report directly related to Hugo Blox Builder. Please post those things on Discord: https://discord.gg/z8wNYzb
Description
Using tailwind, add multiple charts with different data using the chart shortcode to the same page.
All charts will have the same data because the fetchChartJSON function is overwritten. That function should be included in the anonymous function.
I've fixed this locally by overriding the chart shortcode partial with this:
{{ $json := printf "./%s.json" (.Get "data") }}
{{ $id := delimit (shuffle (seq 1 9)) "" }}
<div id="chart-{{$id}}" class="chart"></div>
<script>
(function() {
async function fetchChartJSON() {
console.debug('Hugo Blox fetching chart JSON...')
const response = await fetch('{{$json}}');
return await response.json();
}
let a = setInterval( function() {
if ( typeof window.Plotly === 'undefined' ) {
console.debug('Plotly not loaded yet...')
return;
}
clearInterval( a );
fetchChartJSON().then(chart => {
console.debug('Plotting chart...')
window.Plotly.newPlot('chart-{{$id}}', chart.data, chart.layout, {responsive: true});
});
}, 500 );
})();
</script>
Reproduction Link
too lazy
Steps to Reproduce
1.see description
2.
3.
...
Expected Result
all charts use their respective data
Actual Result
all charts use the same data
What Hugo Module versions does your site use?
github.com/HugoBlox/hugo-blox-builder/modules/blox-tailwind v0.3.1
What operating system(s) are you seeing the problem on?
macOS
What browser(s) are you seeing the problem on?
No response
Which Hugo Blox template are you using?
its a partial, use any
What version of Hugo are you using?
0.136.5