Chart
Chart the results of a database query. Use this for all charts, plots, and graphs.
Outline Display: Show a {{chartType}} chart of {{query}}
Details
Supported chart types are Bar, StackedBar, Line, Pie, Doughnut, and Radar. The first column returned by the query becomes the X-axis labels, and all remaining columns (which must be numeric) become separate data series on the Y-axis. The chart is rendered statically from the query results.
Requirements
The query SQL query must: (1) Return at least 2 columns total. (2) Have a first column with category/label values (string, date, or any displayable type) for the X-axis. (3) Have remaining columns with numeric values (int, float, money, decimal) for the Y-axis. (4) Give each column an AS alias – these become the data series labels. (5) Use GROUP BY for aggregations. CORRECT PATTERNS: Simple: SELECT “Sales”.“Month” AS “Month”, “Sales”.“Revenue” AS “Revenue” FROM “Sales” ORDER BY “Sales”.“Month”. With aggregation: SELECT “Orders”.“Status” AS “Status”, COUNT(*) AS “Count” FROM “Orders” GROUP BY “Orders”.“Status”. Multiple series: SELECT “Products”.“Category” AS “Category”, SUM(“Products”.“Sales”) AS “Total Sales”, AVG(“Products”.“Price”) AS “Avg Price” FROM “Products” GROUP BY “Products”.“Category”.
Local scope
Names introduced within this component’s knobs:
uiArgs– virtual table holding this handler’s parameterstab– result columns ofquery(referenceable as a virtual table)
Settings
Required
query: SQL query
A query for chart data.
Must produce: result namedLabelmatching showable type, then result matching numeric type, then any number of results matching numeric type
Scope: all columns ofuiArgs(reference as[ColumnName], e.g.,[Name],[Price]).
Optional
chartType: choice (one of:Bar,StackedBar,Line,Pie,Doughnut,Radar)
The type of chart