Widget:Napchart: Difference between revisions
From Polyphasic Sleep Wiki
No edit summary |
No edit summary Tag: Reverted |
||
| Line 2: | Line 2: | ||
<div style="padding:5px"> | <div style="padding:5px"> | ||
<div style="width:320px;height:320px;"> | <div style="width:320px;height:320px;"> | ||
<canvas id="nc-<!--{$url|escape:'html'}-->" width:100%;height:100%;"></canvas></div></div> | <canvas id="nc-<!--{$url|escape:'html'}-->" style="width:100%;height:100%;"></canvas></div></div> | ||
<script src="/napchart.min.js"></script> | <script src="/napchart.min.js"></script> | ||
<script> | <script> | ||
var chartIdSuffix = "<!--{$url|escape:'html'}-->".split('/').pop(); | |||
var canvasId = "nc-<!--{$url|escape:'html'}-->"; | |||
var ctx = document.getElementById(canvasId).getContext('2d'); | |||
}); | |||
fetch('https://napchart.com/api/v2/getChart?chartid=' + chartIdSuffix) | |||
.then(response => response.json()) | |||
.then(data => { | |||
Napchart.init(ctx, data['chartDocument']['chartData']); | |||
console.log(data); | |||
}) | |||
.catch(error => console.error('Error fetching napchart data:', error)); | |||
</script> | </script> | ||
</includeonly> | </includeonly> | ||
