mintwaterfall 0.8.6

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.
Files changed (38) hide show
  1. package/CHANGELOG.md +223 -0
  2. package/CONTRIBUTING.md +199 -0
  3. package/README.md +363 -0
  4. package/dist/index.d.ts +149 -0
  5. package/dist/mintwaterfall.cjs.js +7978 -0
  6. package/dist/mintwaterfall.esm.js +7907 -0
  7. package/dist/mintwaterfall.min.js +7 -0
  8. package/dist/mintwaterfall.umd.js +7978 -0
  9. package/index.d.ts +149 -0
  10. package/package.json +126 -0
  11. package/src/enterprise/enterprise-core.js +0 -0
  12. package/src/enterprise/enterprise-feature-template.js +0 -0
  13. package/src/enterprise/feature-registry.js +0 -0
  14. package/src/enterprise/features/breakdown.js +0 -0
  15. package/src/features/breakdown.js +0 -0
  16. package/src/features/conditional-formatting.js +0 -0
  17. package/src/index.js +111 -0
  18. package/src/mintwaterfall-accessibility.ts +680 -0
  19. package/src/mintwaterfall-advanced-data.ts +1034 -0
  20. package/src/mintwaterfall-advanced-interactions.ts +649 -0
  21. package/src/mintwaterfall-advanced-performance.ts +582 -0
  22. package/src/mintwaterfall-animations.ts +595 -0
  23. package/src/mintwaterfall-brush.ts +471 -0
  24. package/src/mintwaterfall-chart-core.ts +296 -0
  25. package/src/mintwaterfall-chart.ts +1915 -0
  26. package/src/mintwaterfall-data.ts +1100 -0
  27. package/src/mintwaterfall-export.ts +475 -0
  28. package/src/mintwaterfall-hierarchical-layouts.ts +724 -0
  29. package/src/mintwaterfall-layouts.ts +647 -0
  30. package/src/mintwaterfall-performance.ts +573 -0
  31. package/src/mintwaterfall-scales.ts +437 -0
  32. package/src/mintwaterfall-shapes.ts +385 -0
  33. package/src/mintwaterfall-statistics.ts +821 -0
  34. package/src/mintwaterfall-themes.ts +391 -0
  35. package/src/mintwaterfall-tooltip.ts +450 -0
  36. package/src/mintwaterfall-zoom.ts +399 -0
  37. package/src/types/js-modules.d.ts +25 -0
  38. package/src/utils/compatibility-layer.js +0 -0
