Skip to content

Commit 2dc62a5

Browse files
committed
v6.4.2
1 parent 732e4ed commit 2dc62a5

File tree

104 files changed

+329
-323
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+329
-323
lines changed

coverage.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"tests":7099,"assertions":32899,"lines":{"total":2328,"covered":2328,"skipped":0,"pct":100},"statements":{"total":2517,"covered":2517,"skipped":0,"pct":100},"functions":{"total":1006,"covered":1006,"skipped":0,"pct":100},"branches":{"total":878,"covered":878,"skipped":0,"pct":100},"branchesTrue":{"total":0,"covered":0,"skipped":0,"pct":100}}
1+
{"tests":7100,"assertions":32900,"lines":{"total":2328,"covered":2328,"skipped":0,"pct":100},"statements":{"total":2517,"covered":2517,"skipped":0,"pct":100},"functions":{"total":1006,"covered":1006,"skipped":0,"pct":100},"branches":{"total":878,"covered":878,"skipped":0,"pct":100},"branchesTrue":{"total":0,"covered":0,"skipped":0,"pct":100}}

docs/demos/car-analysis/article.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<nav><ul><li><a href="/">TinyBase</a></li><li><a href="/demos/">Demos</a></li><li><a href="/demos/car-analysis/">Car Analysis</a></li></ul></nav><section class="s1" id="/demos/car-analysis/" data-id="CA"><h1>Car Analysis</h1><iframe srcdoc="&lt;html&gt;&lt;head&gt;&lt;script type=&quot;importmap&quot;&gt;{
22
&quot;imports&quot;: {
3-
&quot;tinybase&quot;: &quot;https://esm.sh/[email protected].1&quot;,
4-
&quot;tinybase/ui-react&quot;: &quot;https://esm.sh/[email protected].1/ui-react&quot;,
5-
&quot;tinybase/ui-react-dom&quot;: &quot;https://esm.sh/[email protected].1/ui-react-dom&quot;,
6-
&quot;tinybase/ui-react-inspector&quot;: &quot;https://esm.sh/[email protected].1/ui-react-inspector&quot;,
3+
&quot;tinybase&quot;: &quot;https://esm.sh/[email protected].2&quot;,
4+
&quot;tinybase/ui-react&quot;: &quot;https://esm.sh/[email protected].2/ui-react&quot;,
5+
&quot;tinybase/ui-react-dom&quot;: &quot;https://esm.sh/[email protected].2/ui-react-dom&quot;,
6+
&quot;tinybase/ui-react-inspector&quot;: &quot;https://esm.sh/[email protected].2/ui-react-inspector&quot;,
77
&quot;react&quot;: &quot;https://esm.sh/react@^19.0.0&quot;,
88
&quot;react/jsx-runtime&quot;: &quot;https://esm.sh/react@^19.0.0/jsx-runtime&quot;,
99
&quot;react-dom/client&quot;: &quot;https://esm.sh/react-dom@^19.0.0/client&quot;
@@ -12,10 +12,10 @@
1212
`),t=a.shift().split(&quot; &quot;);s.transaction(()=&gt;a.forEach((o,i)=&gt;{const n=o.split(&quot; &quot;);n.length==t.length&amp;&amp;n.forEach((c,p)=&gt;{c!=&quot;&quot;&amp;&amp;(z.test(c)&amp;&amp;(c=parseFloat(c)),s.setCell(&quot;cars&quot;,i,t[p],c))})}))},V=()=&gt;{const[s,a]=y([&quot;Manufacturer&quot;]),[t,o]=y([&quot;MPG&quot;,&quot;Horsepower&quot;]),[i,n]=y(&quot;Average&quot;),[c,p]=y(!1),h=J(s,t,i);return b(C,{children:[b(&quot;aside&quot;,{children:[e(&quot;b&quot;,{children:&quot;Dimensions&quot;}),e(S,{options:F,selected:s,onOptionsChange:a}),e(&quot;hr&quot;,{}),e(&quot;b&quot;,{children:&quot;Measures&quot;}),e(S,{options:Y,selected:t,onOptionsChange:o}),e(&quot;hr&quot;,{}),e(&quot;b&quot;,{children:&quot;Aggregate&quot;}),e(S,{options:Object.keys(I),selected:[i],onOptionsChange:n,multiple:!1}),e(&quot;hr&quot;,{}),e(&quot;input&quot;,{id:&quot;showTable&quot;,type:&quot;checkbox&quot;,checked:c,onChange:A(({target:d})=&gt;p(d.checked),[])}),e(&quot;label&quot;,{for:&quot;showTable&quot;,children:&quot;Show table&quot;}),e(&quot;br&quot;,{}),e(&quot;small&quot;,{children:e(&quot;a&quot;,{href:&quot;https://github.com/vega/vega-datasets/blob/next/data/cars.json&quot;,children:&quot;Source&quot;})})]}),c?e(K,{queryId:h,columns:[...s,...t]}):e(ee,{queryId:h,dimensions:s,measures:t})]})},J=(s,a,t)=&gt;R(()=&gt;(q().setQueryDefinition(&quot;query&quot;,&quot;cars&quot;,({select:o,group:i})=&gt;{s.forEach(n=&gt;o(n)),a.forEach(n=&gt;{o(n),i(n,I[t])})}),&quot;query&quot;),[s,a,t]),K=({queryId:s,columns:a})=&gt;e(Q,{queryId:s,sortOnClick:!0,paginator:!0,limit:10,idColumn:!1,customCells:R(()=&gt;Object.fromEntries(a.map(t=&gt;[t,{component:Z}])),[...a])}),Z=({queryId:s,rowId:a,cellId:t})=&gt;{const o=H(s,a,t);return e(&quot;span&quot;,{className:t,children:Number.isFinite(o)?$(o):o})},ee=({queryId:s,dimensions:a,measures:t})=&gt;{const o=O(null),[{width:i=0,height:n=0},c]=y({});G(()=&gt;{const r=new ResizeObserver(([{contentRect:u}])=&gt;c(u));return r.observe(o.current),()=&gt;r.disconnect()},[o]);const[p,h,d]=te(s,a,t),[l,m,x,v,E]=se(i,n,p,d);return i==0||n==0?e(&quot;main&quot;,{ref:o}):e(&quot;main&quot;,{ref:o,children:b(&quot;svg&quot;,{xmlns:&quot;http://www.w3.org/2000/svg&quot;,viewBox:`0 0 ${i} ${n}`,children:[e(&quot;path&quot;,{d:`M${l(0)} ${m(0)}H${l(E)}`}),e(C,{children:x.map((r,u)=&gt;{const f=l(u)-w/2,g=m(0)+M;return r&amp;&amp;e(&quot;text&quot;,{transform:`translate(${f} ${g}) rotate(90)`,children:r},u)})}),e(C,{children:v.map(r=&gt;{const u=l(0)-M,f=m(r)+w/2;return e(&quot;text&quot;,{transform:`translate(${u} ${f})`,&quot;text-anchor&quot;:&quot;end&quot;,children:r},r)})}),h.map((r,u)=&gt;b(&quot;g&quot;,{className:t[u],children:[e(&quot;path&quot;,{d:r.map((f,g)=&gt;`${g==0?&quot;M&quot;:&quot;L&quot;}${l(g)} ${m(f)}`).join(&quot;&quot;)}),r.map((f,g)=&gt;b(C,{children:[e(&quot;circle&quot;,{cx:l(g),cy:m(f),r:M}),b(&quot;text&quot;,{x:l(g),y:m(f)-w,children:[p[g],&quot; &quot;,t[u],&quot;: &quot;,$(f)]})]}))]},u))]})})},te=(s,a,t)=&gt;{const o=j(s),i=_(s,t[0]??void 0);return R(()=&gt;{const n=[1],c=[],p=t.map(()=&gt;[]);return i.forEach(h=&gt;{const d=o[h];c.push(a.map(l=&gt;d[l]).join(&quot;, &quot;)),t.forEach((l,m)=&gt;{n.push(d[l]),p[m].push(d[l])})}),[c,p,Math.max(...n)]},[o,i,t,a])},se=(s,a,t,o)=&gt;R(()=&gt;{const i=a/4,n=s/15,c=s-n-M,p=a-i-M,h=t.length-1,d=t.map((r,u)=&gt;u%Math.ceil(w*h/c)==0?r:null),l=Math.pow(10,Math.floor(Math.log10(o))),m=Math.ceil(o/l)*l,x=Math.ceil(o/l),v=x&lt;=2?5:x&lt;=5?2:1,E=Array(v*x+1).fill().map((r,u)=&gt;u*l/v);return[r=&gt;n+r*c/h,r=&gt;M+p-r*p/m,d,E,h,m]},[s,a,t,o]),S=({options:s,selected:a,onOptionsChange:t,multiple:o=!0})=&gt;{const i=A(({target:n})=&gt;t(o?[...n.selectedOptions].map(c=&gt;c.value):n.value),[t]);return e(&quot;select&quot;,{multiple:o,size:s.length,onChange:i,children:s.map(n=&gt;e(&quot;option&quot;,{value:n,selected:a.includes(n),className:n,children:n}))})};&lt;/script&gt;&lt;/html&gt;"></iframe><p>In this demo, we build an app that showcases the query capabilities of TinyBase v2.0, grouping and sorting dimensional data for lightweight analytical usage.</p><p>The data from this demo is derived from <code>cars.json</code> in the <a href="https://github.com/vega/vega-datasets">Vega datasets</a> - thank you <a href="https://idl.cs.washington.edu/">UW Interactive Data Lab</a>!</p><h3 id="an-overview-of-the-data">An Overview Of The Data</h3><p>Before looking at code, let&#x27;s familiarize ourselves with the data used in this application.</p><p>The raw data is loaded from a TSV file into one single <a href="/api/store/type-aliases/store/table/"><code>Table</code></a> object: <code>cars</code>, and comprises almost 400 records of cars made in the 1970s and 1980s.</p><p>For each, the data includes the manufacturer, the car name, year, and region. These <a href="/api/store/type-aliases/store/cell/"><code>Cell</code></a> values are &#x27;dimensions&#x27; with which the data can be grouped.</p><p>Each record also includes a number of quantitative fields, including the car&#x27;s miles-per-gallon (MPG), the number of cylinders, their displacement, its horsepower, weight, and acceleration. These <a href="/api/store/type-aliases/store/cell/"><code>Cell</code></a> values are &#x27;measures&#x27; which can be aggregated together - in this basic app, to find their average, maximum, or minimum.</p><p>The app is oriented around one single query. As the user picks different dimensions or measures in the app&#x27;s sidebar, that query is re-run and the results (either in graphical or tabular form) reactively update immediately.</p><h3 id="boilerplate">Boilerplate</h3><p>First, we create the import aliases for TinyBase and React modules we&#x27;ll need:</p><pre><code><span class="tag"><span class="tag"><span class="punctuation">&lt;</span>script</span> <span class="attr-name">type</span><span class="attr-value"><span class="punctuation">=</span><span class="punctuation">"</span>importmap<span class="punctuation">"</span></span><span class="punctuation">></span></span><span class="script"><span class="language-javascript">
1313
<span class="punctuation">{</span>
1414
<span class="string-property">"imports"</span><span class="operator">:</span> <span class="punctuation">{</span>
15-
<span class="string-property">"tinybase"</span><span class="operator">:</span> <span class="string">"https://esm.sh/[email protected].1"</span><span class="punctuation">,</span>
16-
<span class="string-property">"tinybase/ui-react"</span><span class="operator">:</span> <span class="string">"https://esm.sh/[email protected].1/ui-react"</span><span class="punctuation">,</span>
17-
<span class="string-property">"tinybase/ui-react-dom"</span><span class="operator">:</span> <span class="string">"https://esm.sh/[email protected].1/ui-react-dom"</span><span class="punctuation">,</span>
18-
<span class="string-property">"tinybase/ui-react-inspector"</span><span class="operator">:</span> <span class="string">"https://esm.sh/[email protected].1/ui-react-inspector"</span><span class="punctuation">,</span>
15+
<span class="string-property">"tinybase"</span><span class="operator">:</span> <span class="string">"https://esm.sh/[email protected].2"</span><span class="punctuation">,</span>
16+
<span class="string-property">"tinybase/ui-react"</span><span class="operator">:</span> <span class="string">"https://esm.sh/[email protected].2/ui-react"</span><span class="punctuation">,</span>
17+
<span class="string-property">"tinybase/ui-react-dom"</span><span class="operator">:</span> <span class="string">"https://esm.sh/[email protected].2/ui-react-dom"</span><span class="punctuation">,</span>
18+
<span class="string-property">"tinybase/ui-react-inspector"</span><span class="operator">:</span> <span class="string">"https://esm.sh/[email protected].2/ui-react-inspector"</span><span class="punctuation">,</span>
1919
<span class="string-property">"react"</span><span class="operator">:</span> <span class="string">"https://esm.sh/react@^19.0.0"</span><span class="punctuation">,</span>
2020
<span class="string-property">"react/jsx-runtime"</span><span class="operator">:</span> <span class="string">"https://esm.sh/react@^19.0.0/jsx-runtime"</span><span class="punctuation">,</span>
2121
<span class="string-property">"react-dom/client"</span><span class="operator">:</span> <span class="string">"https://esm.sh/react-dom@^19.0.0/client"</span>

0 commit comments

Comments
 (0)