08.09.2022, 10:55
In another thread it is suggested to use https://quickchart.io/ for the generation of graphs and I think it can be a solution to my problem of graphing the price/hour data of the PVPC of Spain.
I have the pvpc data in a table like this
Later with this script I get the URL with the chart based on the configuration selected in chart.
I would need to assemble the chart chain with the data separated and declared as variables:
type
data
labels
datasets
labels
backgroundColor
borderColor
data (the prices of the table obtained from the api esios PVPC)
Just like I do with the url, height and width.
In addition, I would need to be able to use the url that is obtained in the visualization, to be able to see the png that it generates.
Thank you
I have the pvpc data in a table like this
Code:
* table:
["indicator"]
* table:
["composited"]
* bool: false
["magnitud"]
* table:
[1]
* table:
["name"]
* string: Precio
["id"]
* number: 23
["id"]
* number: 1001
["tiempo"]
* table:
[1]
* table:
["name"]
* string: Hora
["id"]
* number: 4
["step_type"]
* string: linear
["short_name"]
* string: PVPC T. 2.0TD
["values"]
* table:
[1]
* table:
["datetime_utc"]
* string: 2022-08-26T22:00:00Z
["geo_id"]
* number: 8741
["value"]
* number: 492.82
["tz_time"]
* string: 2022-08-26T22:00:00.000Z
["geo_name"]
* string: Península
["datetime"]
* string: 2022-08-27T00:00:00.000+02:00
[2]
* table:
["datetime_utc"]
* string: 2022-08-26T23:00:00Z
["geo_id"]
* number: 8741
["value"]
* number: 497.35
["tz_time"]
* string: 2022-08-26T23:00:00.000Z
["geo_name"]
* string: Península
["datetime"]
* string: 2022-08-27T01:00:00.000+02:00
[3]
* table:
["datetime_utc"]
* string: 2022-08-27T00:00:00Z
["geo_id"]
* number: 8741
["value"]
* number: 494.44
["tz_time"]
* string: 2022-08-27T00:00:00.000Z
["geo_name"]
* string: Península
["datetime"]
* string: 2022-08-27T02:00:00.000+02:00
[4]
* table:
["datetime_utc"]
* string: 2022-08-27T01:00:00Z
["geo_id"]
* number: 8741
["value"]
* number: 508.86
["tz_time"]
* string: 2022-08-27T01:00:00.000Z
["geo_name"]
* string: Península
["datetime"]
* string: 2022-08-27T03:00:00.000+02:00
[5]
* table:
["datetime_utc"]
* string: 2022-08-27T02:00:00Z
["geo_id"]
* number: 8741
["value"]
* number: 531.02
["tz_time"]
* string: 2022-08-27T02:00:00.000Z
["geo_name"]
* string: Península
["datetime"]
* string: 2022-08-27T04:00:00.000+02:00
[6]
* table:
["datetime_utc"]
* string: 2022-08-27T03:00:00Z
["geo_id"]
* number: 8741
["value"]
* number: 553.12
["tz_time"]
* string: 2022-08-27T03:00:00.000Z
["geo_name"]
* string: Península
["datetime"]
* string: 2022-08-27T05:00:00.000+02:00
[7]
* table:
["datetime_utc"]
* string: 2022-08-27T04:00:00Z
["geo_id"]
* number: 8741
["value"]
* number: 568.16
["tz_time"]
* string: 2022-08-27T04:00:00.000Z
["geo_name"]
* string: Península
["datetime"]
* string: 2022-08-27T06:00:00.000+02:00
[8]
* table:
["datetime_utc"]
* string: 2022-08-27T05:00:00Z
["geo_id"]
* number: 8741
["value"]
* number: 557.06
["tz_time"]
* string: 2022-08-27T05:00:00.000Z
["geo_name"]
* string: Península
["datetime"]
* string: 2022-08-27T07:00:00.000+02:00
[9]
* table:
["datetime_utc"]
* string: 2022-08-27T06:00:00Z
["geo_id"]
* number: 8741
["value"]
* number: 507.94
["tz_time"]
* string: 2022-08-27T06:00:00.000Z
["geo_name"]
* string: Península
["datetime"]
* string: 2022-08-27T08:00:00.000+02:00
[10]
* table:
["datetime_utc"]
* string: 2022-08-27T07:00:00Z
["geo_id"]
* number: 8741
["value"]
* number: 445.72
["tz_time"]
* string: 2022-08-27T07:00:00.000Z
["geo_name"]
* string: Península
["datetime"]
* string: 2022-08-27T09:00:00.000+02:00
[11]
* table:
["datetime_utc"]
* string: 2022-08-27T08:00:00Z
["geo_id"]
* number: 8741
["value"]
* number: 405.18
["tz_time"]
* string: 2022-08-27T08:00:00.000Z
["geo_name"]
* string: Península
["datetime"]
* string: 2022-08-27T10:00:00.000+02:00
[12]
* table:
["datetime_utc"]
* string: 2022-08-27T09:00:00Z
["geo_id"]
* number: 8741
["value"]
* number: 389.13
["tz_time"]
* string: 2022-08-27T09:00:00.000Z
["geo_name"]
* string: Península
["datetime"]
* string: 2022-08-27T11:00:00.000+02:00
[13]
* table:
["datetime_utc"]
* string: 2022-08-27T10:00:00Z
["geo_id"]
* number: 8741
["value"]
* number: 381.83
["tz_time"]
* string: 2022-08-27T10:00:00.000Z
["geo_name"]
* string: Península
["datetime"]
* string: 2022-08-27T12:00:00.000+02:00
[14]
* table:
["datetime_utc"]
* string: 2022-08-27T11:00:00Z
["geo_id"]
* number: 8741
["value"]
* number: 381.23
["tz_time"]
* string: 2022-08-27T11:00:00.000Z
["geo_name"]
* string: Península
["datetime"]
* string: 2022-08-27T13:00:00.000+02:00
[15]
* table:
["datetime_utc"]
* string: 2022-08-27T12:00:00Z
["geo_id"]
* number: 8741
["value"]
* number: 385.12
["tz_time"]
* string: 2022-08-27T12:00:00.000Z
["geo_name"]
* string: Península
["datetime"]
* string: 2022-08-27T14:00:00.000+02:00
[16]
* table:
["datetime_utc"]
* string: 2022-08-27T13:00:00Z
["geo_id"]
* number: 8741
["value"]
* number: 391.42
["tz_time"]
* string: 2022-08-27T13:00:00.000Z
["geo_name"]
* string: Península
["datetime"]
* string: 2022-08-27T15:00:00.000+02:00
[17]
* table:
["datetime_utc"]
* string: 2022-08-27T14:00:00Z
["geo_id"]
* number: 8741
["value"]
* number: 400.21
["tz_time"]
* string: 2022-08-27T14:00:00.000Z
["geo_name"]
* string: Península
["datetime"]
* string: 2022-08-27T16:00:00.000+02:00
[18]
* table:
["datetime_utc"]
* string: 2022-08-27T15:00:00Z
["geo_id"]
* number: 8741
["value"]
* number: 407.64
["tz_time"]
* string: 2022-08-27T15:00:00.000Z
["geo_name"]
* string: Península
["datetime"]
* string: 2022-08-27T17:00:00.000+02:00
[19]
* table:
["datetime_utc"]
* string: 2022-08-27T16:00:00Z
["geo_id"]
* number: 8741
["value"]
* number: 414.83
["tz_time"]
* string: 2022-08-27T16:00:00.000Z
["geo_name"]
* string: Península
["datetime"]
* string: 2022-08-27T18:00:00.000+02:00
[20]
* table:
["datetime_utc"]
* string: 2022-08-27T17:00:00Z
["geo_id"]
* number: 8741
["value"]
* number: 491.04
["tz_time"]
* string: 2022-08-27T17:00:00.000Z
["geo_name"]
* string: Península
["datetime"]
* string: 2022-08-27T19:00:00.000+02:00
[21]
* table:
["datetime_utc"]
* string: 2022-08-27T18:00:00Z
["geo_id"]
* number: 8741
["value"]
* number: 544.13
["tz_time"]
* string: 2022-08-27T18:00:00.000Z
["geo_name"]
* string: Península
["datetime"]
* string: 2022-08-27T20:00:00.000+02:00
[22]
* table:
["datetime_utc"]
* string: 2022-08-27T19:00:00Z
["geo_id"]
* number: 8741
["value"]
* number: 555.8
["tz_time"]
* string: 2022-08-27T19:00:00.000Z
["geo_name"]
* string: Península
["datetime"]
* string: 2022-08-27T21:00:00.000+02:00
[23]
* table:
["date...
Later with this script I get the URL with the chart based on the configuration selected in chart.
Code:
json = require('json')
http = require('socket.http')
ltn12 = require('ltn12')
url = 'https://quickchart.io/chart/create'
ancho = 500
alto = 300
tipo = line
grafico = "{type:'line',data:{labels:['00','01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23'],datasets:[{label:'PVPC',backgroundColor:'rgb(255, 255, 132)',borderColor:'rgb(255, 195, 132)',data:[93, 29, 17, 8, 73, 98, 40],fill:false,},],},options:{title:{display:false,text:'PVPC',},},}"
body = json.encode(
{
backgroundColor = "transparent",
width = ancho,
height = alto,
format = "png",
chart = grafico
}
)
log(body)
resp = {}
res, code = http.request({
url = url,
method = 'PUT',
headers = {
['Content-Type'] = 'application/json',
['Content-Length'] = #body,
},
source = ltn12.source.string(body),
sink = ltn12.sink.table(resp),
})
log(res, code, resp)
I would need to assemble the chart chain with the data separated and declared as variables:
type
data
labels
datasets
labels
backgroundColor
borderColor
data (the prices of the table obtained from the api esios PVPC)
Just like I do with the url, height and width.
In addition, I would need to be able to use the url that is obtained in the visualization, to be able to see the png that it generates.
Thank you