@allternit/viz 0.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.
Files changed (45) hide show
  1. package/README.md +217 -0
  2. package/dist/charts/canvas-renderer.d.ts +40 -0
  3. package/dist/charts/canvas-renderer.d.ts.bak +40 -0
  4. package/dist/charts/canvas-renderer.d.ts.map +1 -0
  5. package/dist/charts/canvas-renderer.js +580 -0
  6. package/dist/charts/canvas-renderer.js.bak +580 -0
  7. package/dist/charts/canvas-renderer.js.map +1 -0
  8. package/dist/charts/svg-renderer.d.ts +21 -0
  9. package/dist/charts/svg-renderer.d.ts.bak +21 -0
  10. package/dist/charts/svg-renderer.d.ts.map +1 -0
  11. package/dist/charts/svg-renderer.js +285 -0
  12. package/dist/charts/svg-renderer.js.bak +285 -0
  13. package/dist/charts/svg-renderer.js.map +1 -0
  14. package/dist/index.d.ts +34 -0
  15. package/dist/index.d.ts.bak +34 -0
  16. package/dist/index.d.ts.map +1 -0
  17. package/dist/index.js +35 -0
  18. package/dist/index.js.bak +35 -0
  19. package/dist/index.js.map +1 -0
  20. package/dist/types.d.ts +342 -0
  21. package/dist/types.d.ts.bak +342 -0
  22. package/dist/types.d.ts.map +1 -0
  23. package/dist/types.js +39 -0
  24. package/dist/types.js.bak +39 -0
  25. package/dist/types.js.map +1 -0
  26. package/dist/utils/data-processor.d.ts +64 -0
  27. package/dist/utils/data-processor.d.ts.bak +64 -0
  28. package/dist/utils/data-processor.d.ts.map +1 -0
  29. package/dist/utils/data-processor.js +326 -0
  30. package/dist/utils/data-processor.js.bak +326 -0
  31. package/dist/utils/data-processor.js.map +1 -0
  32. package/package.json +41 -0
  33. package/src/charts/canvas-renderer.ts +735 -0
  34. package/src/charts/canvas-renderer.ts.bak +735 -0
  35. package/src/charts/svg-renderer.test.ts.bak +837 -0
  36. package/src/charts/svg-renderer.ts +380 -0
  37. package/src/charts/svg-renderer.ts.bak +380 -0
  38. package/src/index.ts +64 -0
  39. package/src/index.ts.bak +64 -0
  40. package/src/types.ts +410 -0
  41. package/src/types.ts.bak +410 -0
  42. package/src/utils/data-processor.test.ts.bak +720 -0
  43. package/src/utils/data-processor.ts +420 -0
  44. package/src/utils/data-processor.ts.bak +420 -0
  45. package/tsconfig.json +22 -0
