semiotic 3.1.2 → 3.2.1
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/CLAUDE.md +173 -213
- package/LICENSE +197 -10
- package/README.md +12 -11
- package/ai/dist/componentRegistry.js +6 -0
- package/ai/dist/mcp-server.js +115 -5
- package/ai/examples.md +184 -0
- package/ai/schema.json +4140 -888
- package/ai/system-prompt.md +36 -1
- package/dist/components/ChartContainer.d.ts +2 -0
- package/dist/components/DataSummaryContext.d.ts +12 -0
- package/dist/components/ThemeProvider.d.ts +5 -3
- package/dist/components/Tooltip/FlippingTooltip.d.ts +34 -0
- package/dist/components/charts/geo/ChoroplethMap.d.ts +1 -1
- package/dist/components/charts/index.d.ts +12 -1
- package/dist/components/charts/ordinal/BarChart.d.ts +4 -1
- package/dist/components/charts/ordinal/BoxPlot.d.ts +4 -1
- package/dist/components/charts/ordinal/DonutChart.d.ts +1 -1
- package/dist/components/charts/ordinal/DotPlot.d.ts +4 -1
- package/dist/components/charts/ordinal/FunnelChart.d.ts +57 -0
- package/dist/components/charts/ordinal/GroupedBarChart.d.ts +4 -1
- package/dist/components/charts/ordinal/Histogram.d.ts +17 -2
- package/dist/components/charts/ordinal/LikertChart.d.ts +94 -0
- package/dist/components/charts/ordinal/PieChart.d.ts +1 -1
- package/dist/components/charts/ordinal/RidgelinePlot.d.ts +12 -7
- package/dist/components/charts/ordinal/StackedBarChart.d.ts +4 -1
- package/dist/components/charts/ordinal/SwarmPlot.d.ts +15 -1
- package/dist/components/charts/ordinal/SwimlaneChart.d.ts +65 -0
- package/dist/components/charts/ordinal/ViolinPlot.d.ts +17 -2
- package/dist/components/charts/realtime/RealtimeHistogram.d.ts +20 -0
- package/dist/components/charts/shared/annotationResolvers.d.ts +28 -0
- package/dist/components/charts/shared/colorManipulation.d.ts +15 -0
- package/dist/components/charts/shared/formatUtils.d.ts +28 -0
- package/dist/components/charts/shared/hatchPattern.d.ts +35 -0
- package/dist/components/charts/shared/hooks.d.ts +39 -3
- package/dist/components/charts/shared/legendUtils.d.ts +2 -1
- package/dist/components/charts/shared/selectionUtils.d.ts +16 -1
- package/dist/components/charts/shared/statisticalOverlays.d.ts +49 -5
- package/dist/components/charts/shared/statsTooltip.d.ts +11 -0
- package/dist/components/charts/shared/types.d.ts +26 -2
- package/dist/components/charts/shared/useChartSetup.d.ts +12 -2
- package/dist/components/charts/shared/useLikertAggregation.d.ts +51 -0
- package/dist/components/charts/shared/useOrdinalBrush.d.ts +28 -0
- package/dist/components/charts/shared/useOrdinalStreaming.d.ts +54 -0
- package/dist/components/charts/shared/useStreamingLegend.d.ts +2 -2
- package/dist/components/charts/shared/validateProps.d.ts +2 -2
- package/dist/components/charts/shared/validationMap.d.ts +12 -0
- package/dist/components/charts/xy/AreaChart.d.ts +11 -0
- package/dist/components/charts/xy/Heatmap.d.ts +1 -1
- package/dist/components/charts/xy/MinimapChart.d.ts +1 -1
- package/dist/components/charts/xy/MultiAxisLineChart.d.ts +71 -0
- package/dist/components/charts/xy/StackedAreaChart.d.ts +11 -0
- package/dist/components/realtime/types.d.ts +6 -0
- package/dist/components/semiotic-ai.d.ts +4 -0
- package/dist/components/semiotic-ordinal.d.ts +5 -0
- package/dist/components/semiotic-themes.d.ts +80 -0
- package/dist/components/semiotic-utils.d.ts +30 -0
- package/dist/components/semiotic-xy.d.ts +1 -0
- package/dist/components/semiotic.d.ts +11 -5
- package/dist/components/store/LinkedCrosshairStore.d.ts +11 -0
- package/dist/components/store/ThemeStore.d.ts +22 -2
- package/dist/components/store/useSelection.d.ts +1 -0
- package/dist/components/stream/AccessibleDataTable.d.ts +28 -6
- package/dist/components/stream/FocusRing.d.ts +33 -0
- package/dist/components/stream/OrdinalBrushOverlay.d.ts +43 -0
- package/dist/components/stream/OrdinalPipelineStore.d.ts +16 -0
- package/dist/components/stream/OrdinalSVGOverlay.d.ts +2 -1
- package/dist/components/stream/PipelineStore.d.ts +7 -47
- package/dist/components/stream/SVGOverlay.d.ts +9 -3
- package/dist/components/stream/SceneGraph.d.ts +6 -1
- package/dist/components/stream/XYBrushOverlay.d.ts +47 -0
- package/dist/components/stream/accessorUtils.d.ts +14 -0
- package/dist/components/stream/geoTypes.d.ts +5 -1
- package/dist/components/stream/keyboardNav.d.ts +85 -9
- package/dist/components/stream/layouts/hierarchySceneBuilders.d.ts +35 -0
- package/dist/components/stream/layouts/hierarchyUtils.d.ts +25 -0
- package/dist/components/stream/networkTypes.d.ts +7 -1
- package/dist/components/stream/ordinalSceneBuilders/barFunnelScene.d.ts +27 -0
- package/dist/components/stream/ordinalSceneBuilders/funnelScene.d.ts +26 -0
- package/dist/components/stream/ordinalSceneBuilders/swimlaneScene.d.ts +12 -0
- package/dist/components/stream/ordinalTypes.d.ts +30 -4
- package/dist/components/stream/pipelineDecay.d.ts +20 -0
- package/dist/components/stream/pipelinePulse.d.ts +24 -0
- package/dist/components/stream/pipelineTransitions.d.ts +59 -0
- package/dist/components/stream/renderers/barFunnelCanvasRenderer.d.ts +12 -0
- package/dist/components/stream/renderers/pointCanvasRenderer.d.ts +2 -1
- package/dist/components/stream/renderers/trapezoidCanvasRenderer.d.ts +15 -0
- package/dist/components/stream/sceneUtils.d.ts +10 -0
- package/dist/components/stream/types.d.ts +29 -4
- package/dist/components/stream/useMediaPreferences.d.ts +11 -0
- package/dist/components/stream/xySceneBuilders/areaScene.d.ts +13 -0
- package/dist/components/stream/xySceneBuilders/barScene.d.ts +18 -0
- package/dist/components/stream/xySceneBuilders/boundsScene.d.ts +8 -0
- package/dist/components/stream/xySceneBuilders/candlestickScene.d.ts +10 -0
- package/dist/components/stream/xySceneBuilders/emitPointNodes.d.ts +13 -0
- package/dist/components/stream/xySceneBuilders/heatmapScene.d.ts +3 -0
- package/dist/components/stream/xySceneBuilders/lineScene.d.ts +12 -0
- package/dist/components/stream/xySceneBuilders/pointScene.d.ts +12 -0
- package/dist/components/stream/xySceneBuilders/swarmScene.d.ts +10 -0
- package/dist/components/stream/xySceneBuilders/types.d.ts +93 -0
- package/dist/components/stream/xySceneBuilders/waterfallScene.d.ts +12 -0
- package/dist/geo.min.js +1 -1
- package/dist/geo.module.min.js +1 -1
- package/dist/network.min.js +1 -1
- package/dist/network.module.min.js +1 -1
- package/dist/ordinal.min.js +1 -1
- package/dist/ordinal.module.min.js +1 -1
- package/dist/realtime.min.js +1 -1
- package/dist/realtime.module.min.js +1 -1
- package/dist/semiotic-ai-statisticalOverlays-C2PPlmXv.js +1 -0
- package/dist/semiotic-ai.d.ts +4 -0
- package/dist/semiotic-ai.min.js +1 -1
- package/dist/semiotic-ai.module.min.js +1 -1
- package/dist/semiotic-ordinal.d.ts +5 -0
- package/dist/semiotic-statisticalOverlays-DGX_WWc5.js +1 -0
- package/dist/semiotic-themes.d.ts +80 -0
- package/dist/semiotic-themes.min.js +1 -0
- package/dist/semiotic-themes.module.min.js +1 -0
- package/dist/semiotic-utils.d.ts +30 -0
- package/dist/semiotic-utils.min.js +1 -0
- package/dist/semiotic-utils.module.min.js +1 -0
- package/dist/semiotic-xy.d.ts +1 -0
- package/dist/semiotic.d.ts +11 -5
- package/dist/semiotic.min.js +1 -1
- package/dist/semiotic.module.min.js +1 -1
- package/dist/server.min.js +1 -1
- package/dist/server.module.min.js +1 -1
- package/dist/xy-statisticalOverlays-C2PPlmXv.js +1 -0
- package/dist/xy.min.js +1 -1
- package/dist/xy.module.min.js +1 -1
- package/package.json +38 -12
- package/dist/semiotic-ai-statisticalOverlays-C1f7TYyD.js +0 -1
- package/dist/semiotic-statisticalOverlays-C1f7TYyD.js +0 -1
- package/dist/xy-statisticalOverlays-C1f7TYyD.js +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "semiotic",
|
|
3
|
-
"version": "3.1
|
|
3
|
+
"version": "3.2.1",
|
|
4
|
+
"mcpName": "io.github.nteract/semiotic",
|
|
4
5
|
"description": "React data visualization library with built-in MCP server for AI-assisted chart generation",
|
|
5
6
|
"main": "dist/semiotic.min.js",
|
|
6
7
|
"module": "dist/semiotic.module.min.js",
|
|
@@ -65,6 +66,18 @@
|
|
|
65
66
|
"require": "./dist/geo.min.js",
|
|
66
67
|
"default": "./dist/geo.module.min.js"
|
|
67
68
|
},
|
|
69
|
+
"./themes": {
|
|
70
|
+
"types": "./dist/semiotic-themes.d.ts",
|
|
71
|
+
"import": "./dist/semiotic-themes.module.min.js",
|
|
72
|
+
"require": "./dist/semiotic-themes.min.js",
|
|
73
|
+
"default": "./dist/semiotic-themes.module.min.js"
|
|
74
|
+
},
|
|
75
|
+
"./utils": {
|
|
76
|
+
"types": "./dist/semiotic-utils.d.ts",
|
|
77
|
+
"import": "./dist/semiotic-utils.module.min.js",
|
|
78
|
+
"require": "./dist/semiotic-utils.min.js",
|
|
79
|
+
"default": "./dist/semiotic-utils.module.min.js"
|
|
80
|
+
},
|
|
68
81
|
"./package.json": "./package.json"
|
|
69
82
|
},
|
|
70
83
|
"files": [
|
|
@@ -102,13 +115,13 @@
|
|
|
102
115
|
"clean": "rm -rf .parcel-cache docs/build dist && echo 'All caches and build artifacts cleared'",
|
|
103
116
|
"website:clean": "npm run clean && npm run dist:prod",
|
|
104
117
|
"docs:dev": "parcel serve --target website --no-cache --port 3000",
|
|
105
|
-
"website:start": "npm run dist:prod && parcel serve --target website --no-cache",
|
|
118
|
+
"website:start": "npm run dist:prod && npm run docs:api:json && parcel serve --target website --no-cache",
|
|
106
119
|
"website:start:clean": "npm run clean && npm run dist:prod && parcel serve --target website --no-cache",
|
|
107
120
|
"generate:ssr-gallery": "npx tsx scripts/ssr-gallery.tsx > docs/public/ssr-gallery.html 2>/dev/null",
|
|
108
|
-
"website:build": "npm run dist:prod && npm run generate:ssr-gallery && parcel build --target website && node scripts/prerender.mjs",
|
|
121
|
+
"website:build": "npm run dist:prod && npm run docs:api:json && npm run generate:ssr-gallery && parcel build --target website && node scripts/prerender.mjs",
|
|
109
122
|
"build:mcp": "tsc -p tsconfig.mcp.json",
|
|
110
123
|
"docs:api": "typedoc",
|
|
111
|
-
"docs:api:json": "typedoc --json docs/
|
|
124
|
+
"docs:api:json": "typedoc --json docs/public/api/api.json",
|
|
112
125
|
"typescript": "tsc --noEmit",
|
|
113
126
|
"size": "size-limit",
|
|
114
127
|
"check:schema": "node scripts/check-schema-freshness.js",
|
|
@@ -128,7 +141,8 @@
|
|
|
128
141
|
},
|
|
129
142
|
"alias": {
|
|
130
143
|
"semiotic": "./src/components/semiotic.ts",
|
|
131
|
-
"semiotic/geo": "./src/components/semiotic-geo.ts"
|
|
144
|
+
"semiotic/geo": "./src/components/semiotic-geo.ts",
|
|
145
|
+
"semiotic/utils": "./src/components/semiotic-utils.ts"
|
|
132
146
|
},
|
|
133
147
|
"repository": {
|
|
134
148
|
"type": "git",
|
|
@@ -154,33 +168,39 @@
|
|
|
154
168
|
"streaming",
|
|
155
169
|
"network-graph",
|
|
156
170
|
"ai",
|
|
157
|
-
"llm"
|
|
171
|
+
"llm",
|
|
172
|
+
"claude",
|
|
173
|
+
"copilot",
|
|
174
|
+
"geographic",
|
|
175
|
+
"choropleth",
|
|
176
|
+
"sankey",
|
|
177
|
+
"force-directed"
|
|
158
178
|
],
|
|
159
179
|
"license": "Apache-2.0",
|
|
160
180
|
"size-limit": [
|
|
161
181
|
{
|
|
162
182
|
"path": "dist/semiotic.module.min.js",
|
|
163
|
-
"limit": "
|
|
183
|
+
"limit": "230 KB"
|
|
164
184
|
},
|
|
165
185
|
{
|
|
166
186
|
"path": "dist/xy.module.min.js",
|
|
167
|
-
"limit": "
|
|
187
|
+
"limit": "125 KB"
|
|
168
188
|
},
|
|
169
189
|
{
|
|
170
190
|
"path": "dist/ordinal.module.min.js",
|
|
171
|
-
"limit": "
|
|
191
|
+
"limit": "95 KB"
|
|
172
192
|
},
|
|
173
193
|
{
|
|
174
194
|
"path": "dist/network.module.min.js",
|
|
175
|
-
"limit": "
|
|
195
|
+
"limit": "95 KB"
|
|
176
196
|
},
|
|
177
197
|
{
|
|
178
198
|
"path": "dist/geo.module.min.js",
|
|
179
|
-
"limit": "
|
|
199
|
+
"limit": "90 KB"
|
|
180
200
|
},
|
|
181
201
|
{
|
|
182
202
|
"path": "dist/realtime.module.min.js",
|
|
183
|
-
"limit": "
|
|
203
|
+
"limit": "130 KB"
|
|
184
204
|
}
|
|
185
205
|
],
|
|
186
206
|
"devDependencies": {
|
|
@@ -241,6 +261,9 @@
|
|
|
241
261
|
"react": "^18.1.0 || ^19.0.0",
|
|
242
262
|
"react-dom": "^18.1.0 || ^19.0.0"
|
|
243
263
|
},
|
|
264
|
+
"optionalDependencies": {
|
|
265
|
+
"sharp": ">=0.33.0"
|
|
266
|
+
},
|
|
244
267
|
"dependencies": {
|
|
245
268
|
"@modelcontextprotocol/sdk": "^1.12.1",
|
|
246
269
|
"@types/d3-quadtree": "^3.0.6",
|
|
@@ -274,5 +297,8 @@
|
|
|
274
297
|
},
|
|
275
298
|
"volta": {
|
|
276
299
|
"node": "22.22.1"
|
|
300
|
+
},
|
|
301
|
+
"overrides": {
|
|
302
|
+
"flatted": "3.4.2"
|
|
277
303
|
}
|
|
278
304
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const o="__forecastSegment";function n(o,n){return"function"==typeof n?n(o):!!o[n]}function a(o){var n,a,t;return[{type:"anomaly-band",threshold:null!==(n=o.threshold)&&void 0!==n?n:2,showBand:!1!==o.showBand,fill:o.bandColor||"#6366f1",fillOpacity:null!==(a=o.bandOpacity)&&void 0!==a?a:.1,anomalyColor:o.anomalyColor||"#ef4444",anomalyRadius:null!==(t=o.anomalyRadius)&&void 0!==t?t:6,label:o.label}]}function t(a,t,e,s,l){return(r=s).isTraining||r.isForecast||r.isAnomaly||r.upperBounds||r.lowerBounds?function(a,t,e,s,l){var r,i,c;const{isTraining:u,isForecast:f,isAnomaly:p,upperBounds:h,lowerBounds:d,color:y="#6366f1",bandOpacity:b=.15,anomalyColor:g="#ef4444",anomalyRadius:O=6,label:m}=s,v=a.map(a=>{let t="observed";return f&&n(a,f)?t="forecast":u&&n(a,u)&&(t="training"),Object.assign(Object.assign({},a),{[o]:t})}),j=[];for(let n=0;v.length>n;n++)j.push(v[n]),v.length-1>n&&v[n][o]!==v[n+1][o]&&j.push(Object.assign(Object.assign({},v[n]),{[o]:v[n+1][o]}));const w=[];if(h&&d){const o="string"==typeof h?h:"__envUpper",n="string"==typeof d?d:"__envLower";if("function"==typeof h||"function"==typeof d)for(const a of j)"function"==typeof h&&(a[o]=h(a)),"function"==typeof d&&(a[n]=d(a));w.push({type:"envelope",upperAccessor:o,lowerAccessor:n,fill:y,fillOpacity:b,label:m})}return p&&w.push({type:"highlight",filter:o=>n(o,p),color:g,r:O,style:{stroke:g,strokeWidth:1.5,fill:g,fillOpacity:.7}}),l&&w.push({type:"anomaly-band",threshold:null!==(r=l.threshold)&&void 0!==r?r:2,showBand:!1!==l.showBand,fill:l.bandColor||"#6366f1",fillOpacity:null!==(i=l.bandOpacity)&&void 0!==i?i:.1,anomalyColor:l.anomalyColor||"#ef4444",anomalyRadius:null!==(c=l.anomalyRadius)&&void 0!==c?c:6,label:l.label}),{processedData:j,annotations:w}}(a,0,0,s,l):function(n,a,t,e,s){var l,r,i;const{trainEnd:c,steps:u=10,confidence:f=.95,color:p="#6366f1",bandOpacity:h=.15,label:d}=e;if(null==c)return{processedData:n,annotations:[]};const y=[],b=[];for(const t of n)t[a]>c?b.push(Object.assign(Object.assign({},t),{[o]:"observed"})):y.push(Object.assign(Object.assign({},t),{[o]:"training"}));const g=y.map(o=>[o[a],o[t]]).filter(o=>null!=o[0]&&null!=o[1]&&isFinite(o[0])&&isFinite(o[1])).sort((o,n)=>o[0]-n[0]),O=[],m=[];if(g.length>=3){const e=g.length;let s=0,l=0,r=0,i=0;for(const[o,n]of g)s+=o,l+=n,r+=o*o,i+=o*n;const c=e*r-s*s;if(Math.abs(c)>1e-12){const r=(e*i-s*l)/c,y=(l-r*s)/e,b=o=>y+r*o,v=g.map(([o,n])=>n-b(o)).reduce((o,n)=>o+n*n,0),j=Math.sqrt(v/Math.max(e-2,1)),w=g.reduce((o,n)=>o+n[0],0)/e,_=g.reduce((o,n)=>o+Math.pow(n[0]-w,2),0),B=.99>f?.95>f?.9>f?1:1.645:1.96:2.576,C=n.map(o=>o[a]).filter(o=>null!=o&&isFinite(o)),D=Math.max(...C),k=g.length>1?(g[e-1][0]-g[0][0])/(e-1):1;for(let n=1;u>=n;n++){const s=D+n*k,l=b(s),r=j*Math.sqrt(1+1/e+(_>0?Math.pow(s-w,2)/_:0))*B;m.push({[a]:s,[t]:l,[o]:"forecast",__forecastUpper:l+r,__forecastLower:l-r})}O.push({type:"envelope",upperAccessor:"__forecastUpper",lowerAccessor:"__forecastLower",fill:p,fillOpacity:h,label:d})}}O.push({type:"x-threshold",x:c,color:"#94a3b8",strokeWidth:1,strokeDasharray:"4,2",label:"Train / Forecast"}),s&&O.push({type:"anomaly-band",threshold:null!==(l=s.threshold)&&void 0!==l?l:2,showBand:!1!==s.showBand,fill:s.bandColor||"#6366f1",fillOpacity:null!==(r=s.bandOpacity)&&void 0!==r?r:.1,anomalyColor:s.anomalyColor||"#ef4444",anomalyRadius:null!==(i=s.anomalyRadius)&&void 0!==i?i:6,label:s.label});const v=[];if(v.push(...y),y.length>0&&b.length>0&&v.push(Object.assign(Object.assign({},y[y.length-1]),{[o]:"observed"})),v.push(...b),m.length>0){const n=b.length>0?b[b.length-1]:y[y.length-1];n&&v.push(Object.assign(Object.assign({},n),{[o]:"forecast"})),v.push(...m)}return{processedData:v,annotations:O}}(a,t,e,s,l);var r}function e(n,a){var t,e;const s=null!==(t=a.trainDasharray)&&void 0!==t?t:"8,4",l=null!==(e=a.forecastDasharray)&&void 0!==e?e:"4,4",r=a.color||"#6366f1";return a=>{const t=n(a),e=a[o];return"training"===e?Object.assign(Object.assign({},t),{strokeDasharray:s}):"forecast"===e?Object.assign(Object.assign({},t),{stroke:r,strokeDasharray:l}):t}}export{o as SEGMENT_FIELD,a as buildAnomalyAnnotations,t as buildForecast,e as createSegmentLineStyle};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const o="__forecastSegment";function n(o,n){return"function"==typeof n?n(o):!!o[n]}function a(o){var n,a,t;return[{type:"anomaly-band",threshold:null!==(n=o.threshold)&&void 0!==n?n:2,showBand:!1!==o.showBand,fill:o.bandColor||"#6366f1",fillOpacity:null!==(a=o.bandOpacity)&&void 0!==a?a:.1,anomalyColor:o.anomalyColor||"#ef4444",anomalyRadius:null!==(t=o.anomalyRadius)&&void 0!==t?t:6,label:o.label}]}function t(a,t,e,s,l){return(r=s).isTraining||r.isForecast||r.isAnomaly||r.upperBounds||r.lowerBounds?function(a,t,e,s,l){var r,i,c;const{isTraining:u,isForecast:f,isAnomaly:p,upperBounds:h,lowerBounds:d,color:y="#6366f1",bandOpacity:b=.15,anomalyColor:g="#ef4444",anomalyRadius:O=6,label:m}=s,v=a.map(a=>{let t="observed";return f&&n(a,f)?t="forecast":u&&n(a,u)&&(t="training"),Object.assign(Object.assign({},a),{[o]:t})}),j=[];for(let n=0;v.length>n;n++)j.push(v[n]),v.length-1>n&&v[n][o]!==v[n+1][o]&&j.push(Object.assign(Object.assign({},v[n]),{[o]:v[n+1][o]}));const w=[];if(h&&d){const o="string"==typeof h?h:"__envUpper",n="string"==typeof d?d:"__envLower";if("function"==typeof h||"function"==typeof d)for(const a of j)"function"==typeof h&&(a[o]=h(a)),"function"==typeof d&&(a[n]=d(a));w.push({type:"envelope",upperAccessor:o,lowerAccessor:n,fill:y,fillOpacity:b,label:m})}return p&&w.push({type:"highlight",filter:o=>n(o,p),color:g,r:O,style:{stroke:g,strokeWidth:1.5,fill:g,fillOpacity:.7}}),l&&w.push({type:"anomaly-band",threshold:null!==(r=l.threshold)&&void 0!==r?r:2,showBand:!1!==l.showBand,fill:l.bandColor||"#6366f1",fillOpacity:null!==(i=l.bandOpacity)&&void 0!==i?i:.1,anomalyColor:l.anomalyColor||"#ef4444",anomalyRadius:null!==(c=l.anomalyRadius)&&void 0!==c?c:6,label:l.label}),{processedData:j,annotations:w}}(a,0,0,s,l):function(n,a,t,e,s){var l,r,i;const{trainEnd:c,steps:u=10,confidence:f=.95,color:p="#6366f1",bandOpacity:h=.15,label:d}=e;if(null==c)return{processedData:n,annotations:[]};const y=[],b=[];for(const t of n)t[a]>c?b.push(Object.assign(Object.assign({},t),{[o]:"observed"})):y.push(Object.assign(Object.assign({},t),{[o]:"training"}));const g=y.map(o=>[o[a],o[t]]).filter(o=>null!=o[0]&&null!=o[1]&&isFinite(o[0])&&isFinite(o[1])).sort((o,n)=>o[0]-n[0]),O=[],m=[];if(g.length>=3){const e=g.length;let s=0,l=0,r=0,i=0;for(const[o,n]of g)s+=o,l+=n,r+=o*o,i+=o*n;const c=e*r-s*s;if(Math.abs(c)>1e-12){const r=(e*i-s*l)/c,y=(l-r*s)/e,b=o=>y+r*o,v=g.map(([o,n])=>n-b(o)).reduce((o,n)=>o+n*n,0),j=Math.sqrt(v/Math.max(e-2,1)),w=g.reduce((o,n)=>o+n[0],0)/e,_=g.reduce((o,n)=>o+Math.pow(n[0]-w,2),0),B=.99>f?.95>f?.9>f?1:1.645:1.96:2.576,C=n.map(o=>o[a]).filter(o=>null!=o&&isFinite(o)),D=Math.max(...C),k=g.length>1?(g[e-1][0]-g[0][0])/(e-1):1;for(let n=1;u>=n;n++){const s=D+n*k,l=b(s),r=j*Math.sqrt(1+1/e+(_>0?Math.pow(s-w,2)/_:0))*B;m.push({[a]:s,[t]:l,[o]:"forecast",__forecastUpper:l+r,__forecastLower:l-r})}O.push({type:"envelope",upperAccessor:"__forecastUpper",lowerAccessor:"__forecastLower",fill:p,fillOpacity:h,label:d})}}O.push({type:"x-threshold",x:c,color:"#94a3b8",strokeWidth:1,strokeDasharray:"4,2",label:"Train / Forecast"}),s&&O.push({type:"anomaly-band",threshold:null!==(l=s.threshold)&&void 0!==l?l:2,showBand:!1!==s.showBand,fill:s.bandColor||"#6366f1",fillOpacity:null!==(r=s.bandOpacity)&&void 0!==r?r:.1,anomalyColor:s.anomalyColor||"#ef4444",anomalyRadius:null!==(i=s.anomalyRadius)&&void 0!==i?i:6,label:s.label});const v=[];if(v.push(...y),y.length>0&&b.length>0&&v.push(Object.assign(Object.assign({},y[y.length-1]),{[o]:"observed"})),v.push(...b),m.length>0){const n=b.length>0?b[b.length-1]:y[y.length-1];n&&v.push(Object.assign(Object.assign({},n),{[o]:"forecast"})),v.push(...m)}return{processedData:v,annotations:O}}(a,t,e,s,l);var r}function e(n,a){var t,e;const s=null!==(t=a.trainDasharray)&&void 0!==t?t:"8,4",l=null!==(e=a.forecastDasharray)&&void 0!==e?e:"4,4",r=a.color||"#6366f1";return a=>{const t=n(a),e=a[o];return"training"===e?Object.assign(Object.assign({},t),{strokeDasharray:s}):"forecast"===e?Object.assign(Object.assign({},t),{stroke:r,strokeDasharray:l}):t}}export{o as SEGMENT_FIELD,a as buildAnomalyAnnotations,t as buildForecast,e as createSegmentLineStyle};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const o="__forecastSegment";function n(o,n){return"function"==typeof n?n(o):!!o[n]}function a(o){var n,a,t;return[{type:"anomaly-band",threshold:null!==(n=o.threshold)&&void 0!==n?n:2,showBand:!1!==o.showBand,fill:o.bandColor||"#6366f1",fillOpacity:null!==(a=o.bandOpacity)&&void 0!==a?a:.1,anomalyColor:o.anomalyColor||"#ef4444",anomalyRadius:null!==(t=o.anomalyRadius)&&void 0!==t?t:6,label:o.label}]}function t(a,t,e,s,l){return(r=s).isTraining||r.isForecast||r.isAnomaly||r.upperBounds||r.lowerBounds?function(a,t,e,s,l){var r,i,c;const{isTraining:u,isForecast:f,isAnomaly:p,upperBounds:h,lowerBounds:d,color:y="#6366f1",bandOpacity:b=.15,anomalyColor:g="#ef4444",anomalyRadius:O=6,label:m}=s,v=a.map(a=>{let t="observed";return f&&n(a,f)?t="forecast":u&&n(a,u)&&(t="training"),Object.assign(Object.assign({},a),{[o]:t})}),j=[];for(let n=0;v.length>n;n++)j.push(v[n]),v.length-1>n&&v[n][o]!==v[n+1][o]&&j.push(Object.assign(Object.assign({},v[n]),{[o]:v[n+1][o]}));const w=[];if(h&&d){const o="string"==typeof h?h:"__envUpper",n="string"==typeof d?d:"__envLower";if("function"==typeof h||"function"==typeof d)for(const a of j)"function"==typeof h&&(a[o]=h(a)),"function"==typeof d&&(a[n]=d(a));w.push({type:"envelope",upperAccessor:o,lowerAccessor:n,fill:y,fillOpacity:b,label:m})}return p&&w.push({type:"highlight",filter:o=>n(o,p),color:g,r:O,style:{stroke:g,strokeWidth:1.5,fill:g,fillOpacity:.7}}),l&&w.push({type:"anomaly-band",threshold:null!==(r=l.threshold)&&void 0!==r?r:2,showBand:!1!==l.showBand,fill:l.bandColor||"#6366f1",fillOpacity:null!==(i=l.bandOpacity)&&void 0!==i?i:.1,anomalyColor:l.anomalyColor||"#ef4444",anomalyRadius:null!==(c=l.anomalyRadius)&&void 0!==c?c:6,label:l.label}),{processedData:j,annotations:w}}(a,0,0,s,l):function(n,a,t,e,s){var l,r,i;const{trainEnd:c,steps:u=10,confidence:f=.95,color:p="#6366f1",bandOpacity:h=.15,label:d}=e;if(null==c)return{processedData:n,annotations:[]};const y=[],b=[];for(const t of n)t[a]>c?b.push(Object.assign(Object.assign({},t),{[o]:"observed"})):y.push(Object.assign(Object.assign({},t),{[o]:"training"}));const g=y.map(o=>[o[a],o[t]]).filter(o=>null!=o[0]&&null!=o[1]&&isFinite(o[0])&&isFinite(o[1])).sort((o,n)=>o[0]-n[0]),O=[],m=[];if(g.length>=3){const e=g.length;let s=0,l=0,r=0,i=0;for(const[o,n]of g)s+=o,l+=n,r+=o*o,i+=o*n;const c=e*r-s*s;if(Math.abs(c)>1e-12){const r=(e*i-s*l)/c,y=(l-r*s)/e,b=o=>y+r*o,v=g.map(([o,n])=>n-b(o)).reduce((o,n)=>o+n*n,0),j=Math.sqrt(v/Math.max(e-2,1)),w=g.reduce((o,n)=>o+n[0],0)/e,_=g.reduce((o,n)=>o+Math.pow(n[0]-w,2),0),B=.99>f?.95>f?.9>f?1:1.645:1.96:2.576,C=n.map(o=>o[a]).filter(o=>null!=o&&isFinite(o)),D=Math.max(...C),k=g.length>1?(g[e-1][0]-g[0][0])/(e-1):1;for(let n=1;u>=n;n++){const s=D+n*k,l=b(s),r=j*Math.sqrt(1+1/e+(_>0?Math.pow(s-w,2)/_:0))*B;m.push({[a]:s,[t]:l,[o]:"forecast",__forecastUpper:l+r,__forecastLower:l-r})}O.push({type:"envelope",upperAccessor:"__forecastUpper",lowerAccessor:"__forecastLower",fill:p,fillOpacity:h,label:d})}}O.push({type:"x-threshold",x:c,color:"#94a3b8",strokeWidth:1,strokeDasharray:"4,2",label:"Train / Forecast"}),s&&O.push({type:"anomaly-band",threshold:null!==(l=s.threshold)&&void 0!==l?l:2,showBand:!1!==s.showBand,fill:s.bandColor||"#6366f1",fillOpacity:null!==(r=s.bandOpacity)&&void 0!==r?r:.1,anomalyColor:s.anomalyColor||"#ef4444",anomalyRadius:null!==(i=s.anomalyRadius)&&void 0!==i?i:6,label:s.label});const v=[];if(v.push(...y),y.length>0&&b.length>0&&v.push(Object.assign(Object.assign({},y[y.length-1]),{[o]:"observed"})),v.push(...b),m.length>0){const n=b.length>0?b[b.length-1]:y[y.length-1];n&&v.push(Object.assign(Object.assign({},n),{[o]:"forecast"})),v.push(...m)}return{processedData:v,annotations:O}}(a,t,e,s,l);var r}function e(n,a){var t,e;const s=null!==(t=a.trainDasharray)&&void 0!==t?t:"8,4",l=null!==(e=a.forecastDasharray)&&void 0!==e?e:"4,4",r=a.color||"#6366f1";return a=>{const t=n(a),e=a[o];return"training"===e?Object.assign(Object.assign({},t),{strokeDasharray:s}):"forecast"===e?Object.assign(Object.assign({},t),{stroke:r,strokeDasharray:l}):t}}export{o as SEGMENT_FIELD,a as buildAnomalyAnnotations,t as buildForecast,e as createSegmentLineStyle};
|