Add A2UI heatmap charts
This commit is contained in:
16
src/a2ui.rs
16
src/a2ui.rs
@@ -75,7 +75,7 @@ Every line must be one JSON object with `version":"v1.0"` and exactly one of `cr
|
||||
|
||||
Catalog components:
|
||||
- Basic: Text(text Markdown,variant caption|body), Image(url,description,fit contain|cover|fill|none|scaleDown,variant icon|avatar|smallFeature|mediumFeature|largeFeature|header), Icon(name; safe examples: info|error|check|close|search|settings), Video(url,posterUrl), AudioPlayer(url,description), Divider(axis horizontal|vertical), Row/Column(children,justify start|center|end|spaceBetween|spaceAround|spaceEvenly|stretch,align start|center|end|stretch), List(children,direction vertical|horizontal,align start|center|end|stretch), Card(child), Modal(trigger,content), Tabs(tabs[{title,child}]), Button(child,variant default|primary|borderless,action:{event:{name,context,wantResponse}}), TextField(label,value:{path},variant shortText|longText|number|obscured,placeholder), CheckBox(label,value:{path}), Slider(value:{path},max,min,steps positive integer), DateTimeInput(label,value:{path},enableDate,enableTime,min,max), ChoicePicker(label,options[{label,value}],value:{path},variant multipleSelection|mutuallyExclusive,displayStyle checkbox|chips,filterable). Put numeric weight on direct Row/Column children to distribute available space.
|
||||
- Research: Chart(title,chartType bar|line|area|stackedBar|pie|donut,series[{label,value,segments}]), Table(title,columns,rows), Metric(label,value,detail,trend), Timeline(title,events[{time,title,description,status}]), Map(title,locations[{label,latitude,longitude,detail}]), MindMap(title,nodes[{id,label,children}]), Form(title,children,submitLabel,action). Use pie or donut for proportional breakdowns; donut displays the total in its center.
|
||||
- Research: Chart(title,chartType bar|line|area|stackedBar|pie|donut|heatmap,series[{label,value,segments}]), Table(title,columns,rows), Metric(label,value,detail,trend), Timeline(title,events[{time,title,description,status}]), Map(title,locations[{label,latitude,longitude,detail}]), MindMap(title,nodes[{id,label,children}]), Form(title,children,submitLabel,action). Use pie or donut for proportional breakdowns; donut displays the total in its center. Use heatmap for a matrix: every series entry is a row and its segments are the labeled columns whose numeric values determine color intensity. A heatmap without segments is empty.
|
||||
- Shared fields: id, accessibility, weight, checks. Checks use {"condition":{"call":"required","args":{...}},"message":"..."}. Bind dynamic values with {"path":"/json/pointer"}. The renderer supports every function in the v1.0 Basic Catalog, including validation, formatting, logic, pluralize, openUrl, and @index. Input edits are local and synchronous. Agent events receive their resolved context and current data model. Server-initiated `callFunction` messages are supported.
|
||||
|
||||
Example:
|
||||
@@ -1082,7 +1082,15 @@ fn validate_component(component: &Map<String, Value>, catalog_id: &str) -> Resul
|
||||
"Chart" => validate_enum(
|
||||
component,
|
||||
"chartType",
|
||||
&["bar", "line", "area", "stackedBar", "pie", "donut"],
|
||||
&[
|
||||
"bar",
|
||||
"line",
|
||||
"area",
|
||||
"stackedBar",
|
||||
"pie",
|
||||
"donut",
|
||||
"heatmap",
|
||||
],
|
||||
id,
|
||||
)?,
|
||||
_ => {}
|
||||
@@ -2256,14 +2264,14 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn catalog_accepts_pie_and_donut_charts() {
|
||||
fn catalog_accepts_pie_donut_and_heatmap_charts() {
|
||||
let mut store = Store::default();
|
||||
apply(
|
||||
&mut store,
|
||||
json!({"version":VERSION,"createSurface":{"surfaceId":"s","catalogId":CATALOG_ID}}),
|
||||
)
|
||||
.unwrap();
|
||||
for chart_type in ["pie", "donut"] {
|
||||
for chart_type in ["pie", "donut", "heatmap"] {
|
||||
apply(
|
||||
&mut store,
|
||||
json!({"version":VERSION,"updateComponents":{"surfaceId":"s","components":[{"id":"root","component":"Chart","chartType":chart_type,"series":[{"label":"rs","value":41}]}]}}),
|
||||
|
||||
Reference in New Issue
Block a user