[{"data":1,"prerenderedAt":782},["ShallowReactive",2],{"navigation":3,"\u002Fblog\u002F3d-charts-for-shadcn-ui":30,"\u002Fblog\u002F3d-charts-for-shadcn-ui-surround":778},[4],{"title":5,"path":6,"stem":7,"children":8,"page":29},"Blog","\u002Fblog","blog",[9,13,17,21,25],{"title":10,"path":11,"stem":12},"3D Charts for shadcn\u002Fui Where Depth Shows Data","\u002Fblog\u002F3d-charts-for-shadcn-ui","blog\u002F3d-charts-for-shadcn-ui",{"title":14,"path":15,"stem":16},"Polify: Turn Any Image Into Low Poly Art in Your Browser","\u002Fblog\u002Fpolify-turn-any-image-into-low-poly-art","blog\u002Fpolify-turn-any-image-into-low-poly-art",{"title":18,"path":19,"stem":20},"Software Craftsmanship is the real Agile","\u002Fblog\u002Fsoftware-craftsmanship-is-the-real-agile","blog\u002Fsoftware-craftsmanship-is-the-real-agile",{"title":22,"path":23,"stem":24},"Level Up Your D3 Charts: Exploring d3-3d v2","\u002Fblog\u002Flevel-up-your-d3-charts","blog\u002Flevel-up-your-d3-charts",{"title":26,"path":27,"stem":28},"Beautiful Backgrounds: Animated Web Components for Stunning Pages","\u002Fblog\u002Fbeautiful-backgrounds-animated-web-components-for-stunning-pages","blog\u002Fbeautiful-backgrounds-animated-web-components-for-stunning-pages",false,{"id":31,"title":10,"author":32,"body":36,"date":771,"description":772,"extension":773,"image":774,"meta":775,"minRead":287,"navigation":133,"path":11,"seo":776,"stem":12,"__hash__":777},"blog\u002Fblog\u002F3d-charts-for-shadcn-ui.md",{"name":33,"avatar":34},"Stefan Nieke",{"src":35,"alt":33},"\u002Fimg\u002Fme-light.avif",{"type":37,"value":38,"toc":764},"minimark",[39,43,46,66,71,74,119,128,137,140,144,147,175,178,194,197,656,666,670,683,694,697,701,704,707,710,719,725,729,738,760],[40,41,42],"p",{},"Think of the 3D chart you have seen most often. Chances are it is the tilted pie of office software: a thick disc, a glossy edge, one slice pulled out. It is also the 3D chart people ask for most. And it lies.",[40,44,45],{},"Its thickness adds no number. Worse, the tilt bends the numbers that are there: the slice at the front looks larger than its twin at the side, because perspective stretches what is close. The same goes for funnels, pyramids and bars drawn as cylinders. The third dimension is spent on looks, and the reader pays for it.",[40,47,48,49,53,54,61,62,65],{},"So when I built ",[50,51,52],"strong",{},"chart3d\u002Fcn",", 3D charts for ",[55,56,60],"a",{"href":57,"rel":58},"https:\u002F\u002Fui.shadcn.com",[59],"nofollow","shadcn\u002Fui",", I wrote one rule down before anything else: ",[50,63,64],{},"the depth of every chart shows data",", or the shape of the earth. A chart whose depth is decoration does not get in, however often it is asked for. Want a pie? You get a donut whose slices are as wide as their share and as tall as their value, so the depth carries a number too.",[67,68,70],"h2",{"id":69},"what-chart3dcn-is","What chart3d\u002Fcn is",[40,72,73],{},"chart3d\u002Fcn is a set of chart components that work the way shadcn\u002Fui does:",[75,76,77,84,99,113],"ul",{},[78,79,80,83],"li",{},[50,81,82],{},"You own the code."," Install a chart with the shadcn CLI and its source lands in your project. Or install the same components from npm, if you would rather update than own.",[78,85,86,89,90,94,95,98],{},[50,87,88],{},"Your theme."," A chart draws in the colors its config names, such as the ",[91,92,93],"code",{},"--chart-1"," to ",[91,96,97],{},"--chart-5"," tokens your theme already has, dark mode included.",[78,100,101,104,105,108,109,112],{},[50,102,103],{},"The config you know."," ",[91,106,107],{},"ChartContainer3D"," takes the same ",[91,110,111],{},"ChartConfig"," as the chart of shadcn\u002Fui, so one config drives a 2D and a 3D chart.",[78,114,115,118],{},[50,116,117],{},"Plain SVG."," The charts render on the server, print sharply and take CSS like any other element.",[40,120,121,122,127],{},"There are twelve charts: bar (now with stacks), bar field, area, line, scatter and surface in a box with axes; a globe, places, routes and a choropleth on the earth; and the donut. Every one is in the ",[55,123,126],{"href":124,"rel":125},"https:\u002F\u002Fchart3dcn.niekes.com\u002Fdocs\u002Fcomponents",[59],"components overview",".",[40,129,130],{},[131,132],"video",{"autoPlay":133,"loop":133,"muted":133,"playsInline":133,"width":134,"src":135,"ariaLabel":136},true,800,"\u002Fblog\u002Fchart3dcn\u002Fglobe.mp4","A globe chart turning, its tiles rising to the population they hold",[40,138,139],{},"You turn a chart by holding ⌘ on a Mac, or Ctrl elsewhere, and dragging, or by focusing it and using the arrow keys. A plain drag never hijacks the page: it only inspects.",[67,141,143],{"id":142},"getting-started","Getting started",[40,145,146],{},"In a project set up with shadcn\u002Fui, add a chart with the CLI:",[148,149,154],"pre",{"className":150,"code":151,"language":152,"meta":153,"style":153},"language-bash shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","npx shadcn@latest add niekes\u002Fchart3dcn\u002Fbar-chart-3d\n","bash","",[91,155,156],{"__ignoreMap":153},[157,158,161,165,169,172],"span",{"class":159,"line":160},"line",1,[157,162,164],{"class":163},"sBMFI","npx",[157,166,168],{"class":167},"sfazB"," shadcn@latest",[157,170,171],{"class":167}," add",[157,173,174],{"class":167}," niekes\u002Fchart3dcn\u002Fbar-chart-3d\n",[40,176,177],{},"Or take the same components from npm:",[148,179,181],{"className":150,"code":180,"language":152,"meta":153,"style":153},"npm install chart3dcn\n",[91,182,183],{"__ignoreMap":153},[157,184,185,188,191],{"class":159,"line":160},[157,186,187],{"class":163},"npm",[157,189,190],{"class":167}," install",[157,192,193],{"class":167}," chart3dcn\n",[40,195,196],{},"Then a first chart looks like any shadcn chart, with one more dimension:",[148,198,202],{"className":199,"code":200,"language":201,"meta":153,"style":153},"language-tsx shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","import { BarChart3D } from \"@\u002Fcomponents\u002Fui\u002Fbar-chart-3d\"\nimport { ChartContainer3D, type ChartConfig } from \"@\u002Fcomponents\u002Fui\u002Fchart-3d\"\n\nconst chartData = [\n  { month: \"January\", desktop: 186, mobile: 80 },\n  { month: \"February\", desktop: 305, mobile: 200 },\n  { month: \"March\", desktop: 237, mobile: 120 },\n]\n\nconst chartConfig = {\n  desktop: { label: \"Desktop\", color: \"var(--chart-1)\" },\n  mobile: { label: \"Mobile\", color: \"var(--chart-2)\" },\n} satisfies ChartConfig\n\nexport function Visitors() {\n  return (\n    \u003CChartContainer3D config={chartConfig} legend className=\"max-w-xl\">\n      \u003CBarChart3D data={chartData} index=\"month\" titles={{ y: \"Visitors\" }} \u002F>\n    \u003C\u002FChartContainer3D>\n  )\n}\n","tsx",[91,203,204,233,263,269,285,330,366,402,408,413,426,464,500,512,517,535,544,582,634,644,650],{"__ignoreMap":153},[157,205,206,210,214,218,221,224,227,230],{"class":159,"line":160},[157,207,209],{"class":208},"s7zQu","import",[157,211,213],{"class":212},"sMK4o"," {",[157,215,217],{"class":216},"sTEyZ"," BarChart3D",[157,219,220],{"class":212}," }",[157,222,223],{"class":208}," from",[157,225,226],{"class":212}," \"",[157,228,229],{"class":167},"@\u002Fcomponents\u002Fui\u002Fbar-chart-3d",[157,231,232],{"class":212},"\"\n",[157,234,236,238,240,243,246,249,252,254,256,258,261],{"class":159,"line":235},2,[157,237,209],{"class":208},[157,239,213],{"class":212},[157,241,242],{"class":216}," ChartContainer3D",[157,244,245],{"class":212},",",[157,247,248],{"class":208}," type",[157,250,251],{"class":216}," ChartConfig",[157,253,220],{"class":212},[157,255,223],{"class":208},[157,257,226],{"class":212},[157,259,260],{"class":167},"@\u002Fcomponents\u002Fui\u002Fchart-3d",[157,262,232],{"class":212},[157,264,266],{"class":159,"line":265},3,[157,267,268],{"emptyLinePlaceholder":133},"\n",[157,270,272,276,279,282],{"class":159,"line":271},4,[157,273,275],{"class":274},"spNyl","const",[157,277,278],{"class":216}," chartData ",[157,280,281],{"class":212},"=",[157,283,284],{"class":216}," [\n",[157,286,288,291,295,298,300,303,306,308,311,313,317,319,322,324,327],{"class":159,"line":287},5,[157,289,290],{"class":212},"  {",[157,292,294],{"class":293},"swJcz"," month",[157,296,297],{"class":212},":",[157,299,226],{"class":212},[157,301,302],{"class":167},"January",[157,304,305],{"class":212},"\"",[157,307,245],{"class":212},[157,309,310],{"class":293}," desktop",[157,312,297],{"class":212},[157,314,316],{"class":315},"sbssI"," 186",[157,318,245],{"class":212},[157,320,321],{"class":293}," mobile",[157,323,297],{"class":212},[157,325,326],{"class":315}," 80",[157,328,329],{"class":212}," },\n",[157,331,333,335,337,339,341,344,346,348,350,352,355,357,359,361,364],{"class":159,"line":332},6,[157,334,290],{"class":212},[157,336,294],{"class":293},[157,338,297],{"class":212},[157,340,226],{"class":212},[157,342,343],{"class":167},"February",[157,345,305],{"class":212},[157,347,245],{"class":212},[157,349,310],{"class":293},[157,351,297],{"class":212},[157,353,354],{"class":315}," 305",[157,356,245],{"class":212},[157,358,321],{"class":293},[157,360,297],{"class":212},[157,362,363],{"class":315}," 200",[157,365,329],{"class":212},[157,367,369,371,373,375,377,380,382,384,386,388,391,393,395,397,400],{"class":159,"line":368},7,[157,370,290],{"class":212},[157,372,294],{"class":293},[157,374,297],{"class":212},[157,376,226],{"class":212},[157,378,379],{"class":167},"March",[157,381,305],{"class":212},[157,383,245],{"class":212},[157,385,310],{"class":293},[157,387,297],{"class":212},[157,389,390],{"class":315}," 237",[157,392,245],{"class":212},[157,394,321],{"class":293},[157,396,297],{"class":212},[157,398,399],{"class":315}," 120",[157,401,329],{"class":212},[157,403,405],{"class":159,"line":404},8,[157,406,407],{"class":216},"]\n",[157,409,411],{"class":159,"line":410},9,[157,412,268],{"emptyLinePlaceholder":133},[157,414,416,418,421,423],{"class":159,"line":415},10,[157,417,275],{"class":274},[157,419,420],{"class":216}," chartConfig ",[157,422,281],{"class":212},[157,424,425],{"class":212}," {\n",[157,427,429,432,434,436,439,441,443,446,448,450,453,455,457,460,462],{"class":159,"line":428},11,[157,430,431],{"class":293},"  desktop",[157,433,297],{"class":212},[157,435,213],{"class":212},[157,437,438],{"class":293}," label",[157,440,297],{"class":212},[157,442,226],{"class":212},[157,444,445],{"class":167},"Desktop",[157,447,305],{"class":212},[157,449,245],{"class":212},[157,451,452],{"class":293}," color",[157,454,297],{"class":212},[157,456,226],{"class":212},[157,458,459],{"class":167},"var(--chart-1)",[157,461,305],{"class":212},[157,463,329],{"class":212},[157,465,467,470,472,474,476,478,480,483,485,487,489,491,493,496,498],{"class":159,"line":466},12,[157,468,469],{"class":293},"  mobile",[157,471,297],{"class":212},[157,473,213],{"class":212},[157,475,438],{"class":293},[157,477,297],{"class":212},[157,479,226],{"class":212},[157,481,482],{"class":167},"Mobile",[157,484,305],{"class":212},[157,486,245],{"class":212},[157,488,452],{"class":293},[157,490,297],{"class":212},[157,492,226],{"class":212},[157,494,495],{"class":167},"var(--chart-2)",[157,497,305],{"class":212},[157,499,329],{"class":212},[157,501,503,506,509],{"class":159,"line":502},13,[157,504,505],{"class":212},"}",[157,507,508],{"class":208}," satisfies",[157,510,511],{"class":163}," ChartConfig\n",[157,513,515],{"class":159,"line":514},14,[157,516,268],{"emptyLinePlaceholder":133},[157,518,520,523,526,530,533],{"class":159,"line":519},15,[157,521,522],{"class":208},"export",[157,524,525],{"class":274}," function",[157,527,529],{"class":528},"s2Zo4"," Visitors",[157,531,532],{"class":212},"()",[157,534,425],{"class":212},[157,536,538,541],{"class":159,"line":537},16,[157,539,540],{"class":208},"  return",[157,542,543],{"class":293}," (\n",[157,545,547,550,552,555,558,561,564,567,570,572,574,577,579],{"class":159,"line":546},17,[157,548,549],{"class":212},"    \u003C",[157,551,107],{"class":163},[157,553,554],{"class":274}," config",[157,556,557],{"class":212},"={",[157,559,560],{"class":216},"chartConfig",[157,562,563],{"class":212},"} ",[157,565,566],{"class":274},"legend",[157,568,569],{"class":274}," className",[157,571,281],{"class":212},[157,573,305],{"class":212},[157,575,576],{"class":167},"max-w-xl",[157,578,305],{"class":212},[157,580,581],{"class":212},">\n",[157,583,585,588,591,594,596,599,601,604,606,608,611,613,616,619,622,624,626,629,631],{"class":159,"line":584},18,[157,586,587],{"class":212},"      \u003C",[157,589,590],{"class":163},"BarChart3D",[157,592,593],{"class":274}," data",[157,595,557],{"class":212},[157,597,598],{"class":216},"chartData",[157,600,563],{"class":212},[157,602,603],{"class":274},"index",[157,605,281],{"class":212},[157,607,305],{"class":212},[157,609,610],{"class":167},"month",[157,612,305],{"class":212},[157,614,615],{"class":274}," titles",[157,617,618],{"class":212},"={{",[157,620,621],{"class":293}," y",[157,623,297],{"class":212},[157,625,226],{"class":212},[157,627,628],{"class":167},"Visitors",[157,630,305],{"class":212},[157,632,633],{"class":212}," }} \u002F>\n",[157,635,637,640,642],{"class":159,"line":636},19,[157,638,639],{"class":212},"    \u003C\u002F",[157,641,107],{"class":163},[157,643,581],{"class":212},[157,645,647],{"class":159,"line":646},20,[157,648,649],{"class":293},"  )\n",[157,651,653],{"class":159,"line":652},21,[157,654,655],{"class":212},"}\n",[40,657,658,659,661,662,665],{},"The desktop bars draw in your ",[91,660,93],{},", light and dark. To restyle a part of the chart, the box, the tooltip, the legend, you target its ",[91,663,664],{},"data-slot"," from your stylesheet. There are no style props: looks are CSS, behaviour is a prop.",[67,667,669],{"id":668},"how-it-works","How it works",[40,671,672,673,678,679,682],{},"Under the hood sits ",[55,674,677],{"href":675,"rel":676},"https:\u002F\u002Fgithub.com\u002Fniekes\u002Fd3-3d",[59],"d3-3d",", which I wrote ",[55,680,681],{"href":23},"about earlier",". It never touches the DOM. It turns 3D points into projected 2D points, works out the centroid of every shape and which way every face points.",[40,684,685,686,689,690,693],{},"Each chart keeps one camera in React state. A drag changes the state, the next render projects the data again, and React draws the result as plain ",[91,687,688],{},"\u003Cpath>"," and ",[91,691,692],{},"\u003Ccircle>"," elements.",[40,695,696],{},"SVG has no depth buffer: what comes later in the document is drawn on top. So the charts sort their shapes back to front, and stable React keys let React move the existing nodes instead of rebuilding them. Because the result is SVG, the first frame is part of the HTML. The charts on the docs site are visible before any JavaScript runs.",[67,698,700],{"id":699},"the-webgl-renderer-that-was-not-faster","The WebGL renderer that was not faster",[40,702,703],{},"For thousands of marks, SVG gets slow, and a canvas takes over the marks while the box, its labels and the tooltip stay SVG and HTML.",[40,705,706],{},"The obvious next step was WebGL, so I built a WebGL renderer and measured it. It drew no faster than the canvas: the globe's 2,500 tiles took about 40 ms a frame on both. A CPU profile showed why. The projection itself was about 5 % of a frame. The time went into the work around it: the chart's render, sorting, React. Filling the marks on the GPU saves time nobody was spending.",[40,708,709],{},"So the WebGL renderer is gone, and three.js is not coming in either. A frame gets faster by doing less on the CPU: caching what the camera does not change, cheaper colors, fewer faces. The decision is written down, together with what would reopen it: a renderer that projects on the GPU and a measurement that shows it faster on the same demo.",[40,711,712,713,718],{},"That is a pattern in the whole project. The choices that shape what a chart is, how hover lights a mark, how the gestures work, that depth shows data, are recorded as ",[55,714,717],{"href":715,"rel":716},"https:\u002F\u002Fgithub.com\u002Fniekes\u002Fchart3dcn\u002Ftree\u002Fmain\u002Fdocs\u002Fadr",[59],"decisions in the repo",", with the options that lost.",[40,720,721],{},[131,722],{"autoPlay":133,"loop":133,"muted":133,"playsInline":133,"width":134,"src":723,"ariaLabel":724},"\u002Fblog\u002Fchart3dcn\u002Fsurface.mp4","A surface chart turning, a value over a grid",[67,726,728],{"id":727},"try-it","Try it",[40,730,731,732,737],{},"chart3d\u002Fcn is free and open source, kept alive by one maintainer in spare time. If it saves you time, a ",[55,733,736],{"href":734,"rel":735},"https:\u002F\u002Fgithub.com\u002Fsponsors\u002Fniekes",[59],"sponsorship"," keeps it going.",[75,739,740,747,754],{},[78,741,742],{},[55,743,746],{"href":744,"rel":745},"https:\u002F\u002Fchart3dcn.niekes.com\u002Fdocs",[59],"Documentation",[78,748,749],{},[55,750,753],{"href":751,"rel":752},"https:\u002F\u002Fgithub.com\u002Fniekes\u002Fchart3dcn",[59],"GitHub Repo",[78,755,756],{},[55,757,187],{"href":758,"rel":759},"https:\u002F\u002Fwww.npmjs.com\u002Fpackage\u002Fchart3dcn",[59],[761,762,763],"style",{},"html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .s7zQu, html code.shiki .s7zQu{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html pre.shiki code .swJcz, html code.shiki .swJcz{--shiki-light:#E53935;--shiki-default:#F07178;--shiki-dark:#F07178}html pre.shiki code .sbssI, html code.shiki .sbssI{--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}",{"title":153,"searchDepth":235,"depth":235,"links":765},[766,767,768,769,770],{"id":69,"depth":235,"text":70},{"id":142,"depth":235,"text":143},{"id":668,"depth":235,"text":669},{"id":699,"depth":235,"text":700},{"id":727,"depth":235,"text":728},"2026-12-01","chart3d\u002Fcn brings 3D charts to shadcn\u002Fui: copy-paste components in plain SVG, in the colors of your theme, built on d3-3d. And every chart spends its third dimension on data, never on decoration.","md","\u002Fblog\u002Fchart3dcn\u002Fcover.avif",{},{"title":10,"description":772},"YBGIlbBnShEaqqjVx-Yay8glzPO2e1c_bNWqXe-GtYw",[779,780],null,{"title":26,"path":27,"stem":28,"description":781,"children":-1},"How do you make a website truly come alive without heavy frameworks? Beautiful Backgrounds is a TypeScript library that does exactly that: elegant, animated backgrounds as Web Components that are interactive, high-performance, and easy to integrate.",1796467120774]