@cascivo/charts 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  <!-- generated by scripts/readme/generate.ts — edit readme.body.md, not this file -->
2
2
 
3
3
  <div align="center">
4
- <a href="https://cascivo.com"><img src="https://cascivo.com/favicon.svg" width="72" height="72" alt="cascivo logo"></a>
4
+ <a href="https://cascivo.com"><img src="https://cascivo.com/logo-mark-img-accent.svg" width="72" height="72" alt="cascivo logo"></a>
5
5
  <h1>@cascivo/charts</h1>
6
6
  <p><strong>Chart components built from scratch — scales, shapes, and signal-driven rendering, zero dependencies. Colors come from @cascivo/themes; components from @cascivo/react. Docs offline: npx @cascivo/docs</strong></p>
7
7
 
@@ -169,4 +169,4 @@ pnpm add @cascivo/charts
169
169
 
170
170
  [cascivo.com](https://cascivo.com) · [Docs](https://cascivo.com/docs) · [Storybook](https://storybook.cascivo.com) · [GitHub](https://github.com/cascivo/cascivo) · AI agents: read [`llms.txt`](https://cascivo.com/llms.txt) (install steps + component index, plain text) or use [`@cascivo/mcp`](https://github.com/cascivo/cascivo/tree/main/packages/mcp) and [`registry.json`](https://github.com/cascivo/cascivo/blob/main/registry.json) · MIT
171
171
 
172
- <div align="center"><a href="https://cascivo.com"><img src="https://cascivo.com/favicon.svg" width="28" height="28" alt="cascivo"></a></div>
172
+ <div align="center"><a href="https://cascivo.com"><img src="https://cascivo.com/logo-mark-img.svg" width="28" height="28" alt="cascivo"></a></div>
@@ -0,0 +1 @@
1
+ "use client";function e(e,n){let[r,i]=e,[a,o]=n,s=i-r;return{domain:e,range:n,map:e=>s===0?a:a+(e-r)/s*(o-a),invert:e=>o-a===0?r:r+(e-a)/(o-a)*s,ticks:(e=5,n)=>t(r,i,e,n)}}function t(e,t,n=5,r){if(!Number.isFinite(e)||!Number.isFinite(t)||e===t)return[e];e>t&&([e,t]=[t,e]);let i=r??!(Number.isInteger(e)&&Number.isInteger(t)),a=(t-e)/Math.max(1,n),o=10**Math.floor(Math.log10(a)),s=i?[1,2,2.5,5,10]:[1,2,5,10],c=a/o,l=(s.find(e=>e>=c)??10)*o;i||(l=Math.max(1,Math.round(l)));let u=Math.ceil(e/l),d=Math.floor(t/l+1e-9),f=[],p=Math.max(0,Math.ceil(-Math.log10(l))+2);for(let e=u;e<=d;e++)f.push(parseFloat((e*l).toFixed(p)));return f}function n(e,t,n=.1){let[r,i]=t,a=e.length,o=(i-r)/Math.max(1,a+n*(a+1)),s=o,c=o*n,l=new Map(e.map((e,t)=>[e,t]));return{domain:e,range:t,bandwidth:s,map:e=>{let t=l.get(e);return t===void 0?void 0:r+c+t*(o+c)}}}function r(e,t){let[n,r]=e,[i,a]=t,o=Math.sqrt(Math.max(0,n)),s=Math.sqrt(Math.max(0,r))-o;return e=>s===0?(i+a)/2:i+(Math.sqrt(Math.max(0,e))-o)/s*(a-i)}function i(e){return Math.round(e*100)/100}function a(e,t=!1){if(t){let t=e.filter(e=>e!==null);return t.length>0?[t]:[]}let n=[],r=[];for(let t of e)t===null?(r.length>0&&n.push(r),r=[]):r.push(t);return r.length>0&&n.push(r),n}function o(e,t=`linear`){if(e.length===0)return``;if(e.length===1||t===`linear`)return e.map(([e,t],n)=>`${n===0?`M`:`L`}${e},${t}`).join(``);switch(t){case`monotone`:return p(e);case`step`:case`stepBefore`:case`stepAfter`:return s(e,t);case`natural`:return l(e);case`basis`:return u(e);case`cardinal`:return d(e,0);case`catmullRom`:return f(e,.5);default:return p(e)}}function s(e,t){let n=`M${e[0][0]},${e[0][1]}`;for(let r=0;r<e.length-1;r++){let[i,a]=e[r],[o,s]=e[r+1];if(t===`stepBefore`)n+=`L${i},${s}L${o},${s}`;else if(t===`stepAfter`)n+=`L${o},${a}L${o},${s}`;else{let e=(i+o)/2;n+=`L${e},${a}L${e},${s}L${o},${s}`}}return n}function c(e){let t=e.length-1;if(t<1)return[[],[]];let n=Array(t),r=Array(t),i=Array(t);r[0]=2,i[0]=e[0]+2*e[1];for(let a=1;a<t-1;a++)n[a]=1,r[a]=4,i[a]=4*e[a]+2*e[a+1];n[t-1]=2,r[t-1]=7,i[t-1]=8*e[t-1]+e[t];for(let e=1;e<t;e++){let t=(n[e]??0)/r[e-1];r[e]=r[e]-t,i[e]=i[e]-t*i[e-1]}let a=Array(t),o=Array(t);a[t-1]=i[t-1]/r[t-1];for(let e=t-2;e>=0;e--)a[e]=(i[e]-a[e+1])/r[e];for(let n=0;n<t-1;n++)o[n]=2*e[n+1]-a[n+1];return o[t-1]=(e[t]+a[t-1])/2,[a,o]}function l(e){let t=e.length;if(t<3)return e.map(([e,t],n)=>`${n===0?`M`:`L`}${e},${t}`).join(``);let n=e.map(e=>e[0]),r=e.map(e=>e[1]),[i,a]=c(n),[o,s]=c(r),l=`M${n[0]},${r[0]}`;for(let e=0;e<t-1;e++)l+=`C${i[e]},${o[e]} ${a[e]},${s[e]} ${n[e+1]},${r[e+1]}`;return l}function u(e){let t=e.length;if(t<3)return e.map(([e,t],n)=>`${n===0?`M`:`L`}${e},${t}`).join(``);let n=n=>e[Math.max(0,Math.min(t-1,n))][0],r=n=>e[Math.max(0,Math.min(t-1,n))][1],i=`M${n(0)},${r(0)}`;for(let e=0;e<t-1;e++){let t=n(e-1),a=r(e-1),o=n(e),s=r(e),c=n(e+1),l=r(e+1),u=(2*t+o)/3,d=(2*a+s)/3,f=(t+2*o)/3,p=(a+2*s)/3,m=(t+4*o+c)/6,h=(a+4*s+l)/6;i+=`C${u},${d} ${f},${p} ${m},${h}`}let a=e[t-1];return i+=`L${a[0]},${a[1]}`,i}function d(e,t){let n=e.length;if(n<3)return e.map(([e,t],n)=>`${n===0?`M`:`L`}${e},${t}`).join(``);let r=(1-t)/6,i=t=>e[Math.max(0,Math.min(n-1,t))],a=`M${e[0][0]},${e[0][1]}`;for(let e=0;e<n-1;e++){let t=i(e-1),n=i(e),o=i(e+1),s=i(e+2),c=n[0]+r*(o[0]-t[0]),l=n[1]+r*(o[1]-t[1]),u=o[0]-r*(s[0]-n[0]),d=o[1]-r*(s[1]-n[1]);a+=`C${c},${l} ${u},${d} ${o[0]},${o[1]}`}return a}function f(e,t){let n=e.length;if(n<3)return e.map(([e,t],n)=>`${n===0?`M`:`L`}${e},${t}`).join(``);let r=t=>e[Math.max(0,Math.min(n-1,t))],i=(e,t)=>Math.hypot(t[0]-e[0],t[1]-e[1]),a=`M${e[0][0]},${e[0][1]}`;for(let e=0;e<n-1;e++){let n=r(e-1),o=r(e),s=r(e+1),c=r(e+2),l=i(n,o)**+t||1e-6,u=i(o,s)**+t||1e-6,d=i(s,c)**+t||1e-6,f=s[0]-o[0]+u*((o[0]-n[0])/l-(s[0]-n[0])/(l+u)),p=s[1]-o[1]+u*((o[1]-n[1])/l-(s[1]-n[1])/(l+u)),m=s[0]-o[0]+u*((c[0]-s[0])/d-(c[0]-o[0])/(u+d)),h=s[1]-o[1]+u*((c[1]-s[1])/d-(c[1]-o[1])/(u+d)),g=o[0]+f/3,_=o[1]+p/3,v=s[0]-m/3,y=s[1]-h/3;a+=`C${g},${_} ${v},${y} ${s[0]},${s[1]}`}return a}function p(e){let t=e.length,n=[],r=[],i=[];for(let a=0;a<t-1;a++)n[a]=e[a+1][0]-e[a][0],r[a]=e[a+1][1]-e[a][1],i[a]=n[a]===0?0:r[a]/n[a];let a=[i[0]??0];for(let e=1;e<t-1;e++){let t=i[e-1],n=i[e];a[e]=t*n<=0?0:2*t*n/(t+n)}a[t-1]=i[t-2]??0;let o=`M${e[0][0]},${e[0][1]}`;for(let n=0;n<t-1;n++){let[t,r]=e[n],[i,s]=e[n+1],c=(i-t)/3;o+=`C${t+c},${r+c*a[n]} ${i-c},${s-c*a[n+1]} ${i},${s}`}return o}function m(e,t,n=`linear`){if(e.length===0)return``;let r=o(e,n),i=e[e.length-1],a=e[0];return`${r}L${i[0]},${t}L${a[0]},${t}Z`}function h(e,t,n,r,a,o){let s=2*Math.PI;if(Math.abs(o-a)>=s-1e-9){let i=a+Math.PI;return h(e,t,n,r,a,i)+h(e,t,n,r,i,a+s-1e-9)}let c=(n,r)=>[i(e+n*Math.sin(r)),i(t-n*Math.cos(r))],l=+(o-a>Math.PI),u=i(n),d=i(r),[f,p]=c(n,a),[m,g]=c(n,o);if(r<=0)return`M${i(e)},${i(t)}L${f},${p}A${u},${u} 0 ${l} 1 ${m},${g}Z`;let[_,v]=c(r,o),[y,b]=c(r,a);return`M${f},${p}A${u},${u} 0 ${l} 1 ${m},${g}L${_},${v}A${d},${d} 0 ${l} 0 ${y},${b}Z`}function g(e){let t=e[0]?.length??0,n=Array.from({length:t},()=>0);return e.map(e=>e.map((e,t)=>{let r=n[t];return n[t]=r+e,[r,n[t]]}))}var _={frame:`_frame_1gm0a_2`,"cascivo-chart-in":`_cascivo-chart-in_1gm0a_1`,fallback:`_fallback_1gm0a_78`};export{i as a,n as c,r as d,o as i,e as l,h as n,a as o,m as r,g as s,_ as t,t as u};
package/dist/index.d.ts CHANGED
@@ -1896,6 +1896,12 @@ interface ScatterChartProps {
1896
1896
  series: readonly ScatterChartSeries[];
1897
1897
  title: string;
1898
1898
  description?: string;
1899
+ /**
1900
+ * Point radius or accessor
1901
+ *
1902
+ * @defaultValue `4`
1903
+ * @see the component manifest
1904
+ */
1899
1905
  r?: number | ((d: ScatterDatum) => number);
1900
1906
  /**
1901
1907
  * Fixed SVG width in px. ⚠ **Omit for a responsive chart** — the chart fills and tracks
@@ -2920,7 +2926,12 @@ interface CandlestickProps {
2920
2926
  upColor?: string;
2921
2927
  /** Colour for down candles (close < open). */
2922
2928
  downColor?: string;
2923
- /** Render volume bars beneath the candles. */
2929
+ /**
2930
+ * Render volume bars beneath the candles.
2931
+ *
2932
+ * @defaultValue `false`
2933
+ * @see the component manifest
2934
+ */
2924
2935
  volume?: boolean;
2925
2936
  tooltip?: boolean;
2926
2937
  className?: string;