Skip to content
Web > Charts > Chart Type Walkthroughs > Cartesian

Bullet Chart of Actuals Against Targets

Known issues

Some chart features have known issues in the current release. See Known issues.

This walkthrough draws each desk's actual as a bar against a target mark and 3 ranges, answering "Which desks are on target?"

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.

  1. Select Dashboard -> AMIDB Shell Tool....
  2. Run:

    1
    2
    3
    CREATE PUBLIC TABLE ChartDemoKpi (Desk String, Actual Double, Target Double, Poor Double, Ok Double, Good Double);
    INSERT INTO ChartDemoKpi VALUES ("Equities", 82, 90, 50, 75, 100), ("Rates", 64, 70, 50, 75, 100), ("FX", 95, 85, 50, 75, 100);
    SELECT * FROM ChartDemoKpi;
    
  3. Check that the lower pane shows the 3 rows.

2. Create the chart

The gallery creates a datamodel that reads the table, then places the chart.

  1. Select Windows -> New Window, then the edit button on Blank1, then "Create Table / Visualization / Form".
  2. Select "AMI (__AMI)", then "Next >>".
  3. Select the "USER" tile ChartDemoKpi, then "Next >>".
  4. Select "Test (alt+enter)", then "Next >>".
  5. Select the "Cartesian" tab, then the "Bullet" tile.
  6. Set the fields below the tiles:

    Field Value
    "Category:" Desk
    "Value:" Actual
    "Target:" Target
    "Range 1:" Poor
    "Range 2:" Ok
    "Range 3:" Good
  7. Select "Finish".

  8. Check that the window shows a row per desk, each with a dark bar, a red target mark, and gray range bands from 0 to 50, 75, and 100.

Result

One row per desk. FX's bar, 95, passes its target of 85; Equities, 82 against 90, and Rates, 64 against 70, fall short.

The finished "Bullet" chart: One row per desk. FX's bar, 95, passes its target of 85; Equities, 82 against 90, and Rates, 64 against 70, fall short

The chart's own PNG export, from AmiScript toImagePng; see Chart type walkthroughs.

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 "Measure", "Target", "Range 1", "Range 2", and "Range 3" layers each report Rows 3 and an empty Problem.

With your own data

The chart needs one row per category: its value, its target, and up to 3 range bounds, each a number column. In stage 2, select the "USER" tile of your table in place of ChartDemoKpi, 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.

  1. Create the datamodel with web_execute op=importDatamodel and this dmJson, then run it once with op=initDatamodelSchema and dmName ChartDemoKpi:

    {"id": "ChartDemoKpi", "queryMode": "startup", "callbacks": [{"name": "onProcess", "amiscript": ["{ CREATE TABLE ChartDemoKpi AS USE ds=\"AMI\" EXECUTE SELECT * FROM ChartDemoKpi; }"]}]}
    
  2. Create the chart:

    {"windowName": "ChartDemoBullet", "templateKey": "tplBullet", "datamodelId": "ChartDemoKpi", "dmTable": "ChartDemoKpi", "title": "ChartDemoBullet", "bindings": "{\"CAT\": \"Desk\", \"VAL\": \"Actual\", \"TARGET\": \"Target\", \"R1\": \"Poor\", \"R2\": \"Ok\", \"R3\": \"Good\"}"}
    
  3. Run the datamodel again with web_execute op=executeDatamodel, dmName ChartDemoKpi. A chart created over MCP can stay empty until its datamodel runs again, with its axes at 0-100.

  4. Confirm that every layer reports the rows above and an empty Problem: run web_debug op=panelRenderStats.

The call is web_create_chart_from_template.

Removing the example

Remove the chart, then its datamodel, then the table, so that the next walkthrough can reuse the names:

  1. Close the chart's window with its close button, and select "Delete" when asked whether to delete the panel.
  2. Select Dashboard -> Data Modeler..., expand "Datamodels", right-click the chart's datamodel, ChartDemoKpi, and select "Delete Datamodel", then "Yes". If that name was taken when stage 2 ran, the gallery added a number to it, as in ChartDemoKpi1.
  3. Run DROP TABLE ChartDemoKpi; in the AMIDB Shell Tool.
  4. Check that SELECT * FROM ChartDemoKpi; reports Unknown table: ChartDemoKpi.

Over MCP, delete the chart with web_danger op=deletePanel, then the datamodel with op=deleteDatamodel, dmName ChartDemoKpi, 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.