@@ -0,0 +1,385 @@
1
+ // MintWaterfall Enhanced Shape Generators - TypeScript Version
2
+ // Provides advanced D3.js shape generators for waterfall chart enhancements
3
+
4
+ import * as d3 from 'd3';
5
+
6
+ // ============================================================================
7
+ // TYPE DEFINITIONS
8
+ // ============================================================================
9
+
10
+ export interface ConfidenceBandData {
11
+ x: number;
12
+ y: number;
13
+ yUpper: number;
14
+ yLower: number;
15
+ label?: string;
16
+ }
17
+
18
+ export interface DataPointMarker {
19
+ x: number;
20
+ y: number;
21
+ type: 'circle' | 'square' | 'triangle' | 'diamond' | 'star' | 'cross';
22
+ size?: number;
23
+ color?: string;
24
+ label?: string;
25
+ }
26
+
27
+ export interface AreaConfig {
28
+ curve?: d3.CurveFactory;
29
+ opacity?: number;
30
+ fillColor?: string;
31
+ strokeColor?: string;
32
+ strokeWidth?: number;
33
+ }
34
+
35
+ export interface SymbolConfig {
36
+ type?: d3.SymbolType;
37
+ size?: number;
38
+ fillColor?: string;
39
+ strokeColor?: string;
40
+ strokeWidth?: number;
41
+ }
42
+
43
+ export interface TrendLineConfig {
44
+ curve?: d3.CurveFactory;
45
+ strokeColor?: string;
46
+ strokeWidth?: number;
47
+ strokeDasharray?: string;
48
+ opacity?: number;
49
+ }
50
+
51
+ export interface ShapeGeneratorSystem {
52
+ // Area generators
53
+ createConfidenceBand(data: ConfidenceBandData[], config?: AreaConfig): string;
54
+ createEnvelopeArea(data: Array<{x: number, y0: number, y1: number}>, config?: AreaConfig): string;
55
+
56
+ // Symbol generators
57
+ createDataPointMarkers(data: DataPointMarker[], config?: SymbolConfig): Array<{path: string, transform: string, config: SymbolConfig}>;
58
+ createCustomSymbol(type: string, size?: number): string;
59
+
60
+ // Enhanced trend lines
61
+ createSmoothTrendLine(data: Array<{x: number, y: number}>, config?: TrendLineConfig): string;
62
+ createMultipleTrendLines(datasets: Array<{data: Array<{x: number, y: number}>, config?: TrendLineConfig}>): string[];
63
+
64
+ // Utility functions
65
+ getCurveTypes(): { [key: string]: d3.CurveFactory };
66
+ getSymbolTypes(): { [key: string]: d3.SymbolType };
67
+ }
68
+
69
+ // ============================================================================
70
+ // SHAPE GENERATOR IMPLEMENTATION
71
+ // ============================================================================
72
+
73
+ export function createShapeGenerators(): ShapeGeneratorSystem {
74
+
75
+ // Available curve types for enhanced visualization
76
+ const curveTypes = {
77
+ linear: d3.curveLinear,
78
+ basis: d3.curveBasis,
79
+ cardinal: d3.curveCardinal,
80
+ catmullRom: d3.curveCatmullRom,
81
+ monotoneX: d3.curveMonotoneX,
82
+ monotoneY: d3.curveMonotoneY,
83
+ natural: d3.curveNatural,
84
+ step: d3.curveStep,
85
+ stepBefore: d3.curveStepBefore,
86
+ stepAfter: d3.curveStepAfter,
87
+ bumpX: d3.curveBumpX,
88
+ bumpY: d3.curveBumpY
89
+ };
90
+
91
+ // Available symbol types for data point markers
92
+ const symbolTypes = {
93
+ circle: d3.symbolCircle,
94
+ square: d3.symbolSquare,
95
+ triangle: d3.symbolTriangle,
96
+ diamond: d3.symbolDiamond,
97
+ star: d3.symbolStar,
98
+ cross: d3.symbolCross,
99
+ wye: d3.symbolWye
100
+ };
101
+
102
+ // ========================================================================
103
+ // AREA GENERATORS
104
+ // ========================================================================
105
+
106
+ /**
107
+ * Create confidence band area for uncertainty visualization
108
+ * Perfect for showing confidence intervals around waterfall projections
109
+ */
110
+ function createConfidenceBand(data: ConfidenceBandData[], config: AreaConfig = {}): string {
111
+ const {
112
+ curve = d3.curveMonotoneX,
113
+ opacity = 0.3,
114
+ fillColor = "#95a5a6"
115
+ } = config;
116
+
117
+ const areaGenerator = d3.area<ConfidenceBandData>()
118
+ .x(d => d.x)
119
+ .y0(d => d.yLower)
120
+ .y1(d => d.yUpper)
121
+ .curve(curve);
122
+
123
+ return areaGenerator(data) || "";
124
+ }
125
+
126
+ /**
127
+ * Create envelope area between two data series
128
+ * Useful for showing range between scenarios in waterfall analysis
129
+ */
130
+ function createEnvelopeArea(
131
+ data: Array<{x: number, y0: number, y1: number}>,
132
+ config: AreaConfig = {}
133
+ ): string {
134
+ const {
135
+ curve = d3.curveMonotoneX
136
+ } = config;
137
+
138
+ const areaGenerator = d3.area<{x: number, y0: number, y1: number}>()
139
+ .x(d => d.x)
140
+ .y0(d => d.y0)
141
+ .y1(d => d.y1)
142
+ .curve(curve);
143
+
144
+ return areaGenerator(data) || "";
145
+ }
146
+
147
+ // ========================================================================
148
+ // SYMBOL GENERATORS
149
+ // ========================================================================
150
+
151
+ /**
152
+ * Create data point markers for highlighting key values
153
+ * Perfect for marking important milestones in waterfall progression
154
+ */
155
+ function createDataPointMarkers(
156
+ data: DataPointMarker[],
157
+ config: SymbolConfig = {}
158
+ ): Array<{path: string, transform: string, config: SymbolConfig}> {
159
+ const {
160
+ size = 64,
161
+ fillColor = "#3498db",
162
+ strokeColor = "#ffffff",
163
+ strokeWidth = 2
164
+ } = config;
165
+
166
+ return data.map(point => {
167
+ const symbolType = symbolTypes[point.type as keyof typeof symbolTypes] || d3.symbolCircle;
168
+ const symbolSize = point.size || size;
169
+
170
+ const symbolGenerator = d3.symbol()
171
+ .type(symbolType)
172
+ .size(symbolSize);
173
+
174
+ return {
175
+ path: symbolGenerator() || "",
176
+ transform: `translate(${point.x}, ${point.y})`,
177
+ config: {
178
+ ...config,
179
+ fillColor: point.color || fillColor,
180
+ strokeColor,
181
+ strokeWidth
182
+ }
183
+ };
184
+ });
185
+ }
186
+
187
+ /**
188
+ * Create custom symbol path
189
+ * Allows for creating unique markers for specific data points
190
+ */
191
+ function createCustomSymbol(type: string, size: number = 64): string {
192
+ const symbolType = symbolTypes[type as keyof typeof symbolTypes] || d3.symbolCircle;
193
+ const symbolGenerator = d3.symbol()
194
+ .type(symbolType)
195
+ .size(size);
196
+
197
+ return symbolGenerator() || "";
198
+ }
199
+
200
+ // ========================================================================
201
+ // ENHANCED TREND LINES
202
+ // ========================================================================
203
+
204
+ /**
205
+ * Create smooth trend line with enhanced curve support
206
+ * Provides better visual flow for waterfall trend analysis
207
+ */
208
+ function createSmoothTrendLine(
209
+ data: Array<{x: number, y: number}>,
210
+ config: TrendLineConfig = {}
211
+ ): string {
212
+ const {
213
+ curve = d3.curveMonotoneX,
214
+ strokeColor = "#e74c3c",
215
+ strokeWidth = 2,
216
+ opacity = 0.8
217
+ } = config;
218
+
219
+ const lineGenerator = d3.line<{x: number, y: number}>()
220
+ .x(d => d.x)
221
+ .y(d => d.y)
222
+ .curve(curve);
223
+
224
+ return lineGenerator(data) || "";
225
+ }
226
+
227
+ /**
228
+ * Create multiple trend lines for comparison analysis
229
+ * Useful for comparing different scenarios or time periods
230
+ */
231
+ function createMultipleTrendLines(
232
+ datasets: Array<{data: Array<{x: number, y: number}>, config?: TrendLineConfig}>
233
+ ): string[] {
234
+ return datasets.map(dataset => {
235
+ return createSmoothTrendLine(dataset.data, dataset.config);
236
+ });
237
+ }
238
+
239
+ // ========================================================================
240
+ // UTILITY FUNCTIONS
241
+ // ========================================================================
242
+
243
+ function getCurveTypes(): { [key: string]: d3.CurveFactory } {
244
+ return { ...curveTypes };
245
+ }
246
+
247
+ function getSymbolTypes(): { [key: string]: d3.SymbolType } {
248
+ return { ...symbolTypes };
249
+ }
250
+
251
+ // ========================================================================
252
+ // RETURN API
253
+ // ========================================================================
254
+
255
+ return {
256
+ // Area generators
257
+ createConfidenceBand,
258
+ createEnvelopeArea,
259
+
260
+ // Symbol generators
261
+ createDataPointMarkers,
262
+ createCustomSymbol,
263
+
264
+ // Enhanced trend lines
265
+ createSmoothTrendLine,
266
+ createMultipleTrendLines,
267
+
268
+ // Utility functions
269
+ getCurveTypes,
270
+ getSymbolTypes
271
+ };
272
+ }
273
+
274
+ // ============================================================================
275
+ // ADVANCED WATERFALL-SPECIFIC SHAPE UTILITIES
276
+ // ============================================================================
277
+
278
+ /**
279
+ * Create confidence bands specifically for waterfall financial projections
280
+ * Combines multiple projection scenarios into visual uncertainty bands
281
+ */
282
+ export function createWaterfallConfidenceBands(
283
+ baselineData: Array<{label: string, value: number}>,
284
+ scenarios: {
285
+ optimistic: Array<{label: string, value: number}>,
286
+ pessimistic: Array<{label: string, value: number}>
287
+ },
288
+ xScale: d3.ScaleBand<string>,
289
+ yScale: d3.ScaleLinear<number, number>
290
+ ): {
291
+ confidencePath: string,
292
+ optimisticPath: string,
293
+ pessimisticPath: string
294
+ } {
295
+ const shapeGenerator = createShapeGenerators();
296
+
297
+ // Calculate cumulative values for each scenario
298
+ let baselineCumulative = 0;
299
+ let optimisticCumulative = 0;
300
+ let pessimisticCumulative = 0;
301
+
302
+ const confidenceData: ConfidenceBandData[] = baselineData.map((item, i) => {
303
+ baselineCumulative += item.value;
304
+ optimisticCumulative += scenarios.optimistic[i]?.value || item.value;
305
+ pessimisticCumulative += scenarios.pessimistic[i]?.value || item.value;
306
+
307
+ const x = (xScale(item.label) || 0) + xScale.bandwidth() / 2;
308
+
309
+ return {
310
+ x,
311
+ y: yScale(baselineCumulative),
312
+ yUpper: yScale(optimisticCumulative),
313
+ yLower: yScale(pessimisticCumulative),
314
+ label: item.label
315
+ };
316
+ });
317
+
318
+ // Create trend lines for each scenario
319
+ const optimisticTrendData = confidenceData.map(d => ({ x: d.x, y: d.yUpper }));
320
+ const pessimisticTrendData = confidenceData.map(d => ({ x: d.x, y: d.yLower }));
321
+
322
+ return {
323
+ confidencePath: shapeGenerator.createConfidenceBand(confidenceData, {
324
+ fillColor: "rgba(52, 152, 219, 0.2)",
325
+ curve: d3.curveMonotoneX
326
+ }),
327
+ optimisticPath: shapeGenerator.createSmoothTrendLine(optimisticTrendData, {
328
+ strokeColor: "#27ae60",
329
+ strokeWidth: 2,
330
+ strokeDasharray: "5,5",
331
+ curve: d3.curveMonotoneX
332
+ }),
333
+ pessimisticPath: shapeGenerator.createSmoothTrendLine(pessimisticTrendData, {
334
+ strokeColor: "#e74c3c",
335
+ strokeWidth: 2,
336
+ strokeDasharray: "5,5",
337
+ curve: d3.curveMonotoneX
338
+ })
339
+ };
340
+ }
341
+
342
+ /**
343
+ * Create key milestone markers for waterfall charts
344
+ * Highlights important data points like targets, thresholds, or significant events
345
+ */
346
+ export function createWaterfallMilestones(
347
+ milestones: Array<{
348
+ label: string,
349
+ value: number,
350
+ type: 'target' | 'threshold' | 'alert' | 'achievement',
351
+ description?: string
352
+ }>,
353
+ xScale: d3.ScaleBand<string>,
354
+ yScale: d3.ScaleLinear<number, number>
355
+ ): Array<{path: string, transform: string, config: SymbolConfig}> {
356
+ const shapeGenerator = createShapeGenerators();
357
+
358
+ const markerData: DataPointMarker[] = milestones.map(milestone => {
359
+ const typeMapping = {
360
+ target: { type: 'star' as const, color: '#f39c12', size: 100 },
361
+ threshold: { type: 'diamond' as const, color: '#9b59b6', size: 80 },
362
+ alert: { type: 'triangle' as const, color: '#e74c3c', size: 90 },
363
+ achievement: { type: 'circle' as const, color: '#27ae60', size: 85 }
364
+ };
365
+
366
+ const styling = typeMapping[milestone.type as keyof typeof typeMapping] || typeMapping.target;
367
+
368
+ return {
369
+ x: (xScale(milestone.label) || 0) + xScale.bandwidth() / 2,
370
+ y: yScale(milestone.value),
371
+ type: styling.type,
372
+ size: styling.size,
373
+ color: styling.color,
374
+ label: milestone.description || milestone.label
375
+ };
376
+ });
377
+
378
+ return shapeGenerator.createDataPointMarkers(markerData, {
379
+ strokeColor: "#ffffff",
380
+ strokeWidth: 2
381
+ });
382
+ }
383
+
384
+ // Default export for convenience
385
+ export default createShapeGenerators;