Hello,
I am using plotly with grafana and want to create a 3D Plot. The first version is good, but small adjustments are already open.
I have data from a Postgre SQL database in these form
ID | Date | Zone1 | Zone2 | … |
---|---|---|---|---|
Abc1 | 08.02.2021 – 15:00 | 321 | 323 | … |
Abc2 | 08.02.2021 – 15:01 | 320 | 300 | … |
There are 40 zones and every few seconds I will get new data. In the example Abc3 ….
The 3D plot looks good, but is there a possibility to enclose the start and the end?
In the plot I want to show the last 40 data rows.
My code looks this:
console.log(data)
//var myArray = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40];
//var myArray2 = [1,1,1,1,1,1,1,1,1,1];
//var myValuesArray = [];
var myXArray = [];
var myYArray = [];
var counterY = 40;
var counterX = 0;
var testZ = [];
var dataLength = data.series[0];
for (i = 0; i < dataLength.length; i++) {
counterX = counterX +1;
myXArray.push(counterX);
for (j = 0; j < 40 ; j++) {
counterY = 40 - j;
myYArray.push(counterY);
var pushValue = data.series[0].fields[j].values.buffer[i];
//myValuesArray.push(pushValue);
}
}
for (k = 0; k < 40 ; k++) {
testZ.push(data.series[0].fields[k].values.buffer);
}
//myXArray = [1,2];//[1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2];
//myYArray = [9,10];//[10,11,10,11,10,11,10,11,10,11,10,11,10,11,10,11,10,11,10,11,10,11,10,11,10,11,10,11,10,11,10,11,10,11,10,11,10,11,10,11];
//myValuesArray = [//
// [7,4],
// [8,1],
// [9,20]];
//var test = data.series[0].fields[3].values.buffer;
//test = [data.series[0].fields[3].values.buffer, data.series[0].fields[4].values.buffer, data.series[0].fields[5].values.buffer];
var trace = {
x: myXArray,
y: myYArray,
z: testZ
};
return {data:[trace],layout:{title:'3D plot'}};
Thanks.