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
#33
Thanks for the help.

With random data it works and with the image the graph is loaded on the visualization.

I have the data in the data.lp file. How do I collect it?

I have tried with this
Code:
<?

data_pvpc = storage.get('pvpc')

local data = {}
for i = 1, 24 do
  data[ i ] = {
    value = data_pvpc
  }
end

local labels = {}

for i = 0, 23 do
  local label = tostring(i)
  if #label == 1 then
    label = '0' .. label
  end

  labels[ #labels + 1 ] = label
end

for i, item in ipairs(data) do
  data[ i ] = item.value / 1000
end

local width = 600
local height = 400

local params = {
  type = 'line',
  data = {
    labels = labels,
    datasets = {
      {
        label = 'Prices',
        backgroundColor = 'rgb(255, 99, 132)',
        borderColor = 'rgb(255, 99, 132)',
        data = data,
        fill = false,
      }
    }
  },
  options = {
    title = {
      display = true,
      text = 'Title',
    }
  }
}

local cdata = ngx.escape_uri(require('json').encode(params))
local url = 'https://quickchart.io/chart?w=' .. width .. '&h=' .. height .. '&c=' .. cdata

local data = require('socket.http').request(url)

header('content-type', 'image/png')
write(data)

I returned

Error in /www/user/chart.lp at line 3: attempt to index global 'storage' (a nil value)

I have also tried with local data_pvpc = storage.get('pvpc')

Greeting
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: