{ "$schema": "https://vega.github.io/schema/vega/v5.json", "description": "todo", "title": "Treemap", "width": 400, "height": 250, "padding": 5, "autosize": {"type": "fit", "contains": "padding"}, "data": [ { "name": "table", "values": [{"Category":"Technology","Sub-Category":"Phones","Sales":330007.05},{"Category":"Technology","Sub-Category":"Machines","Sales":189238.63},{"Category":"Technology","Sub-Category":"Copiers","Sales":149528.03},{"Category":"Technology","Sub-Category":"Accessories","Sales":167380.32},{"Category":"Office Supplies","Sub-Category":"Supplies","Sales":46673.54},{"Category":"Office Supplies","Sub-Category":"Storage","Sales":223843.61},{"Category":"Office Supplies","Sub-Category":"Paper","Sales":78479.21},{"Category":"Office Supplies","Sub-Category":"Labels","Sales":12486.31},{"Category":"Office Supplies","Sub-Category":"Fasteners","Sales":3024.28},{"Category":"Office Supplies","Sub-Category":"Envelopes","Sales":16476.4},{"Category":"Office Supplies","Sub-Category":"Binders","Sales":203412.73},{"Category":"Office Supplies","Sub-Category":"Art","Sales":27118.79},{"Category":"Office Supplies","Sub-Category":"Appliances","Sales":107532.16},{"Category":"Furniture","Sub-Category":"Tables","Sales":206965.53},{"Category":"Furniture","Sub-Category":"Furnishings","Sales":91705.16},{"Category":"Furniture","Sub-Category":"Chairs","Sales":328449.1},{"Category":"Furniture","Sub-Category":"Bookcases","Sales":114880}], "transform": [ { "type" : "nest", "keys": ["Category", "Sub-Category"] }, { "type": "treemap", "field": "Sales", "ratio": 1, "paddingInner": 1, "size": [{"signal": "width"}, {"signal": "height"}] } ] } ], "scales": [ { "name": "color", "type": "ordinal", "domain": {"data": "table", "field": "Category"}, "range": ["#96cbff", "#1A8CFF", "#115DAA", "#082A4D"] } ], "marks": [ { "type": "rect", "from": {"data": "table"}, "encode": { "update": { "x": {"field": "x0"}, "y": {"field": "y0"}, "x2": {"field": "x1"}, "y2": {"field": "y1"}, "fill": {"scale": "color", "field": "Category"}, "tooltip": {"signal": "datum"} } } }, { "type": "text", "from": {"data": "table"}, "encode": { "update": { "dx": {"value": 2}, "dy": {"value": 10}, "x": {"field": "x0"}, "y": {"field": "y0"}, "text": [ {"test": "(datum.y1-datum.y0<20) || (datum.x1-datum.x0<30)", "value": ""}, {"field": "Sub-Category"}], "fill": {"value": "white"} } } } ] }