quickest-silver•2y ago
Generate a Bar Chart
I want to generate a bar chart based on the API response result. I have successfully call the API and have the result in array of JSON object. Then I use Response AI to help me generate the bar chart.
This is my prompt:
-----
Based on the value in API response, show me a bar chart with the following configurations:
1. X-axis is the "Month" column value.
2. Y-axis is the "Total" value correspond to the "Month" column value. The bar is blue in color.
If there is no result in the API response, tell user there is no data available.
------
But instead of generating a bar chart, it generates python sample code for me. What are the keywords that I miss out in order for the AI to generate a chart for me?
3 Replies
You can use an API like quickchart, generate the URL with your AI Set step and populate a variable you can use in an Image step.
https://quickchart.io/chart?c=%7B%22type%22%3A%22bar%22%2C%22data%22%3A%7B%22labels%22%3A%5B%222023-10-20%2015%3A11%3A37%22%2C%222023-11-06%2016%3A57%3A02%22%2C%222023-11-06%2016%3A58%3A37%22%2C%222023-11-06%2017%3A40%3A17%22%5D%2C%22datasets%22%3A%5B%7B%22label%22%3A%22Token%20Consumption%20(gpt-3.5-turbo)%22%2C%22data%22%3A%5B0%2C3755%2C3803%2C7816%5D%2C%22backgroundColor%22%3A%22hsla(0%2C%2050%25%2C%2050%25%2C%200.2)%22%2C%22borderColor%22%3A%22hsla(0%2C%2050%25%2C%2050%25%2C%201)%22%2C%22borderWidth%22%3A1%7D%2C%7B%22label%22%3A%22Token%20Consumption%20(claude-instant-v1)%22%2C%22data%22%3A%5B5999%2C0%2C0%2C0%5D%2C%22backgroundColor%22%3A%22hsla(90%2C%2050%25%2C%2050%25%2C%200.2)%22%2C%22borderColor%22%3A%22hsla(90%2C%2050%25%2C%2050%25%2C%201)%22%2C%22borderWidth%22%3A1%7D%5D%7D%2C%22options%22%3A%7B%22scales%22%3A%7B%22y%22%3A%7B%22beginAtZero%22%3Atrue%7D%7D%7D%7D
QuickChart
Chart Images from URL | QuickChart
Create a chart image with one URL and embed anywhere. Open source, no watermarks.
quickest-silverOP•2y ago
Thanks, I will try it out! 😁