@@ -0,0 +1,285 @@
1
+ /**
2
+ * SVG Chart Renderer
3
+ *
4
+ * Renders charts to SVG format.
5
+ */
6
+ import { palettes } from '../types';
7
+ /**
8
+ * Create SVG chart renderer
9
+ */
10
+ export function createSVGRenderer() {
11
+ const defaultWidth = 800;
12
+ const defaultHeight = 400;
13
+ const margin = { top: 60, right: 40, bottom: 60, left: 80 };
14
+ /**
15
+ * Render chart to SVG
16
+ */
17
+ function render(config, series) {
18
+ const width = config.width || defaultWidth;
19
+ const height = config.height || defaultHeight;
20
+ const palette = palettes[config.theme || 'default'];
21
+ const chartWidth = width - margin.left - margin.right;
22
+ const chartHeight = height - margin.top - margin.bottom;
23
+ let svg = `<svg width="${width}" height="${height}" viewBox="0 0 ${width} ${height}" xmlns="http://www.w3.org/2000/svg">\n`;
24
+ // Background
25
+ svg += ` <rect width="${width}" height="${height}" fill="${palette.background[0]}" />\n`;
26
+ // Title
27
+ if (config.title) {
28
+ svg += ` <text x="${width / 2}" y="30" text-anchor="middle" font-family="sans-serif" font-size="18" font-weight="bold" fill="${palette.text.primary}">${escapeHtml(config.title)}</text>\n`;
29
+ }
30
+ // Chart group
31
+ svg += ` <g transform="translate(${margin.left}, ${margin.top})">\n`;
32
+ // Render based on chart type
33
+ switch (config.type) {
34
+ case 'bar':
35
+ svg += renderBarChart(chartWidth, chartHeight, series, palette, config);
36
+ break;
37
+ case 'line':
38
+ svg += renderLineChart(chartWidth, chartHeight, series, palette, config);
39
+ break;
40
+ case 'pie':
41
+ case 'donut':
42
+ svg += renderPieChart(chartWidth, chartHeight, series, palette, config);
43
+ break;
44
+ case 'area':
45
+ svg += renderAreaChart(chartWidth, chartHeight, series, palette, config);
46
+ break;
47
+ default:
48
+ svg += renderPlaceholder(chartWidth, chartHeight, config.type);
49
+ }
50
+ // Axes
51
+ if (['bar', 'line', 'area'].includes(config.type)) {
52
+ svg += renderAxes(chartWidth, chartHeight, series, config, palette);
53
+ }
54
+ svg += ` </g>\n`;
55
+ svg += `</svg>`;
56
+ return svg;
57
+ }
58
+ /**
59
+ * Render bar chart
60
+ */
61
+ function renderBarChart(width, height, series, palette, config) {
62
+ let svg = '';
63
+ if (series.length === 0)
64
+ return svg;
65
+ const allData = series.flatMap(s => s.data);
66
+ const maxValue = Math.max(...allData.map(d => (d.y || d.value || 0)));
67
+ const categories = [...new Set(allData.map(d => d.x || d.name))];
68
+ const barWidth = (width / categories.length) * 0.6 / series.length;
69
+ const scaleY = height / (maxValue * 1.1);
70
+ series.forEach((s, seriesIndex) => {
71
+ const color = s.color || palette.primary[seriesIndex % palette.primary.length];
72
+ s.data.forEach((point, pointIndex) => {
73
+ const value = (point.y || point.value || 0);
74
+ const barHeight = value * scaleY;
75
+ const x = (pointIndex + 0.2) * (width / categories.length) + seriesIndex * barWidth;
76
+ const y = height - barHeight;
77
+ svg += ` <rect x="${x}" y="${y}" width="${barWidth}" height="${barHeight}" fill="${color}" />\n`;
78
+ });
79
+ });
80
+ return svg;
81
+ }
82
+ /**
83
+ * Render line chart
84
+ */
85
+ function renderLineChart(width, height, series, palette, config) {
86
+ let svg = '';
87
+ if (series.length === 0)
88
+ return svg;
89
+ const allData = series.flatMap(s => s.data);
90
+ const maxValue = Math.max(...allData.map(d => (d.y || 0)));
91
+ const scaleX = width / (allData.length - 1 || 1);
92
+ const scaleY = height / (maxValue * 1.1);
93
+ series.forEach((s, seriesIndex) => {
94
+ const color = s.color || palette.primary[seriesIndex % palette.primary.length];
95
+ // Generate path
96
+ let path = '';
97
+ s.data.forEach((point, index) => {
98
+ const x = index * scaleX;
99
+ const y = height - (point.y || 0) * scaleY;
100
+ path += index === 0 ? `M ${x} ${y}` : ` L ${x} ${y}`;
101
+ });
102
+ svg += ` <path d="${path}" fill="none" stroke="${color}" stroke-width="2" />\n`;
103
+ // Data points
104
+ if (config.dataLabels) {
105
+ s.data.forEach((point, index) => {
106
+ const x = index * scaleX;
107
+ const y = height - (point.y || 0) * scaleY;
108
+ svg += ` <circle cx="${x}" cy="${y}" r="4" fill="${color}" />\n`;
109
+ });
110
+ }
111
+ });
112
+ return svg;
113
+ }
114
+ /**
115
+ * Render pie/donut chart
116
+ */
117
+ function renderPieChart(width, height, series, palette, config) {
118
+ let svg = '';
119
+ if (series.length === 0)
120
+ return svg;
121
+ const data = series[0].data;
122
+ const total = data.reduce((sum, d) => sum + (d.y || d.value || 0), 0);
123
+ const centerX = width / 2;
124
+ const centerY = height / 2;
125
+ const radius = Math.min(width, height) / 2 * 0.8;
126
+ const innerRadius = config.type === 'donut' ? radius * 0.5 : 0;
127
+ let currentAngle = -Math.PI / 2;
128
+ data.forEach((point, index) => {
129
+ const value = (point.y || point.value || 0);
130
+ const angle = (value / total) * 2 * Math.PI;
131
+ const color = palette.primary[index % palette.primary.length];
132
+ const x1 = centerX + Math.cos(currentAngle) * radius;
133
+ const y1 = centerY + Math.sin(currentAngle) * radius;
134
+ const x2 = centerX + Math.cos(currentAngle + angle) * radius;
135
+ const y2 = centerY + Math.sin(currentAngle + angle) * radius;
136
+ const largeArc = angle > Math.PI ? 1 : 0;
137
+ if (innerRadius > 0) {
138
+ // Donut
139
+ const ix1 = centerX + Math.cos(currentAngle) * innerRadius;
140
+ const iy1 = centerY + Math.sin(currentAngle) * innerRadius;
141
+ const ix2 = centerX + Math.cos(currentAngle + angle) * innerRadius;
142
+ const iy2 = centerY + Math.sin(currentAngle + angle) * innerRadius;
143
+ svg += ` <path d="M ${x1} ${y1} A ${radius} ${radius} 0 ${largeArc} 1 ${x2} ${y2} L ${ix2} ${iy2} A ${innerRadius} ${innerRadius} 0 ${largeArc} 0 ${ix1} ${iy1} Z" fill="${color}" />\n`;
144
+ }
145
+ else {
146
+ // Pie
147
+ svg += ` <path d="M ${centerX} ${centerY} L ${x1} ${y1} A ${radius} ${radius} 0 ${largeArc} 1 ${x2} ${y2} Z" fill="${color}" />\n`;
148
+ }
149
+ currentAngle += angle;
150
+ });
151
+ return svg;
152
+ }
153
+ /**
154
+ * Render area chart
155
+ */
156
+ function renderAreaChart(width, height, series, palette, config) {
157
+ let svg = '';
158
+ if (series.length === 0)
159
+ return svg;
160
+ const allData = series.flatMap(s => s.data);
161
+ const maxValue = Math.max(...allData.map(d => (d.y || 0)));
162
+ const scaleX = width / (allData.length - 1 || 1);
163
+ const scaleY = height / (maxValue * 1.1);
164
+ series.forEach((s, seriesIndex) => {
165
+ const color = s.color || palette.primary[seriesIndex % palette.primary.length];
166
+ const fillColor = color + '40'; // 25% opacity
167
+ // Generate area path
168
+ let path = '';
169
+ s.data.forEach((point, index) => {
170
+ const x = index * scaleX;
171
+ const y = height - (point.y || 0) * scaleY;
172
+ path += index === 0 ? `M ${x} ${y}` : ` L ${x} ${y}`;
173
+ });
174
+ // Close the area
175
+ path += ` L ${width} ${height} L 0 ${height} Z`;
176
+ svg += ` <path d="${path}" fill="${fillColor}" stroke="${color}" stroke-width="2" />\n`;
177
+ });
178
+ return svg;
179
+ }
180
+ /**
181
+ * Render placeholder for unsupported chart types
182
+ */
183
+ function renderPlaceholder(width, height, type) {
184
+ return ` <rect x="${width / 4}" y="${height / 3}" width="${width / 2}" height="${height / 3}" fill="#e5e7eb" rx="8" />\n <text x="${width / 2}" y="${height / 2}" text-anchor="middle" font-family="sans-serif" font-size="14" fill="#6b7280">${type} chart</text>\n`;
185
+ }
186
+ /**
187
+ * Render axes
188
+ */
189
+ function renderAxes(width, height, series, config, palette) {
190
+ let svg = '';
191
+ // Y-axis
192
+ svg += ` <line x1="0" y1="0" x2="0" y2="${height}" stroke="${palette.background[2]}" stroke-width="1" />\n`;
193
+ // X-axis
194
+ svg += ` <line x1="0" y1="${height}" x2="${width}" y2="${height}" stroke="${palette.background[2]}" stroke-width="1" />\n`;
195
+ // Y-axis labels
196
+ const yAxis = config.yAxis || {};
197
+ const maxValue = Math.max(...series.flatMap(s => s.data.map(d => (d.y || 0))));
198
+ const steps = 5;
199
+ for (let i = 0; i <= steps; i++) {
200
+ const value = (maxValue / steps) * i;
201
+ const y = height - (height / steps) * i;
202
+ svg += ` <text x="-10" y="${y + 4}" text-anchor="end" font-family="sans-serif" font-size="12" fill="${palette.text.secondary}">${Math.round(value)}</text>\n`;
203
+ // Grid line
204
+ if (config.xAxis?.grid?.enabled !== false && i > 0) {
205
+ svg += ` <line x1="0" y1="${y}" x2="${width}" y2="${y}" stroke="${palette.background[2]}" stroke-width="1" stroke-dasharray="4,4" />\n`;
206
+ }
207
+ }
208
+ // Axis titles
209
+ if (yAxis.title) {
210
+ svg += ` <text x="${-margin.left + 20}" y="${height / 2}" transform="rotate(-90, ${-margin.left + 20}, ${height / 2})" text-anchor="middle" font-family="sans-serif" font-size="12" fill="${palette.text.secondary}">${escapeHtml(yAxis.title)}</text>\n`;
211
+ }
212
+ if (config.xAxis?.title) {
213
+ svg += ` <text x="${width / 2}" y="${height + 40}" text-anchor="middle" font-family="sans-serif" font-size="12" fill="${palette.text.secondary}">${escapeHtml(config.xAxis.title)}</text>\n`;
214
+ }
215
+ return svg;
216
+ }
217
+ /**
218
+ * Escape HTML special characters
219
+ */
220
+ function escapeHtml(text) {
221
+ return text
222
+ .replace(/&/g, '&amp;')
223
+ .replace(/</g, '&lt;')
224
+ .replace(/>/g, '&gt;')
225
+ .replace(/"/g, '&quot;')
226
+ .replace(/'/g, '&#039;');
227
+ }
228
+ /**
229
+ * Get chart metadata
230
+ */
231
+ function getMetadata(type) {
232
+ const metadata = {
233
+ line: {
234
+ type: 'line',
235
+ name: 'Line Chart',
236
+ description: 'Show trends over time or categories',
237
+ axes: ['x', 'y'],
238
+ dataStructure: 'Array of { x, y } points',
239
+ useCases: ['Time series', 'Trends', 'Progress over time'],
240
+ },
241
+ bar: {
242
+ type: 'bar',
243
+ name: 'Bar Chart',
244
+ description: 'Compare values across categories',
245
+ axes: ['x', 'y'],
246
+ dataStructure: 'Array of { x, y } points',
247
+ useCases: ['Comparisons', 'Rankings', 'Category distribution'],
248
+ },
249
+ pie: {
250
+ type: 'pie',
251
+ name: 'Pie Chart',
252
+ description: 'Show part-to-whole relationships',
253
+ axes: [],
254
+ dataStructure: 'Array of { name, value }',
255
+ useCases: ['Composition', 'Percentage distribution'],
256
+ },
257
+ donut: {
258
+ type: 'donut',
259
+ name: 'Donut Chart',
260
+ description: 'Show part-to-whole with center space',
261
+ axes: [],
262
+ dataStructure: 'Array of { name, value }',
263
+ useCases: ['Composition', 'Percentage distribution'],
264
+ },
265
+ area: {
266
+ type: 'area',
267
+ name: 'Area Chart',
268
+ description: 'Show cumulative totals over time',
269
+ axes: ['x', 'y'],
270
+ dataStructure: 'Array of { x, y } points',
271
+ useCases: ['Volume over time', 'Cumulative data'],
272
+ },
273
+ };
274
+ return metadata[type] || metadata.line;
275
+ }
276
+ return {
277
+ render,
278
+ getMetadata,
279
+ };
280
+ }
281
+ /**
282
+ * Global SVG renderer instance
283
+ */
284
+ export const globalSVGRenderer = createSVGRenderer();
285
+ //# sourceMappingURL=svg-renderer.js.map
@@ -0,0 +1,285 @@
1
+ /**
2
+ * SVG Chart Renderer
3
+ *
4
+ * Renders charts to SVG format.
5
+ */
6
+ import { palettes } from '../types';
7
+ /**
8
+ * Create SVG chart renderer
9
+ */
10
+ export function createSVGRenderer() {
11
+ const defaultWidth = 800;
12
+ const defaultHeight = 400;
13
+ const margin = { top: 60, right: 40, bottom: 60, left: 80 };
14
+ /**
15
+ * Render chart to SVG
16
+ */
17
+ function render(config, series) {
18
+ const width = config.width || defaultWidth;
19
+ const height = config.height || defaultHeight;
20
+ const palette = palettes[config.theme || 'default'];
21
+ const chartWidth = width - margin.left - margin.right;
22
+ const chartHeight = height - margin.top - margin.bottom;
23
+ let svg = `<svg width="${width}" height="${height}" viewBox="0 0 ${width} ${height}" xmlns="http://www.w3.org/2000/svg">\n`;
24
+ // Background
25
+ svg += ` <rect width="${width}" height="${height}" fill="${palette.background[0]}" />\n`;
26
+ // Title
27
+ if (config.title) {
28
+ svg += ` <text x="${width / 2}" y="30" text-anchor="middle" font-family="sans-serif" font-size="18" font-weight="bold" fill="${palette.text.primary}">${escapeHtml(config.title)}</text>\n`;
29
+ }
30
+ // Chart group
31
+ svg += ` <g transform="translate(${margin.left}, ${margin.top})">\n`;
32
+ // Render based on chart type
33
+ switch (config.type) {
34
+ case 'bar':
35
+ svg += renderBarChart(chartWidth, chartHeight, series, palette, config);
36
+ break;
37
+ case 'line':
38
+ svg += renderLineChart(chartWidth, chartHeight, series, palette, config);
39
+ break;
40
+ case 'pie':
41
+ case 'donut':
42
+ svg += renderPieChart(chartWidth, chartHeight, series, palette, config);
43
+ break;
44
+ case 'area':
45
+ svg += renderAreaChart(chartWidth, chartHeight, series, palette, config);
46
+ break;
47
+ default:
48
+ svg += renderPlaceholder(chartWidth, chartHeight, config.type);
49
+ }
50
+ // Axes
51
+ if (['bar', 'line', 'area'].includes(config.type)) {
52
+ svg += renderAxes(chartWidth, chartHeight, series, config, palette);
53
+ }
54
+ svg += ` </g>\n`;
55
+ svg += `</svg>`;
56
+ return svg;
57
+ }
58
+ /**
59
+ * Render bar chart
60
+ */
61
+ function renderBarChart(width, height, series, palette, config) {
62
+ let svg = '';
63
+ if (series.length === 0)
64
+ return svg;
65
+ const allData = series.flatMap(s => s.data);
66
+ const maxValue = Math.max(...allData.map(d => (d.y || d.value || 0)));
67
+ const categories = [...new Set(allData.map(d => d.x || d.name))];
68
+ const barWidth = (width / categories.length) * 0.6 / series.length;
69
+ const scaleY = height / (maxValue * 1.1);
70
+ series.forEach((s, seriesIndex) => {
71
+ const color = s.color || palette.primary[seriesIndex % palette.primary.length];
72
+ s.data.forEach((point, pointIndex) => {
73
+ const value = (point.y || point.value || 0);
74
+ const barHeight = value * scaleY;
75
+ const x = (pointIndex + 0.2) * (width / categories.length) + seriesIndex * barWidth;
76
+ const y = height - barHeight;
77
+ svg += ` <rect x="${x}" y="${y}" width="${barWidth}" height="${barHeight}" fill="${color}" />\n`;
78
+ });
79
+ });
80
+ return svg;
81
+ }
82
+ /**
83
+ * Render line chart
84
+ */
85
+ function renderLineChart(width, height, series, palette, config) {
86
+ let svg = '';
87
+ if (series.length === 0)
88
+ return svg;
89
+ const allData = series.flatMap(s => s.data);
90
+ const maxValue = Math.max(...allData.map(d => (d.y || 0)));
91
+ const scaleX = width / (allData.length - 1 || 1);
92
+ const scaleY = height / (maxValue * 1.1);
93
+ series.forEach((s, seriesIndex) => {
94
+ const color = s.color || palette.primary[seriesIndex % palette.primary.length];
95
+ // Generate path
96
+ let path = '';
97
+ s.data.forEach((point, index) => {
98
+ const x = index * scaleX;
99
+ const y = height - (point.y || 0) * scaleY;
100
+ path += index === 0 ? `M ${x} ${y}` : ` L ${x} ${y}`;
101
+ });
102
+ svg += ` <path d="${path}" fill="none" stroke="${color}" stroke-width="2" />\n`;
103
+ // Data points
104
+ if (config.dataLabels) {
105
+ s.data.forEach((point, index) => {
106
+ const x = index * scaleX;
107
+ const y = height - (point.y || 0) * scaleY;
108
+ svg += ` <circle cx="${x}" cy="${y}" r="4" fill="${color}" />\n`;
109
+ });
110
+ }
111
+ });
112
+ return svg;
113
+ }
114
+ /**
115
+ * Render pie/donut chart
116
+ */
117
+ function renderPieChart(width, height, series, palette, config) {
118
+ let svg = '';
119
+ if (series.length === 0)
120
+ return svg;
121
+ const data = series[0].data;
122
+ const total = data.reduce((sum, d) => sum + (d.y || d.value || 0), 0);
123
+ const centerX = width / 2;
124
+ const centerY = height / 2;
125
+ const radius = Math.min(width, height) / 2 * 0.8;
126
+ const innerRadius = config.type === 'donut' ? radius * 0.5 : 0;
127
+ let currentAngle = -Math.PI / 2;
128
+ data.forEach((point, index) => {
129
+ const value = (point.y || point.value || 0);
130
+ const angle = (value / total) * 2 * Math.PI;
131
+ const color = palette.primary[index % palette.primary.length];
132
+ const x1 = centerX + Math.cos(currentAngle) * radius;
133
+ const y1 = centerY + Math.sin(currentAngle) * radius;
134
+ const x2 = centerX + Math.cos(currentAngle + angle) * radius;
135
+ const y2 = centerY + Math.sin(currentAngle + angle) * radius;
136
+ const largeArc = angle > Math.PI ? 1 : 0;
137
+ if (innerRadius > 0) {
138
+ // Donut
139
+ const ix1 = centerX + Math.cos(currentAngle) * innerRadius;
140
+ const iy1 = centerY + Math.sin(currentAngle) * innerRadius;
141
+ const ix2 = centerX + Math.cos(currentAngle + angle) * innerRadius;
142
+ const iy2 = centerY + Math.sin(currentAngle + angle) * innerRadius;
143
+ svg += ` <path d="M ${x1} ${y1} A ${radius} ${radius} 0 ${largeArc} 1 ${x2} ${y2} L ${ix2} ${iy2} A ${innerRadius} ${innerRadius} 0 ${largeArc} 0 ${ix1} ${iy1} Z" fill="${color}" />\n`;
144
+ }
145
+ else {
146
+ // Pie
147
+ svg += ` <path d="M ${centerX} ${centerY} L ${x1} ${y1} A ${radius} ${radius} 0 ${largeArc} 1 ${x2} ${y2} Z" fill="${color}" />\n`;
148
+ }
149
+ currentAngle += angle;
150
+ });
151
+ return svg;
152
+ }
153
+ /**
154
+ * Render area chart
155
+ */
156
+ function renderAreaChart(width, height, series, palette, config) {
157
+ let svg = '';
158
+ if (series.length === 0)
159
+ return svg;
160
+ const allData = series.flatMap(s => s.data);
161
+ const maxValue = Math.max(...allData.map(d => (d.y || 0)));
162
+ const scaleX = width / (allData.length - 1 || 1);
163
+ const scaleY = height / (maxValue * 1.1);
164
+ series.forEach((s, seriesIndex) => {
165
+ const color = s.color || palette.primary[seriesIndex % palette.primary.length];
166
+ const fillColor = color + '40'; // 25% opacity
167
+ // Generate area path
168
+ let path = '';
169
+ s.data.forEach((point, index) => {
170
+ const x = index * scaleX;
171
+ const y = height - (point.y || 0) * scaleY;
172
+ path += index === 0 ? `M ${x} ${y}` : ` L ${x} ${y}`;
173
+ });
174
+ // Close the area
175
+ path += ` L ${width} ${height} L 0 ${height} Z`;
176
+ svg += ` <path d="${path}" fill="${fillColor}" stroke="${color}" stroke-width="2" />\n`;
177
+ });
178
+ return svg;
179
+ }
180
+ /**
181
+ * Render placeholder for unsupported chart types
182
+ */
183
+ function renderPlaceholder(width, height, type) {
184
+ return ` <rect x="${width / 4}" y="${height / 3}" width="${width / 2}" height="${height / 3}" fill="#e5e7eb" rx="8" />\n <text x="${width / 2}" y="${height / 2}" text-anchor="middle" font-family="sans-serif" font-size="14" fill="#6b7280">${type} chart</text>\n`;
185
+ }
186
+ /**
187
+ * Render axes
188
+ */
189
+ function renderAxes(width, height, series, config, palette) {
190
+ let svg = '';
191
+ // Y-axis
192
+ svg += ` <line x1="0" y1="0" x2="0" y2="${height}" stroke="${palette.background[2]}" stroke-width="1" />\n`;
193
+ // X-axis
194
+ svg += ` <line x1="0" y1="${height}" x2="${width}" y2="${height}" stroke="${palette.background[2]}" stroke-width="1" />\n`;
195
+ // Y-axis labels
196
+ const yAxis = config.yAxis || {};
197
+ const maxValue = Math.max(...series.flatMap(s => s.data.map(d => (d.y || 0))));
198
+ const steps = 5;
199
+ for (let i = 0; i <= steps; i++) {
200
+ const value = (maxValue / steps) * i;
201
+ const y = height - (height / steps) * i;
202
+ svg += ` <text x="-10" y="${y + 4}" text-anchor="end" font-family="sans-serif" font-size="12" fill="${palette.text.secondary}">${Math.round(value)}</text>\n`;
203
+ // Grid line
204
+ if (config.xAxis?.grid?.enabled !== false && i > 0) {
205
+ svg += ` <line x1="0" y1="${y}" x2="${width}" y2="${y}" stroke="${palette.background[2]}" stroke-width="1" stroke-dasharray="4,4" />\n`;
206
+ }
207
+ }
208
+ // Axis titles
209
+ if (yAxis.title) {
210
+ svg += ` <text x="${-margin.left + 20}" y="${height / 2}" transform="rotate(-90, ${-margin.left + 20}, ${height / 2})" text-anchor="middle" font-family="sans-serif" font-size="12" fill="${palette.text.secondary}">${escapeHtml(yAxis.title)}</text>\n`;
211
+ }
212
+ if (config.xAxis?.title) {
213
+ svg += ` <text x="${width / 2}" y="${height + 40}" text-anchor="middle" font-family="sans-serif" font-size="12" fill="${palette.text.secondary}">${escapeHtml(config.xAxis.title)}</text>\n`;
214
+ }
215
+ return svg;
216
+ }
217
+ /**
218
+ * Escape HTML special characters
219
+ */
220
+ function escapeHtml(text) {
221
+ return text
222
+ .replace(/&/g, '&amp;')
223
+ .replace(/</g, '&lt;')
224
+ .replace(/>/g, '&gt;')
225
+ .replace(/"/g, '&quot;')
226
+ .replace(/'/g, '&#039;');
227
+ }
228
+ /**
229
+ * Get chart metadata
230
+ */
231
+ function getMetadata(type) {
232
+ const metadata = {
233
+ line: {
234
+ type: 'line',
235
+ name: 'Line Chart',
236
+ description: 'Show trends over time or categories',
237
+ axes: ['x', 'y'],
238
+ dataStructure: 'Array of { x, y } points',
239
+ useCases: ['Time series', 'Trends', 'Progress over time'],
240
+ },
241
+ bar: {
242
+ type: 'bar',
243
+ name: 'Bar Chart',
244
+ description: 'Compare values across categories',
245
+ axes: ['x', 'y'],
246
+ dataStructure: 'Array of { x, y } points',
247
+ useCases: ['Comparisons', 'Rankings', 'Category distribution'],
248
+ },
249
+ pie: {
250
+ type: 'pie',
251
+ name: 'Pie Chart',
252
+ description: 'Show part-to-whole relationships',
253
+ axes: [],
254
+ dataStructure: 'Array of { name, value }',
255
+ useCases: ['Composition', 'Percentage distribution'],
256
+ },
257
+ donut: {
258
+ type: 'donut',
259
+ name: 'Donut Chart',
260
+ description: 'Show part-to-whole with center space',
261
+ axes: [],
262
+ dataStructure: 'Array of { name, value }',
263
+ useCases: ['Composition', 'Percentage distribution'],
264
+ },
265
+ area: {
266
+ type: 'area',
267
+ name: 'Area Chart',
268
+ description: 'Show cumulative totals over time',
269
+ axes: ['x', 'y'],
270
+ dataStructure: 'Array of { x, y } points',
271
+ useCases: ['Volume over time', 'Cumulative data'],
272
+ },
273
+ };
274
+ return metadata[type] || metadata.line;
275
+ }
276
+ return {
277
+ render,
278
+ getMetadata,
279
+ };
280
+ }
281
+ /**
282
+ * Global SVG renderer instance
283
+ */
284
+ export const globalSVGRenderer = createSVGRenderer();
285
+ //# sourceMappingURL=svg-renderer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"svg-renderer.js","sourceRoot":"","sources":["../../src/charts/svg-renderer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AASpC;;GAEG;AACH,MAAM,UAAU,iBAAiB;IAC/B,MAAM,YAAY,GAAG,GAAG,CAAC;IACzB,MAAM,aAAa,GAAG,GAAG,CAAC;IAC1B,MAAM,MAAM,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;IAE5D;;OAEG;IACH,SAAS,MAAM,CAAC,MAAmB,EAAE,MAAoB;QACvD,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,IAAI,YAAY,CAAC;QAC3C,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,IAAI,aAAa,CAAC;QAC9C,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,KAAK,IAAI,SAAS,CAAC,CAAC;QAEpD,MAAM,UAAU,GAAG,KAAK,GAAG,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC;QACtD,MAAM,WAAW,GAAG,MAAM,GAAG,MAAM,CAAC,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC;QAExD,IAAI,GAAG,GAAG,eAAe,KAAK,aAAa,MAAM,kBAAkB,KAAK,IAAI,MAAM,yCAAyC,CAAC;QAE5H,aAAa;QACb,GAAG,IAAI,kBAAkB,KAAK,aAAa,MAAM,WAAW,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC;QAE1F,QAAQ;QACR,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;YACjB,GAAG,IAAI,cAAc,KAAK,GAAG,CAAC,kGAAkG,OAAO,CAAC,IAAI,CAAC,OAAO,KAAK,UAAU,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AC/C,IAAI,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC;gBAChB,aAAa,EAAE,0BAA0B;gBACzC,QAAQ,EAAE,CAAC,kBAAkB,EAAE,iBAAiB,CAAC;aAClD;SACF,CAAC;QAEF,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,QAAQ,CAAC,IAAI,CAAC;IACzC,CAAC;IAED,OAAO;QACL,MAAM;QACN,WAAW;KACZ,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,iBAAiB,EAAE,CAAC"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * A2R Data Visualization
3
+ *
4
+ * Charts, graphs, and dashboards for A2R platform.
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * import { createSVGRenderer, createDashboard } from '@allternit/viz';
9
+ *
10
+ * const renderer = createSVGRenderer();
11
+ *
12
+ * const svg = renderer.render({
13
+ * type: 'bar',
14
+ * title: 'Sales by Month',
15
+ * width: 800,
16
+ * height: 400,
17
+ * }, [
18
+ * {
19
+ * id: 'sales',
20
+ * name: 'Sales',
21
+ * data: [
22
+ * { x: 'Jan', y: 100 },
23
+ * { x: 'Feb', y: 150 },
24
+ * { x: 'Mar', y: 200 },
25
+ * ],
26
+ * },
27
+ * ]);
28
+ * ```
29
+ */
30
+ export type { ChartType, ChartConfig, AxisConfig, LegendConfig, TooltipConfig, DataSeries, DataPoint, DashboardConfig, WidgetConfig, GridPosition, MetricConfig, TableConfig, TableColumn, DataSource, DataTransform, ChartMetadata, ChartPalette, ExportOptions, VizEvent, } from './types';
31
+ export { palettes } from './types';
32
+ export { createSVGRenderer, globalSVGRenderer, type SVGRenderer, } from './charts/svg-renderer';
33
+ export declare const VERSION = "0.1.0";
34
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,34 @@
1
+ /**
2
+ * A2R Data Visualization
3
+ *
4
+ * Charts, graphs, and dashboards for A2R platform.
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * import { createSVGRenderer, createDashboard } from '@allternit/viz';
9
+ *
10
+ * const renderer = createSVGRenderer();
11
+ *
12
+ * const svg = renderer.render({
13
+ * type: 'bar',
14
+ * title: 'Sales by Month',
15
+ * width: 800,
16
+ * height: 400,
17
+ * }, [
18
+ * {
19
+ * id: 'sales',
20
+ * name: 'Sales',
21
+ * data: [
22
+ * { x: 'Jan', y: 100 },
23
+ * { x: 'Feb', y: 150 },
24
+ * { x: 'Mar', y: 200 },
25
+ * ],
26
+ * },
27
+ * ]);
28
+ * ```
29
+ */
30
+ export type { ChartType, ChartConfig, AxisConfig, LegendConfig, TooltipConfig, DataSeries, DataPoint, DashboardConfig, WidgetConfig, GridPosition, MetricConfig, TableConfig, TableColumn, DataSource, DataTransform, ChartMetadata, ChartPalette, ExportOptions, VizEvent, } from './types';
31
+ export { palettes } from './types';
32
+ export { createSVGRenderer, globalSVGRenderer, type SVGRenderer, } from './charts/svg-renderer';
33
+ export declare const VERSION = "0.1.0";
34
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAGH,YAAY,EACV,SAAS,EACT,WAAW,EACX,UAAU,EACV,YAAY,EACZ,aAAa,EACb,UAAU,EACV,SAAS,EACT,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,WAAW,EACX,UAAU,EACV,aAAa,EACb,aAAa,EACb,YAAY,EACZ,aAAa,EACb,QAAQ,GACT,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAGnC,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,KAAK,WAAW,GACjB,MAAM,uBAAuB,CAAC;AAG/B,eAAO,MAAM,OAAO,UAAU,CAAC"}