This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

PVPC trend graph in visu
#2
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
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
Reply


Messages In This Thread
PVPC trend graph in visu - by JRP - 26.08.2022, 10:45
RE: PVPC trend graph in visu - by JRP - 08.09.2022, 10:55
RE: PVPC trend graph in visu - by admin - 08.09.2022, 11:55
RE: PVPC trend graph in visu - by JRP - 08.09.2022, 16:15
RE: PVPC trend graph in visu - by admin - 09.09.2022, 08:48
RE: PVPC trend graph in visu - by JRP - 09.09.2022, 18:03
RE: PVPC trend graph in visu - by admin - 12.09.2022, 09:43
RE: PVPC trend graph in visu - by JRP - 13.09.2022, 18:51
RE: PVPC trend graph in visu - by admin - 14.09.2022, 06:47
RE: PVPC trend graph in visu - by JRP - 14.09.2022, 16:24
RE: PVPC trend graph in visu - by admin - 15.09.2022, 07:15
RE: PVPC trend graph in visu - by JRP - 16.09.2022, 08:41
RE: PVPC trend graph in visu - by JRP - 21.09.2022, 08:36
RE: PVPC trend graph in visu - by admin - 21.09.2022, 08:42
RE: PVPC trend graph in visu - by JRP - 22.09.2022, 18:02
RE: PVPC trend graph in visu - by JRP - 23.09.2022, 10:43
RE: PVPC trend graph in visu - by admin - 23.09.2022, 11:05
RE: PVPC trend graph in visu - by JRP - 23.09.2022, 11:47
RE: PVPC trend graph in visu - by admin - 23.09.2022, 11:50
RE: PVPC trend graph in visu - by JRP - 23.09.2022, 12:09
RE: PVPC trend graph in visu - by admin - 23.09.2022, 12:12
RE: PVPC trend graph in visu - by JRP - 23.09.2022, 12:52
RE: PVPC trend graph in visu - by JRP - 24.09.2022, 11:24
RE: PVPC trend graph in visu - by JRP - 03.10.2022, 09:53
RE: PVPC trend graph in visu - by Daniel - 03.10.2022, 10:07
RE: PVPC trend graph in visu - by JRP - 03.10.2022, 10:35
RE: PVPC trend graph in visu - by admin - 03.10.2022, 13:10
RE: PVPC trend graph in visu - by JRP - 06.10.2022, 17:16
RE: PVPC trend graph in visu - by admin - 07.10.2022, 05:36
RE: PVPC trend graph in visu - by JRP - 16.10.2022, 17:25
RE: PVPC trend graph in visu - by JRP - 18.10.2022, 07:30
RE: PVPC trend graph in visu - by admin - 18.10.2022, 09:31
RE: PVPC trend graph in visu - by JRP - 18.10.2022, 17:30
RE: PVPC trend graph in visu - by JRP - 19.10.2022, 07:41
RE: PVPC trend graph in visu - by admin - 19.10.2022, 07:42
RE: PVPC trend graph in visu - by JRP - 20.10.2022, 18:11
RE: PVPC trend graph in visu - by icuzz - 14.02.2024, 16:43
RE: PVPC trend graph in visu - by admin - 15.02.2024, 08:05
RE: PVPC trend graph in visu - by icuzz - 16.02.2024, 05:20
RE: PVPC trend graph in visu - by admin - 16.02.2024, 07:21
RE: PVPC trend graph in visu - by icuzz - 17.02.2024, 18:18
RE: PVPC trend graph in visu - by admin - 19.02.2024, 06:01
RE: PVPC trend graph in visu - by icuzz - 20.02.2024, 07:21
RE: PVPC trend graph in visu - by icuzz - 01.03.2024, 04:21

Forum Jump: