[{"data":1,"prerenderedAt":885},["ShallowReactive",2],{"lib:\u002Fplot\u002Fembedding":3,"lib-nav:en:\u002Fplot":857},{"id":4,"title":5,"body":6,"description":849,"extension":311,"group":850,"meta":851,"navigation":230,"order":252,"path":853,"seo":854,"stem":855,"__hash__":856},"libs\u002Fplot\u002Fembedding.md","Embedding",{"type":7,"value":8,"toc":842},"minimark",[9,13,22,103,107,146,158,161,174,300,306,366,380,383,389,446,464,468,478,558,565,688,698,701,707,817,838],[10,11,5],"h1",{"id":12},"embedding",[14,15,16,17,21],"p",{},"The components are plain Vue 3, so they work wherever Vue does, and they render on the server as well as in the browser. Nothing touches ",[18,19,20],"code",{},"window"," before a plot is mounted, and every plot gets its own ids, so any number of them can share a page. Pick the setup you have:",[23,24,25,38],"table",{},[26,27,28],"thead",{},[29,30,31,35],"tr",{},[32,33,34],"th",{},"You have",[32,36,37],{},"Do this",[39,40,41,55,67,79,91],"tbody",{},[29,42,43,47],{},[44,45,46],"td",{},"A Vue app built with Vite",[44,48,49,50],{},"Install, import, done: ",[51,52,54],"a",{"href":53},"#a-vite-app","A Vite app",[29,56,57,60],{},[44,58,59],{},"Course notes in Markdown",[44,61,62,63],{},"Register the plugin once in VitePress: ",[51,64,66],{"href":65},"#vitepress-course-notes","VitePress course notes",[29,68,69,72],{},[44,70,71],{},"A Nuxt site",[44,73,74,75],{},"Import the components, or add a plugin: ",[51,76,78],{"href":77},"#nuxt","Nuxt",[29,80,81,84],{},[44,82,83],{},"A page that only shows figures",[44,85,86,87],{},"Solve at build time and ship JSON: ",[51,88,90],{"href":89},"#ship-the-drawing-not-the-solver","Ship the drawing",[29,92,93,96],{},[44,94,95],{},"No Vue at all",[44,97,98,99],{},"Write the SVG in Node: ",[51,100,102],{"href":101},"#plain-html-from-node","Without Vue",[104,105,54],"h2",{"id":106},"a-vite-app",[108,109,114],"pre",{"className":110,"code":111,"language":112,"meta":113,"style":113},"language-bash shiki shiki-themes github-light github-dark","npm create vue@latest\nnpm install @edubeam\u002Fplot @edubeam\u002Ffem\n","bash","",[18,115,116,132],{"__ignoreMap":113},[117,118,121,125,129],"span",{"class":119,"line":120},"line",1,[117,122,124],{"class":123},"sScJk","npm",[117,126,128],{"class":127},"sZZnC"," create",[117,130,131],{"class":127}," vue@latest\n",[117,133,135,137,140,143],{"class":119,"line":134},2,[117,136,124],{"class":123},[117,138,139],{"class":127}," install",[117,141,142],{"class":127}," @edubeam\u002Fplot",[117,144,145],{"class":127}," @edubeam\u002Ffem\n",[14,147,148,149,153,154,157],{},"Import the components where you use them, as in ",[51,150,152],{"href":151},"\u002Fplot\u002Fgetting-started#draw-a-solved-model","Getting started",", or register both once with ",[18,155,156],{},"app.use(EduBeamPlot)",". There is nothing else to configure: no stylesheet and no bundler plugin.",[104,159,66],{"id":160},"vitepress-course-notes",[14,162,163,169,170,173],{},[51,164,168],{"href":165,"rel":166},"https:\u002F\u002Fvitepress.dev",[167],"nofollow","VitePress"," builds Markdown pages with Vue, which makes it a good home for course notes. Register the components in the theme, ",[18,171,172],{},".vitepress\u002Ftheme\u002Findex.ts",":",[108,175,179],{"className":176,"code":177,"filename":172,"language":178,"meta":113,"style":113},"language-ts shiki shiki-themes github-light github-dark","import DefaultTheme from 'vitepress\u002Ftheme'\nimport type { Theme } from 'vitepress'\nimport { EduBeamPlot } from '@edubeam\u002Fplot'\n\nexport default {\n  extends: DefaultTheme,\n  enhanceApp({ app }) {\n    app.use(EduBeamPlot) \u002F\u002F \u003CStructurePlot> and \u003CDiagramStack> in every page\n  },\n} satisfies Theme\n","ts",[18,180,181,197,212,225,232,244,250,266,282,288],{"__ignoreMap":113},[117,182,183,187,191,194],{"class":119,"line":120},[117,184,186],{"class":185},"szBVR","import",[117,188,190],{"class":189},"sVt8B"," DefaultTheme ",[117,192,193],{"class":185},"from",[117,195,196],{"class":127}," 'vitepress\u002Ftheme'\n",[117,198,199,201,204,207,209],{"class":119,"line":134},[117,200,186],{"class":185},[117,202,203],{"class":185}," type",[117,205,206],{"class":189}," { Theme } ",[117,208,193],{"class":185},[117,210,211],{"class":127}," 'vitepress'\n",[117,213,215,217,220,222],{"class":119,"line":214},3,[117,216,186],{"class":185},[117,218,219],{"class":189}," { EduBeamPlot } ",[117,221,193],{"class":185},[117,223,224],{"class":127}," '@edubeam\u002Fplot'\n",[117,226,228],{"class":119,"line":227},4,[117,229,231],{"emptyLinePlaceholder":230},true,"\n",[117,233,235,238,241],{"class":119,"line":234},5,[117,236,237],{"class":185},"export",[117,239,240],{"class":185}," default",[117,242,243],{"class":189}," {\n",[117,245,247],{"class":119,"line":246},6,[117,248,249],{"class":189},"  extends: DefaultTheme,\n",[117,251,253,256,259,263],{"class":119,"line":252},7,[117,254,255],{"class":123},"  enhanceApp",[117,257,258],{"class":189},"({ ",[117,260,262],{"class":261},"s4XuR","app",[117,264,265],{"class":189}," }) {\n",[117,267,269,272,275,278],{"class":119,"line":268},8,[117,270,271],{"class":189},"    app.",[117,273,274],{"class":123},"use",[117,276,277],{"class":189},"(EduBeamPlot) ",[117,279,281],{"class":280},"sJ8bj","\u002F\u002F \u003CStructurePlot> and \u003CDiagramStack> in every page\n",[117,283,285],{"class":119,"line":284},9,[117,286,287],{"class":189},"  },\n",[117,289,291,294,297],{"class":119,"line":290},10,[117,292,293],{"class":189},"} ",[117,295,296],{"class":185},"satisfies",[117,298,299],{"class":123}," Theme\n",[14,301,302,303,173],{},"Then build and draw a model right in a page, next to ",[18,304,305],{},"frame.ts",[108,307,312],{"className":308,"code":309,"filename":310,"language":311,"meta":113,"style":113},"language-md shiki shiki-themes github-light github-dark","\u003Cscript setup lang=\"ts\">\nimport { portalFrame } from '.\u002Fframe' \u002F\u002F () => a solved LinearStaticSolver\n\nconst frame = portalFrame()\n\u003C\u002Fscript>\n\n# Portal frame\n\nThe bending moment under the design loads:\n\n\u003CStructurePlot :solver=\"frame\" :layers=\"['members', 'supports', 'loads', 'reactions', 'M']\" \u002F>\n","portal-frame.md","md",[18,313,314,319,324,328,333,338,342,347,351,356,360],{"__ignoreMap":113},[117,315,316],{"class":119,"line":120},[117,317,318],{},"\u003Cscript setup lang=\"ts\">\n",[117,320,321],{"class":119,"line":134},[117,322,323],{},"import { portalFrame } from '.\u002Fframe' \u002F\u002F () => a solved LinearStaticSolver\n",[117,325,326],{"class":119,"line":214},[117,327,231],{"emptyLinePlaceholder":230},[117,329,330],{"class":119,"line":227},[117,331,332],{},"const frame = portalFrame()\n",[117,334,335],{"class":119,"line":234},[117,336,337],{},"\u003C\u002Fscript>\n",[117,339,340],{"class":119,"line":246},[117,341,231],{"emptyLinePlaceholder":230},[117,343,344],{"class":119,"line":252},[117,345,346],{},"# Portal frame\n",[117,348,349],{"class":119,"line":268},[117,350,231],{"emptyLinePlaceholder":230},[117,352,353],{"class":119,"line":284},[117,354,355],{},"The bending moment under the design loads:\n",[117,357,358],{"class":119,"line":290},[117,359,231],{"emptyLinePlaceholder":230},[117,361,363],{"class":119,"line":362},11,[117,364,365],{},"\u003CStructurePlot :solver=\"frame\" :layers=\"['members', 'supports', 'loads', 'reactions', 'M']\" \u002F>\n",[14,367,368,371,372,374,375,379],{},[18,369,370],{},"vitepress build"," solves the frame and writes the finished SVG into the page's HTML, labels and all. In the browser the page takes over, and the plot fits itself to the column. ",[18,373,305],{}," is on the ",[51,376,378],{"href":377},"\u002Fplot\u002Fslides#a-figure-that-builds-up","Slides"," page.",[104,381,78],{"id":382},"nuxt",[14,384,385,386,173],{},"Nuxt renders on the server too; this site is built with it. Import the components in a page or component as usual, or register them for the whole app with a plugin in ",[18,387,388],{},"plugins\u002Fedubeam-plot.ts",[108,390,392],{"className":176,"code":391,"filename":388,"language":178,"meta":113,"style":113},"import { EduBeamPlot } from '@edubeam\u002Fplot'\n\nexport default defineNuxtPlugin((nuxtApp) => {\n  nuxtApp.vueApp.use(EduBeamPlot)\n})\n",[18,393,394,404,408,431,441],{"__ignoreMap":113},[117,395,396,398,400,402],{"class":119,"line":120},[117,397,186],{"class":185},[117,399,219],{"class":189},[117,401,193],{"class":185},[117,403,224],{"class":127},[117,405,406],{"class":119,"line":134},[117,407,231],{"emptyLinePlaceholder":230},[117,409,410,412,414,417,420,423,426,429],{"class":119,"line":214},[117,411,237],{"class":185},[117,413,240],{"class":185},[117,415,416],{"class":123}," defineNuxtPlugin",[117,418,419],{"class":189},"((",[117,421,422],{"class":261},"nuxtApp",[117,424,425],{"class":189},") ",[117,427,428],{"class":185},"=>",[117,430,243],{"class":189},[117,432,433,436,438],{"class":119,"line":227},[117,434,435],{"class":189},"  nuxtApp.vueApp.",[117,437,274],{"class":123},[117,439,440],{"class":189},"(EduBeamPlot)\n",[117,442,443],{"class":119,"line":234},[117,444,445],{"class":189},"})\n",[14,447,448,449,452,453,456,457,460,461,463],{},"On the server there is no box to measure, so a plot is laid out at its ",[18,450,451],{},"width"," prop: 640 px by default (400 px with ",[18,454,455],{},"compact","), 720 px for ",[18,458,459],{},"DiagramStack",". Once mounted it lays out again at its real width. If your column is much narrower or wider, give ",[18,462,451],{}," a closer guess and the figure will not change size as the page loads.",[104,465,467],{"id":466},"ship-the-drawing-not-the-solver","Ship the drawing, not the solver",[14,469,470,471,474,475,173],{},"A page that only shows a figure needs no solver. ",[18,472,473],{},"modelFromSolver"," reads a solved model into plain data: nodes, members, loads, reactions, and every member's N, V, M and displacements as exact polynomials. Make it at build time, with a script such as ",[18,476,477],{},"build-figures.ts",[108,479,481],{"className":176,"code":480,"filename":477,"language":178,"meta":113,"style":113},"import { writeFileSync } from 'node:fs'\nimport { modelFromSolver } from '@edubeam\u002Fplot'\nimport { portalFrame } from '.\u002Fframe.ts'\n\nwriteFileSync('portal-frame.json', JSON.stringify(modelFromSolver(portalFrame())))\n",[18,482,483,495,506,518,522],{"__ignoreMap":113},[117,484,485,487,490,492],{"class":119,"line":120},[117,486,186],{"class":185},[117,488,489],{"class":189}," { writeFileSync } ",[117,491,193],{"class":185},[117,493,494],{"class":127}," 'node:fs'\n",[117,496,497,499,502,504],{"class":119,"line":134},[117,498,186],{"class":185},[117,500,501],{"class":189}," { modelFromSolver } ",[117,503,193],{"class":185},[117,505,224],{"class":127},[117,507,508,510,513,515],{"class":119,"line":214},[117,509,186],{"class":185},[117,511,512],{"class":189}," { portalFrame } ",[117,514,193],{"class":185},[117,516,517],{"class":127}," '.\u002Fframe.ts'\n",[117,519,520],{"class":119,"line":227},[117,521,231],{"emptyLinePlaceholder":230},[117,523,524,527,530,533,536,540,543,546,548,550,552,555],{"class":119,"line":234},[117,525,526],{"class":123},"writeFileSync",[117,528,529],{"class":189},"(",[117,531,532],{"class":127},"'portal-frame.json'",[117,534,535],{"class":189},", ",[117,537,539],{"class":538},"sj4cs","JSON",[117,541,542],{"class":189},".",[117,544,545],{"class":123},"stringify",[117,547,529],{"class":189},[117,549,473],{"class":123},[117,551,529],{"class":189},[117,553,554],{"class":123},"portalFrame",[117,556,557],{"class":189},"())))\n",[14,559,560,561,564],{},"and draw it with the ",[18,562,563],{},"model"," prop:",[108,566,570],{"className":567,"code":568,"language":569,"meta":113,"style":113},"language-vue shiki shiki-themes github-light github-dark","\u003Cscript setup lang=\"ts\">\nimport { StructurePlot, type PlotModel } from '@edubeam\u002Fplot'\nimport frame from '.\u002Fportal-frame.json'\n\u003C\u002Fscript>\n\n\u003Ctemplate>\n  \u003CStructurePlot :model=\"frame as PlotModel\" \u002F>\n\u003C\u002Ftemplate>\n","vue",[18,571,572,596,613,625,634,638,647,680],{"__ignoreMap":113},[117,573,574,577,581,584,587,590,593],{"class":119,"line":120},[117,575,576],{"class":189},"\u003C",[117,578,580],{"class":579},"s9eBZ","script",[117,582,583],{"class":123}," setup",[117,585,586],{"class":123}," lang",[117,588,589],{"class":189},"=",[117,591,592],{"class":127},"\"ts\"",[117,594,595],{"class":189},">\n",[117,597,598,600,603,606,609,611],{"class":119,"line":134},[117,599,186],{"class":185},[117,601,602],{"class":189}," { StructurePlot, ",[117,604,605],{"class":185},"type",[117,607,608],{"class":189}," PlotModel } ",[117,610,193],{"class":185},[117,612,224],{"class":127},[117,614,615,617,620,622],{"class":119,"line":214},[117,616,186],{"class":185},[117,618,619],{"class":189}," frame ",[117,621,193],{"class":185},[117,623,624],{"class":127}," '.\u002Fportal-frame.json'\n",[117,626,627,630,632],{"class":119,"line":227},[117,628,629],{"class":189},"\u003C\u002F",[117,631,580],{"class":579},[117,633,595],{"class":189},[117,635,636],{"class":119,"line":234},[117,637,231],{"emptyLinePlaceholder":230},[117,639,640,642,645],{"class":119,"line":246},[117,641,576],{"class":189},[117,643,644],{"class":579},"template",[117,646,595],{"class":189},[117,648,649,652,655,658,660,662,665,668,671,674,677],{"class":119,"line":252},[117,650,651],{"class":189},"  \u003C",[117,653,654],{"class":579},"StructurePlot",[117,656,657],{"class":189}," :",[117,659,563],{"class":123},[117,661,589],{"class":189},[117,663,664],{"class":127},"\"",[117,666,667],{"class":189},"frame ",[117,669,670],{"class":185},"as",[117,672,673],{"class":123}," PlotModel",[117,675,676],{"class":127},"\" \u002F",[117,678,595],{"class":679},"s7hpK",[117,681,682,684,686],{"class":119,"line":268},[117,683,629],{"class":185},[117,685,644],{"class":189},[117,687,595],{"class":185},[14,689,690,691,693,694,542],{},"The portal frame is under 2 kB of JSON and draws exactly as its solver does. Every feature works on a model as on a solver, and ",[18,692,563],{}," wins if you give both. The format is in ",[51,695,697],{"href":696},"\u002Fplot\u002Fmodel","Plot model",[104,699,102],{"id":700},"plain-html-from-node",[14,702,703,706],{},[18,704,705],{},"structureSvg"," turns a model into the text of an SVG file, with plain colours and no styles or scripts. Paste it into any HTML, a static site generator, a Markdown file or a CMS. This script writes a page with one figure:",[108,708,711],{"className":176,"code":709,"filename":710,"language":178,"meta":113,"style":113},"import { writeFileSync } from 'node:fs'\nimport { modelFromSolver, structureSvg } from '@edubeam\u002Fplot'\nimport { portalFrame } from '.\u002Fframe.ts'\n\nconst svg = structureSvg(modelFromSolver(portalFrame()), { layers: ['members', 'supports', 'reactions', 'M'] })\nwriteFileSync('frame.html', `\u003C!doctype html>\u003Cmeta charset=\"utf-8\">\u003Ctitle>Portal frame\u003C\u002Ftitle>${svg}`)\n","frame-html.ts",[18,712,713,723,734,744,748,794],{"__ignoreMap":113},[117,714,715,717,719,721],{"class":119,"line":120},[117,716,186],{"class":185},[117,718,489],{"class":189},[117,720,193],{"class":185},[117,722,494],{"class":127},[117,724,725,727,730,732],{"class":119,"line":134},[117,726,186],{"class":185},[117,728,729],{"class":189}," { modelFromSolver, structureSvg } ",[117,731,193],{"class":185},[117,733,224],{"class":127},[117,735,736,738,740,742],{"class":119,"line":214},[117,737,186],{"class":185},[117,739,512],{"class":189},[117,741,193],{"class":185},[117,743,517],{"class":127},[117,745,746],{"class":119,"line":227},[117,747,231],{"emptyLinePlaceholder":230},[117,749,750,753,756,759,762,764,766,768,770,773,776,778,781,783,786,788,791],{"class":119,"line":234},[117,751,752],{"class":185},"const",[117,754,755],{"class":538}," svg",[117,757,758],{"class":185}," =",[117,760,761],{"class":123}," structureSvg",[117,763,529],{"class":189},[117,765,473],{"class":123},[117,767,529],{"class":189},[117,769,554],{"class":123},[117,771,772],{"class":189},"()), { layers: [",[117,774,775],{"class":127},"'members'",[117,777,535],{"class":189},[117,779,780],{"class":127},"'supports'",[117,782,535],{"class":189},[117,784,785],{"class":127},"'reactions'",[117,787,535],{"class":189},[117,789,790],{"class":127},"'M'",[117,792,793],{"class":189},"] })\n",[117,795,796,798,800,803,805,808,811,814],{"class":119,"line":246},[117,797,526],{"class":123},[117,799,529],{"class":189},[117,801,802],{"class":127},"'frame.html'",[117,804,535],{"class":189},[117,806,807],{"class":127},"`\u003C!doctype html>\u003Cmeta charset=\"utf-8\">\u003Ctitle>Portal frame\u003C\u002Ftitle>${",[117,809,810],{"class":189},"svg",[117,812,813],{"class":127},"}`",[117,815,816],{"class":189},")\n",[14,818,819,820,823,824,827,828,832,833,837],{},"Such a figure has the size it was written at, 640 px wide by default (",[18,821,822],{},"max-width: 100%; height: auto"," lets it shrink with the column), and a white background of its own; ",[18,825,826],{},"background: false"," leaves it transparent. It does not follow a dark theme or read values under the pointer: for that, render the component. The ",[51,829,831],{"href":830},"\u002Fplot\u002Fexercises#print-a-test","test generator"," prints a whole test this way, and ",[51,834,836],{"href":835},"\u002Fplot\u002Ffunctions#a-standalone-svg-file","A standalone SVG file"," lists the options.",[839,840,841],"style",{},"html pre.shiki code .szBVR, html code.shiki .szBVR{--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .s4XuR, html code.shiki .s4XuR{--shiki-default:#E36209;--shiki-dark:#FFAB70}html pre.shiki code .sJ8bj, html code.shiki .sJ8bj{--shiki-default:#6A737D;--shiki-dark:#6A737D}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 .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .s9eBZ, html code.shiki .s9eBZ{--shiki-default:#22863A;--shiki-dark:#85E89D}html pre.shiki code .s7hpK, html code.shiki .s7hpK{--shiki-default:#B31D28;--shiki-default-font-style:italic;--shiki-dark:#FDAEB7;--shiki-dark-font-style:italic}",{"title":113,"searchDepth":134,"depth":214,"links":843},[844,845,846,847,848],{"id":106,"depth":134,"text":54},{"id":160,"depth":134,"text":66},{"id":382,"depth":134,"text":78},{"id":466,"depth":134,"text":467},{"id":700,"depth":134,"text":102},"Put @edubeam\u002Fplot figures in a Vite app, VitePress notes or a Nuxt site, render them on the server, ship pre-solved models, or write plain SVG files.",null,{"source":852},"site","\u002Fplot\u002Fembedding",{"title":5,"description":849},"plot\u002Fembedding","4nPILRoH_u9mtVfzYRcl87APWwuTcIoiEDBuEzg4p70",[858,861,864,866,869,873,876,877,881,882],{"path":859,"title":152,"order":120,"group":860},"\u002Fplot\u002Fgetting-started","Introduction",{"path":862,"title":654,"order":134,"group":863},"\u002Fplot\u002Fstructure-plot","Components",{"path":865,"title":459,"order":214,"group":850},"\u002Fplot\u002Fdiagram-stack",{"path":867,"title":868,"order":227,"group":850},"\u002Fplot\u002Ftheming","Theming and colours",{"path":870,"title":871,"order":234,"group":872},"\u002Fplot\u002Fexercises","Exercises and tests","Use cases",{"path":874,"title":875,"order":246,"group":850},"\u002Fplot\u002Fslides","Slides and notes",{"path":853,"title":5,"order":252,"group":850},{"path":878,"title":879,"order":268,"group":880},"\u002Fplot\u002Fcomponents","Component API","Reference",{"path":696,"title":697,"order":284,"group":850},{"path":883,"title":884,"order":290,"group":850},"\u002Fplot\u002Ffunctions","Functions",1795108676435]