Charts
A simple way to implement charts with your AdminJS instance is to use Recharts library and Admin's API.
[
{
name: xAxisVariable0,
value: yAxisVariable0
},
{
name: xAxisVariable1,
value: yAxisVariable1
},
// ...
{
name: xAxisVariableN,
value: yAxisVariableN
},
]import { Filter } from 'adminjs'
export const dashboardHandler = async (request, response, context) => {
// finding resource called movies
const resource = context._admin.findResource('movies')
// creating new filter, so that we can see only movies released in 2020
const filter = new Filter({}, resource)
// finding all records that match provided filter
const resourceData = await resource.find(filter, { sort: { sortBy: 'year', direction: 'desc' } }, context)
const data = resourceData.map((item) => item.toJSON(context.currentAdmin))
return data
}Last updated