Skip to content

Commit

Permalink
add color pack example
Browse files Browse the repository at this point in the history
  • Loading branch information
mcnuttandrew committed Mar 4, 2024
1 parent 9e98d51 commit 7bc3a3f
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
64 changes: 64 additions & 0 deletions public/examples/colorpack.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"description": "An example of a circle packing layout for hierarchical data.",
"width": 600,
"height": 600,
"padding": 5,
"autosize": "none",

"data": [
{
"name": "tree",
"url": "data/flare.json",
"transform": [
{
"type": "stratify",
"key": "id",
"parentKey": "parent"
},
{
"type": "pack",
"field": "size",
"sort": { "field": "value" },
"size": [{ "signal": "width" }, { "signal": "height" }]
}
]
}
],

"scales": [
{
"name": "color",
"type": "ordinal",
"domain": { "data": "tree", "field": "depth" },
"range": { "scheme": "category20" }
}
],

"marks": [
{
"type": "symbol",
"from": { "data": "tree" },
"encode": {
"enter": {
"shape": { "value": "circle" },
"fill": { "scale": "color", "field": "depth" },
"tooltip": {
"signal": "datum.name + (datum.size ? ', ' + datum.size + ' bytes' : '')"
}
},
"update": {
"x": { "field": "x" },
"y": { "field": "y" },
"size": { "signal": "4 * datum.r * datum.r" },
"stroke": { "value": "white" },
"strokeWidth": { "value": 0.5 }
},
"hover": {
"stroke": { "value": "red" },
"strokeWidth": { "value": 2 }
}
}
}
]
}
5 changes: 5 additions & 0 deletions src/stores/example-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ export const DEMOS = [
title: "Grid",
filename: "./examples/grid-heatmap.json",
},
{
type: "vega",
title: "Circle Pack",
filename: "./examples/colorpack.json",
},
];

export function modifySVGForExampleStore(
Expand Down

0 comments on commit 7bc3a3f

Please sign in to comment.