root page chart table javascript playground wip

This commit is contained in:
DeltaLima 2025-04-10 02:35:20 +02:00
parent 57f704ef28
commit 05fa317e24

View file

@ -334,6 +334,12 @@ function DrawChart() {
/* https://www.w3schools.com/jsref/met_table_insertrow.asp */
var row = [];
/* store previous datapoint for chartcss line chart , array index is chart id */
var previousData = [];
/* fill with 0 */
for(let i = 0; i < chartSum; i++) {
previousData[i] = 0;
}
var table = document.getElementById('tbl_chart0');
for(let i = 0; i < datapointsMax; i++) {
@ -343,9 +349,23 @@ function DrawChart() {
/* check if data is present */
if((ChartJson.chart[j].hasOwnProperty('data')) && (ChartJson.chart[j].data[i] != "undefined")) {
cell[j] = row[i].insertCell(j);
cell[j].innerHTML = ChartJson.chart[j].data[i];
cell[j].innerHTML = ChartJson.chart[j].data[i];
/* add chartscss styles for line chart */
/* build the css string in a var first */
let cssString;
/* when it is the first data point, dont draw --start */
if(i == 0) {
cssString = '--start: calc( ' + ChartJson.chart[j].data[i] + ' / 100); --end: calc( ' + ChartJson.chart[j].data[i] + ' / 100);';
} else {
cssString = '--start: calc( ' + previousData[j] + ' / 100); --end: calc( ' + ChartJson.chart[j].data[i] + ' / 100);';
}
cell[j].style.cssText = cssString;
/* store datapoint as previous data */
previousData[j] = ChartJson.chart[j].data[i];
} else {
console.log('Chart ID ' + j + 'does not have any data')
//console.log('Chart ID ' + j + 'does not have any data')
}
}