Create Doughnut

Example
Prompt
Code

Tutorial

Here is a step-by-step tutorial on how to complete the function fn:

Define the initial SQL query: The SQL query should select the necessary data from the database. In this case, we want to count the number of users created in the last 30 days and group them by month and year.

ts
let sql = `SELECT if(active = 1, "Active", "Inactive") as label count(1) quantity FROM users GROUP BY active`;

Execute the SQL query: Use the query method provided in args to execute the SQL query and get the results.

ts
let results = await args.query(sql);

Display the chart: Use the chartLine method provided in args to send the formatted data as a line chart response.

ts
return args.chartDoughnut(data);

Final Result

With these steps, you have completed the fn function. Now, when this function is called, it will return a line chart showing the number of users created per month in the last 30 days. Make sure to adjust the code according to your application's specifications and structure.

ts
const fn = async function (args: Args) { let sql = `SELECT if(active = 1, "Active", "Inactive") as label count(1) quantity FROM users GROUP BY active`; let results = await args.query(sql); return args.chartDoughnut(results); };
How to create Chartlines
Click to go
How to create Tables
Click to go
On this page

Create Doughnut

Tutorial

Final Result

View this page on
GitHub

Do you have specific enterprise needs? Contact our sales team.

get enterprise

Make your business efficient in seconds.

Create dashboards and backoffices in seconds
Start now