Line Chart of Daily Closes¶
Known issues
Some chart features have known issues in the current release. See Known issues.
This walkthrough draws a line through 10 daily closing prices, answering "How has the price moved over the last 2 weeks?"
Prerequisites¶
- Editor mode: click once on the screen, then press Ctrl+d. The AMIDB Shell Tool and the gallery are used as in the quickstart.
- Data: the example data that stage 1 creates. To use a table of your own instead, see With your own data.
1. Create the example data¶
The chart reads a table in the Center, so create the table first.
- Select Dashboard -> AMIDB Shell Tool....
-
Run:
-
Check that the lower pane shows the 10 rows.
The dates are stored at midnight New York time, the default user time zone, so each one falls on its own day. See Dates on an axis.
2. Create the chart¶
The gallery creates a datamodel that reads the table, then places the chart.
- Select Windows -> New Window, then the edit button on
Blank1, then "Create Table / Visualization / Form". - Select "AMI (__AMI)", then "Next >>".
- Select the "USER" tile
ChartDemoDaily, then "Next >>". - Select "Test (alt+enter)", then "Next >>".
- Select the "Cartesian" tab, then the "Line Chart" tile.
-
Set the fields below the tiles:
Field Value "X Axis:" Day"Y Axis:" Close"Order by:" Day"Series:" Leave empty -
Select "Finish".
- Check that the window shows a line through 10 points, from 413.5 on Sep 28 to 421.7 on Oct 9, with a longer segment where the weekend falls: the line is unbroken, and the points are spaced by date.
The gallery fills "Y Axis:" with Open first. After you change it to Close, the line follows. The vertical axis title and the hover text still name Open, so change the title in the axis's "Edit Axis" "Title:" field, and the text in the layer's "Hover Over:" field, such as "Close: " + Close (see Writing hover text).
Leave the date axis's "Axis Format Type:" at "Auto". It labels each day under a band, with the hours above; "Date" labels every tick with the date before.
Result¶
A line of 10 points over Sep 28 to Oct 9, its value axis from about 406 to 422.
To check without looking, read the render stats: session.getDevTools().getAllRenderStats() in the AMIDB Shell Tool, with "Run on this web session" selected (see Running a script), or web_debug op=panelRenderStats over MCP. The layer reports Rows 10 and an empty Problem.
With your own data¶
The chart needs one row per point: a time or a number for "X Axis:", and a number for "Y Axis:". For several lines, add a column that names each line and map it to "Series:". In stage 2, select the "USER" tile of your table in place of ChartDemoDaily, and map your columns to the fields in stage 2's field table. Stage 2's check quotes the example data; on yours, check the same features against your own values. To filter rows, or to total raw rows first, see Using your own data.
Over MCP¶
An agent builds the same chart from the same table. Connecting an agent is covered in the AI section; the tools are on Building charts over MCP.
-
Create the datamodel with
web_executeop=importDatamodeland thisdmJson, then run it once withop=initDatamodelSchemaanddmNameChartDemoDaily: -
Create the chart:
-
Run the datamodel again with
web_executeop=executeDatamodel,dmNameChartDemoDaily. A chart created over MCP can stay empty until its datamodel runs again, with its axes at 0-100. - Confirm that every layer reports the rows above and an empty
Problem: runweb_debugop=panelRenderStats.
The call is web_create_chart. Its axis title and hover text name Close.
Removing the example¶
Remove the chart, then its datamodel, then the table, so that the next walkthrough can reuse the names:
- Close the chart's window with its close button, and select "Delete" when asked whether to delete the panel.
- Select Dashboard -> Data Modeler..., expand "Datamodels", right-click the chart's datamodel,
ChartDemoDaily, and select "Delete Datamodel", then "Yes". If that name was taken when stage 2 ran, the gallery added a number to it, as inChartDemoDaily1. - Run
DROP TABLE ChartDemoDaily;in the AMIDB Shell Tool. - Check that
SELECT * FROM ChartDemoDaily;reportsUnknown table: ChartDemoDaily.
Over MCP, delete the chart with web_danger op=deletePanel, then the datamodel with op=deleteDatamodel, dmName ChartDemoDaily, and drop the table as in step 3. deleteDatamodel refuses a datamodel that has been committed; delete that one in the Data Modeler as in step 2. See Removing an agent's chart.