Skip to content

chart

This endpoint allows to use chart core module

render

request

POST /chart/render

Request body format:

{
    "title": "chart title",
    "series" [<series data>]    
}

Series data:

see chart module documentation about series data format

{
  "color": "red",
  "line_color": "",
  "point_color": "",
  "data": [<data>]
}

Data:

{
  "timestamp": 123123123123,
  "value": 10.20
}

Example

curl -X "POST" "http://127.0.0.1:2020/chart/render" \
     -H 'Content-Type: application/json; charset=utf-8' \
     -d $'{
  "title": "FooBar",
  "series": [
    {
      "data": [
        {
          "value": 95,
          "timestamp": 12345646554
        },
        {
          "value": 94,
          "timestamp": 12345646555
        }
      ]
    }
  ]
}'

Its request is analogous to the following lua script:

script.lua
local ch = require("chart")

data = {
    title = "FooBar",
    series = {
        {
            data = {
                {
                    value = 95,
                    timestamp = 12345646554
                },
                {
                    value = 94,
                    timestamp = 12345646555
                }
            }
        }
    }
}

result = ch.render(data)

response

{
  "status": "ok",
  "result": <base64 encoded image>
}

Chart response image:

image