Get widget by id
GET
/
api
/
widgets
/
{widgetId}
Authorizations
x-api-key
string
headerrequiredResponse
200 - application/json
The response is of type object
.
{
"id": "5a85328f-ed69-4c44-9cfb-cdea08324397",
"title": "Orders M-o-M",
"query": "Create a bar chart showing the orders per month. The x axis should show the month and year in MM-YYYY format",
"x": 6,
"y": 3,
"w": 6,
"h": 3,
"assumptions": [
"1. The 'Order Date' field from the 'd65edfb2-f781-4815-899e-5f50134b36b8' key will be used to extract the month and year for the x-axis.",
"2. The 'Order ID' field from the 'd65edfb2-f781-4815-899e-5f50134b36b8' key will be used to count the number of orders for the y-axis.",
"3. The 'Order Date' field is assumed to be in the 'YYYY-MM-DD' format.",
"4. The 'Order ID' field is assumed to be unique for each order.",
"5. The data is unsorted, so we will need to sort it by date to correctly display the orders per month.",
"6. We are not using any fields from the '93e483e0-1246-43ac-a8bc-5fad124fbf14' key in this function."
],
"code": "import pandas as pd\nimport numpy as np\ndef main():\n # Load the necessary columns from the first CSV file\n df1 = pd.read_csv('/tmp/9f5cd772-aaff-460e-8e7a-03d21070b12c.csv', \n usecols=['Order ID', 'Order Date'])\n \n # Convert 'Order Date' to datetime format and extract the month and year\n df1['Order Date'] = pd.to_datetime(df1['Order Date'])\n df1['Month-Year'] = df1['Order Date'].dt.strftime('%m-%Y')\n \n # Count the number of orders per month\n orders_per_month = df1['Month-Year'].value_counts().sort_index()\n \n # Create the chart.js object\n chart = {\n \"type\": \"bar\",\n \"data\": {\n \"labels\": orders_per_month.index.tolist(),\n \"datasets\": [{\n \"label\": \"Number of Orders\",\n \"data\": orders_per_month.values.tolist(),\n \"backgroundColor\": 'rgba(75, 192, 192, 0.2)',\n \"borderColor\": 'rgba(75, 192, 192, 1)',\n \"borderWidth\": 1\n }]\n },\n \"options\": {\n \"responsive\": True,\n \"maintainAspectRatio\": False,\n \"plugins\": {\n \"datalabels\": {\n \"display\": False\n },\n \"title\": {\n \"display\": True,\n \"text\": 'Orders per Month'\n }\n }\n }\n }\n \n return chart",
"team": "ee5b08c6-5167-4425-bbc3-a746fe4a7ead",
"dashboard": "fd0b9d77-791d-4898-afa6-99800301d861",
"cache": "{\"type\":\"bar\",\"data\":{\"labels\":[\"01-2015\",\"01-2016\",\"01-2017\",\"01-2018\",\"02-2015\",\"02-2016\",\"02-2017\",\"02-2018\",\"03-2015\",\"03-2016\",\"03-2017\",\"03-2018\",\"04-2015\",\"04-2016\",\"04-2017\",\"04-2018\",\"05-2015\",\"05-2016\",\"05-2017\",\"05-2018\",\"06-2015\",\"06-2016\",\"06-2017\",\"06-2018\",\"07-2015\",\"07-2016\",\"07-2017\",\"07-2018\",\"08-2015\",\"08-2016\",\"08-2017\",\"08-2018\",\"09-2015\",\"09-2016\",\"09-2017\",\"09-2018\",\"10-2015\",\"10-2016\",\"10-2017\",\"10-2018\",\"11-2015\",\"11-2016\",\"11-2017\",\"11-2018\",\"12-2015\",\"12-2016\",\"12-2017\",\"12-2018\"],\"datasets\":[{\"label\":\"Number of Orders\",\"data\":[79,58,89,155,46,64,83,107,157,138,163,238,135,160,170,203,122,146,225,242,135,138,199,245,143,140,201,226,153,159,176,218,268,293,363,459,159,166,196,298,318,324,370,459,278,316,352,462],\"backgroundColor\":\"rgba(75, 192, 192, 0.2)\",\"borderColor\":\"rgba(75, 192, 192, 1)\",\"borderWidth\":1}]},\"options\":{\"responsive\":true,\"maintainAspectRatio\":false,\"plugins\":{\"datalabels\":{\"display\":false},\"title\":{\"display\":true,\"text\":\"Orders per Month\"}}}}"
}
You can find all properties for Widgets in the concepts at this link