API Charts
Last updated
Was this helpful?
Last updated
Was this helpful?
This is the official documentation of the @forestadmin/agent
Node.js agent.
API charts in the legacy agents were declared using express routes.
In the new agent, you will need to use either the agent.addChart
or the collection.addChart
function, depending on if the chart is to be displayed on a record of a collection or a dashboard.
router.post
agent.addChart collection.addChart(...)
Liana.StatSerializer
return resultBuilder.value(...) return resultBuilder.distribution(...)
request.query?.record_id
context.recordId
Migrating should be straightforward: the only differences are that:
dashboard charts are now declared using the agent.addChart
function.
collection charts are now declared using the collection.addChart
function, and access the record id using context.recordId
instead of request.query?.record_id
.
Both types should use the resultBuilder
helper to return the chart data.