Referensi
Artifact grafik Flint
Referensi untuk artifact grafik yang dirender di chat Pinter.
Chat Pinter merender artifact flint_chart dengan flint-chart@0.4.1 dan ECharts. Konten artifact adalah ChartAssemblyInput dalam bentuk string JSON:
{
"type": "flint_chart",
"title": "Sales by month",
"content": "{\"data\":{\"values\":[...]},\"semantic_types\":{...},\"chart_spec\":{...}}"
}
content harus berisi data.values, semantic_types, dan chart_spec. Setiap field yang direferensikan oleh encodings harus ada di data dan memiliki semantic type. Gunakan channel kanonis di bawah ini untuk artifact baru.
Bentuk yang diwajibkan
{
"data": { "values": [{ "month": "Jan", "sales": 120 }] },
"semantic_types": { "month": "Category", "sales": "Amount" },
"chart_spec": {
"chartType": "Bar Chart",
"encodings": {
"x": { "field": "month" },
"y": { "field": "sales" }
}
}
}
Tipe grafik dan channel
| Tipe grafik | Channel wajib | Channel opsional |
|---|---|---|
Scatter Plot | x, y | color, size, opacity, column, row |
Regression | x, y | size, color, column, row |
Connected Scatter Plot | x, y | order, color, detail, column, row |
Ranged Dot Plot | x, y | color |
Boxplot | x, y | color, opacity, column, row |
Strip Plot | x, y | color, size, column, row |
Bar Chart | x, y | color, opacity, column, row |
Grouped Bar Chart | x, y, group | color, column, row |
Stacked Bar Chart | x, y, color | column, row |
Lollipop Chart | x, y | color, column, row |
Pyramid Chart | x, y | color |
Heatmap | x, y, color | column, row |
Calendar Heatmap | x, color | — |
Line Chart | x, y | color, opacity, column, row |
Bump Chart | x, y | color, detail, column, row |
Slope Chart | x, y | color, detail, column, row |
Area Chart | x, y | color, opacity, column, row |
Streamgraph | x, y, color | column, row |
Range Area Chart | x, y, y2 | color, column, row |
Pie Chart | size, color | column, row |
Funnel Chart | y, size | — |
Treemap | color | size, detail |
Sunburst Chart | color | size, group, detail |
Tree | color | detail, size |
Histogram | x | color, column, row |
Density Plot | x | color, column, row |
ECDF Plot | x | color, detail, column, row |
Parallel Coordinates | Dua atau lebih field data numerik | color, detail |
Candlestick Chart | x, open, high, low, close | column, row |
Waterfall Chart | x, y | color, column, row |
Gantt Chart | y, x, x2 | color, detail, column, row |
Bullet Chart | y, x, goal | color, column, row |
Radar Chart | x, y | color, column, row |
Rose Chart | x, y | color, column, row |
Gauge Chart | size | column |
Sankey Diagram | x, y, size | — |
Network Graph | x, y, size | — |
Grafik alur, hierarki, dan polar
Grafik-grafik ini paling sensitif terhadap pemilihan channel:
| Tipe grafik | Pemetaan kanonis |
|---|---|
Funnel Chart | y = tahap, size = jumlah/nilai. Jangan gunakan color untuk tahap. |
Sankey Diagram | x = sumber, y = target, size = nilai alur. |
Network Graph | x = node sumber, y = node target, size = bobot tautan. |
Rose Chart | x = kategori, y = nilai. color hanya untuk pengelompokan seri terpisah. |
Radar Chart | x = dimensi, y = nilai. color hanya untuk pengelompokan seri terpisah. |
Treemap | color = kategori, size = nilai, detail = kategori turunan. |
Sunburst Chart | color = kategori terluar, group = level tengah, detail = leaf, size = nilai. |
Tree | color = induk/kategori, detail = turunan, size = nilai. |
Gauge Chart | size = nilai; column secara opsional membuat satu gauge per kategori. |
Contoh: diagram Sankey
{
"data": {
"values": [
{ "source": "Pabrik A", "target": "Gudang", "value": 500 },
{ "source": "Gudang", "target": "Toko", "value": 500 }
]
},
"semantic_types": {
"source": "Category",
"target": "Category",
"value": "Amount"
},
"chart_spec": {
"chartType": "Sankey Diagram",
"encodings": {
"x": { "field": "source" },
"y": { "field": "target" },
"size": { "field": "value" }
}
}
}
Contoh: grafik Funnel
{
"data": {
"values": [
{ "stage": "Applicants", "count": 1200 },
{ "stage": "Screening", "count": 400 },
{ "stage": "Hired", "count": 15 }
]
},
"semantic_types": { "stage": "Category", "count": "Count" },
"chart_spec": {
"chartType": "Funnel Chart",
"encodings": {
"y": { "field": "stage" },
"size": { "field": "count" }
}
}
}
Alias kompatibilitas
Renderer chat menerima beberapa nama channel lama/deskriptif untuk artifact yang sudah ada. Ini adalah lapisan kompatibilitas; agent dan integrasi sebaiknya menggunakan channel kanonis di atas.
| Tipe grafik | Encoding lama yang diterima | Dinormalisasi ke |
|---|---|---|
Sankey Diagram, Network Graph | source, target | x, y |
Funnel Chart | stage, category, label, atau color; value | y; size |
Rose Chart | color, size | x, y |
Kegagalan umum
- Gunakan nama tipe grafik yang persis, seperti
Sankey DiagramdanNetwork Graph. - Channel encoding harus mereferensikan field di
data.valuessecara persis. - Jangan gunakan JSON option ECharts sebagai artifact; berikan bentuk input Flint di atas.
- Jangan gunakan
channels; field yang benar adalahencodings. - Jika grafik kosong, periksa channel wajib terlebih dahulu. Flint dapat menghilangkan sebuah seri ketika channel wajib tidak ada.