@file-viewer/renderer-spreadsheet 3.3.4 → 3.3.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.
@@ -61,20 +61,20 @@ const showsSeriesLine = (chart, series) => {
61
61
  if (series.lineVisible === false) {
62
62
  return false;
63
63
  }
64
- return chart.type !== 'scatter' || ((_a = chart.scatterStyle) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== 'marker';
64
+ return (series.type || chart.type) !== 'scatter' || ((_a = chart.scatterStyle) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== 'marker';
65
65
  };
66
66
  const showsSeriesMarker = (chart, series) => {
67
67
  if (series.marker) {
68
68
  return series.marker.symbol.toLowerCase() !== 'none';
69
69
  }
70
- if (chart.type !== 'scatter') {
70
+ if ((series.type || chart.type) !== 'scatter') {
71
71
  return false;
72
72
  }
73
73
  const scatterStyle = (chart.scatterStyle || 'lineMarker').toLowerCase();
74
74
  return scatterStyle === 'marker' || scatterStyle.endsWith('marker');
75
75
  };
76
- const categoryLabelIndexes = (count, plotWidth) => {
77
- const limit = Math.max(2, Math.floor(plotWidth / 28));
76
+ const categoryLabelIndexes = (count, plotWidth, labelWidth = 28) => {
77
+ const limit = Math.max(2, Math.floor(plotWidth / labelWidth));
78
78
  if (count <= limit) {
79
79
  return Array.from({ length: count }, (_, index) => index);
80
80
  }
@@ -157,14 +157,18 @@ const drawSeriesMarker = (documentRef, svg, series, color, x, y) => {
157
157
  }
158
158
  };
159
159
  const categoryLabels = (chart) => {
160
- const labels = chart.series.reduce((longest, series) => series.categories.length > longest.length ? series.categories : longest, []);
160
+ const matching = chart.categoryAxisId
161
+ ? chart.series.filter(series => series.categoryAxisId === chart.categoryAxisId)
162
+ : [];
163
+ const candidates = matching.some(series => series.categories.length) ? matching : chart.series;
164
+ const labels = candidates.reduce((longest, series) => series.categories.length > longest.length ? series.categories : longest, []);
161
165
  const valueCount = chart.series.reduce((count, series) => Math.max(count, series.values.length), 0);
162
166
  return labels.length ? labels : Array.from({ length: valueCount }, (_, index) => `${index + 1}`);
163
167
  };
164
- const valueDomain = (chart) => {
168
+ const valueDomain = (seriesList) => {
165
169
  let min = 0;
166
170
  let max = 0;
167
- chart.series.forEach((series) => {
171
+ seriesList.forEach((series) => {
168
172
  series.values.forEach((value) => {
169
173
  if (!Number.isFinite(value)) {
170
174
  return;
@@ -178,14 +182,16 @@ const valueDomain = (chart) => {
178
182
  }
179
183
  return { min, max, span: max - min };
180
184
  };
181
- const createPlot = (chart) => {
185
+ const createPlot = (chart, rightAxis = false) => {
182
186
  const hasTitle = !!chart.title;
183
187
  const hasLegend = !!chart.legendPosition;
184
188
  const rightLegend = chart.legendPosition === 'right';
185
- const top = hasTitle ? 48 : 24;
186
- const bottom = hasLegend && !rightLegend ? 302 : 326;
189
+ const topLegend = chart.legendPosition === 'top';
190
+ const legendRows = Math.ceil(Math.min(chart.series.length, MAX_LEGEND_ITEMS) / 4);
191
+ const top = (hasTitle ? 48 : 24) + (topLegend ? legendRows * 20 : 0);
192
+ const bottom = hasLegend && !rightLegend && !topLegend ? 302 : 326;
187
193
  const left = chart.valueAxisTitle ? 76 : 58;
188
- const right = rightLegend ? 492 : 612;
194
+ const right = (rightLegend ? 492 : 612) - (rightAxis ? 42 : 0);
189
195
  return {
190
196
  left,
191
197
  top,
@@ -194,76 +200,90 @@ const createPlot = (chart) => {
194
200
  bottom
195
201
  };
196
202
  };
197
- const drawValueGrid = (documentRef, svg, plot, domain, fontSize = 10) => {
203
+ const drawValueGrid = (documentRef, svg, plot, domain, fontSize = 10, axis) => {
204
+ const right = (axis === null || axis === void 0 ? void 0 : axis.position) === 'right';
205
+ const edge = right ? plot.left + plot.width : plot.left;
206
+ if (right) {
207
+ svg.appendChild(svgElement(documentRef, 'line', {
208
+ x1: edge, x2: edge, y1: plot.top, y2: plot.bottom, stroke: '#9ca3af'
209
+ }));
210
+ }
198
211
  const tickCount = 5;
199
212
  for (let index = 0; index <= tickCount; index += 1) {
200
213
  const ratio = index / tickCount;
201
214
  const y = plot.bottom - ratio * plot.height;
202
215
  const value = domain.min + ratio * domain.span;
203
- svg.appendChild(svgElement(documentRef, 'line', {
204
- x1: plot.left,
205
- y1: y,
206
- x2: plot.left + plot.width,
207
- y2: y,
208
- stroke: index === 0 ? '#9ca3af' : '#e5e7eb',
209
- 'stroke-width': 1
210
- }));
211
- svg.appendChild(svgText(documentRef, Number.isInteger(value) ? `${value}` : value.toFixed(1), plot.left - 8, y + fontSize / 3, {
212
- anchor: 'end',
213
- size: fontSize
214
- }));
216
+ if (!right)
217
+ svg.appendChild(svgElement(documentRef, 'line', {
218
+ x1: plot.left,
219
+ y1: y,
220
+ x2: plot.left + plot.width,
221
+ y2: y,
222
+ stroke: index === 0 ? '#9ca3af' : '#e5e7eb',
223
+ 'stroke-width': 1
224
+ }));
225
+ if (!(axis === null || axis === void 0 ? void 0 : axis.hidden)) {
226
+ const label = svgText(documentRef, Number.isInteger(value) ? `${value}` : value.toFixed(1), edge + (right ? 8 : -8), y + fontSize / 3, {
227
+ anchor: right ? 'start' : 'end',
228
+ size: fontSize
229
+ });
230
+ if (axis) {
231
+ label.classList.add('excel-chart-value-label');
232
+ label.dataset.axisId = axis.id;
233
+ label.dataset.axisSide = axis.position;
234
+ }
235
+ svg.appendChild(label);
236
+ }
215
237
  }
216
238
  };
217
- const drawCategoryLabels = (documentRef, svg, chart, plot, pointAxis = false) => {
239
+ const drawCategoryLabels = (documentRef, svg, chart, plot, pointAxis = false, bandCount) => {
218
240
  const categories = categoryLabels(chart);
219
241
  if (!categories.length) {
220
242
  return;
221
243
  }
222
244
  const categorySeries = chart.series.find(series => series.categories === categories);
223
245
  const sourcePointCount = Math.max(...chart.series.map(series => series.sourcePointCount || Math.max(series.values.length, series.categories.length)), categories.length);
224
- const step = plot.width / categories.length;
246
+ const step = plot.width / (bandCount || categories.length);
225
247
  const visible = categories.flatMap((label, i) => label ? [i] : []);
226
- categoryLabelIndexes(visible.length, plot.width).forEach((visibleIndex) => {
248
+ const fontSize = axisFontSize(chart, chart.categoryAxisFontSize, 10);
249
+ const dateLabelWidth = chart.categoryAxisDate ? categories.reduce((width, label) => Math.max(width, label.length * fontSize * (/[^\x00-\x7f]/.test(label) ? 0.8 : 0.55) + 8), 28) : 28;
250
+ categoryLabelIndexes(visible.length, plot.width, dateLabelWidth).forEach((visibleIndex) => {
227
251
  var _a, _b;
228
252
  const index = visible[visibleIndex];
229
253
  const category = categories[index];
230
254
  const maxLength = categories.length > 8 ? 8 : 14;
231
- const label = category.length > maxLength ? `${category.slice(0, maxLength - 1)}…` : category;
255
+ const label = !chart.categoryAxisDate && category.length > maxLength ? `${category.slice(0, maxLength - 1)}…` : category;
232
256
  const sourceIndex = (_b = (_a = categorySeries === null || categorySeries === void 0 ? void 0 : categorySeries.sourcePointIndexes) === null || _a === void 0 ? void 0 : _a[index]) !== null && _b !== void 0 ? _b : index;
233
257
  const x = pointAxis && categories.length > 1
234
258
  ? plot.left + (sourceIndex / Math.max(sourcePointCount - 1, 1)) * plot.width
235
- : plot.left + (index + 0.5) * step;
259
+ : plot.left + ((bandCount ? sourceIndex : index) + 0.5) * step;
236
260
  const labelElement = svgText(documentRef, label, x, plot.bottom + 17, {
237
261
  anchor: 'middle',
238
- size: axisFontSize(chart, chart.categoryAxisFontSize, 10)
262
+ size: fontSize
239
263
  });
240
264
  labelElement.classList.add('excel-chart-category-label');
241
265
  labelElement.dataset.categoryIndex = `${sourceIndex}`;
242
266
  svg.appendChild(labelElement);
243
267
  });
244
268
  };
245
- const drawColumnChart = (documentRef, svg, chart, plot) => {
246
- const domain = valueDomain(chart);
247
- const categories = categoryLabels(chart);
248
- const categoryCount = Math.max(categories.length, chart.series.reduce((count, series) => Math.max(count, series.values.length), 0), 1);
269
+ const drawColumnSeries = (documentRef, svg, plot, entries, categoryCount, domainFor) => {
249
270
  const groupWidth = plot.width / categoryCount;
250
- const seriesCount = Math.max(chart.series.length, 1);
251
- const slotWidth = (groupWidth * 0.76) / seriesCount;
252
- const zeroY = plot.bottom - ((0 - domain.min) / domain.span) * plot.height;
253
- drawValueGrid(documentRef, svg, plot, domain, axisFontSize(chart, chart.valueAxisFontSize, 10));
254
- chart.series.forEach((series, seriesIndex) => {
271
+ const slotWidth = (groupWidth * 0.76) / Math.max(entries.length, 1);
272
+ entries.forEach(({ series, index }, slot) => {
273
+ const domain = domainFor(series);
274
+ const zeroY = plot.bottom - ((0 - domain.min) / domain.span) * plot.height;
255
275
  series.values.forEach((value, valueIndex) => {
256
276
  if (!Number.isFinite(value))
257
277
  return;
258
278
  const valueY = plot.bottom - ((value - domain.min) / domain.span) * plot.height;
259
- const x = plot.left + valueIndex * groupWidth + groupWidth * 0.12 + seriesIndex * slotWidth;
279
+ const x = plot.left + valueIndex * groupWidth + groupWidth * 0.12 + slot * slotWidth;
260
280
  const y = Math.min(zeroY, valueY);
261
281
  const rect = svgElement(documentRef, 'rect', {
262
282
  x,
263
283
  y,
264
284
  width: Math.max(1, slotWidth - 2),
265
285
  height: Math.max(1, Math.abs(zeroY - valueY)),
266
- fill: seriesColor(series, seriesIndex),
286
+ fill: seriesColor(series, index),
267
287
  rx: 1
268
288
  });
269
289
  const title = svgElement(documentRef, 'title');
@@ -272,10 +292,16 @@ const drawColumnChart = (documentRef, svg, chart, plot) => {
272
292
  svg.appendChild(rect);
273
293
  });
274
294
  });
295
+ };
296
+ const drawColumnChart = (documentRef, svg, chart, plot) => {
297
+ const domain = valueDomain(chart.series);
298
+ const categoryCount = chart.series.reduce((count, series) => Math.max(count, series.values.length, series.categories.length), 1);
299
+ drawValueGrid(documentRef, svg, plot, domain, axisFontSize(chart, chart.valueAxisFontSize, 10));
300
+ drawColumnSeries(documentRef, svg, plot, chart.series.map((series, index) => ({ series, index })), categoryCount, () => domain);
275
301
  drawCategoryLabels(documentRef, svg, chart, plot);
276
302
  };
277
303
  const drawHorizontalBarChart = (documentRef, svg, chart, plot) => {
278
- const domain = valueDomain(chart);
304
+ const domain = valueDomain(chart.series);
279
305
  const categories = categoryLabels(chart);
280
306
  const categoryCount = Math.max(categories.length, chart.series.reduce((count, series) => Math.max(count, series.values.length), 0), 1);
281
307
  const groupHeight = plot.height / categoryCount;
@@ -317,76 +343,111 @@ const drawHorizontalBarChart = (documentRef, svg, chart, plot) => {
317
343
  }));
318
344
  });
319
345
  };
320
- const drawLineChart = (documentRef, svg, chart, plot, fillArea) => {
321
- const domain = valueDomain(chart);
322
- const count = Math.max(chart.series.reduce((pointCount, series) => Math.max(pointCount, series.sourcePointCount || series.values.length), 0), 1);
323
- const step = count > 1 ? plot.width / (count - 1) : plot.width;
324
- drawValueGrid(documentRef, svg, plot, domain, axisFontSize(chart, chart.valueAxisFontSize, 10));
325
- chart.series.forEach((series, seriesIndex) => {
326
- var _a, _b;
327
- const pointIndexes = extremaPointIndexes(series.values, Math.max(64, Math.floor(plot.width * MAX_LINE_POINTS_PER_PIXEL)), series.spanBlankIndexes);
328
- const spanning = new Set(series.spanBlankIndexes || []);
329
- const segments = [];
330
- let segment = [];
331
- for (const index of pointIndexes) {
332
- const value = series.values[index];
333
- if (!Number.isFinite(value)) {
334
- if (spanning.has(index))
335
- continue;
336
- if (segment.length)
337
- segments.push(segment);
338
- segment = [];
346
+ const drawLineSeries = (documentRef, svg, chart, plot, entry, domain, xAt, fillArea = false) => {
347
+ var _a, _b;
348
+ const { series, index: seriesIndex } = entry;
349
+ const pointIndexes = extremaPointIndexes(series.values, Math.max(64, Math.floor(plot.width * MAX_LINE_POINTS_PER_PIXEL)), series.spanBlankIndexes);
350
+ const spanning = new Set(series.spanBlankIndexes || []);
351
+ const segments = [];
352
+ let segment = [];
353
+ for (const index of pointIndexes) {
354
+ const value = series.values[index];
355
+ if (!Number.isFinite(value)) {
356
+ if (spanning.has(index))
339
357
  continue;
340
- }
341
- const sourceIndex = (_b = (_a = series.sourcePointIndexes) === null || _a === void 0 ? void 0 : _a[index]) !== null && _b !== void 0 ? _b : index;
342
- segment.push({
343
- x: plot.left + (count > 1 ? sourceIndex * step : plot.width / 2),
344
- y: plot.bottom - ((value - domain.min) / domain.span) * plot.height
345
- });
358
+ if (segment.length)
359
+ segments.push(segment);
360
+ segment = [];
361
+ continue;
346
362
  }
347
- if (segment.length)
348
- segments.push(segment);
349
- const points = segments.flat();
350
- if (!points.length)
351
- return;
352
- const pathFor = (points) => points
353
- .map((point, index) => `${index ? 'L' : 'M'}${point.x},${point.y}`).join(' ');
354
- const pathData = segments.map(pathFor).join(' ');
355
- if (fillArea) {
356
- const zeroY = plot.bottom - ((0 - domain.min) / domain.span) * plot.height;
357
- for (const points of segments) {
358
- if (points.length < 2)
359
- continue;
360
- svg.appendChild(svgElement(documentRef, 'path', {
361
- class: 'excel-chart-area',
362
- d: `${pathFor(points)} L${points[points.length - 1].x},${zeroY} L${points[0].x},${zeroY} Z`,
363
- fill: seriesColor(series, seriesIndex), opacity: 0.2
364
- }));
365
- }
366
- }
367
- const color = seriesColor(series, seriesIndex);
368
- const dashArray = seriesDashArray(series);
369
- if (showsSeriesLine(chart, series)) {
363
+ const sourceIndex = (_b = (_a = series.sourcePointIndexes) === null || _a === void 0 ? void 0 : _a[index]) !== null && _b !== void 0 ? _b : index;
364
+ segment.push({
365
+ x: xAt(sourceIndex),
366
+ y: plot.bottom - ((value - domain.min) / domain.span) * plot.height
367
+ });
368
+ }
369
+ if (segment.length)
370
+ segments.push(segment);
371
+ const points = segments.flat();
372
+ if (!points.length)
373
+ return;
374
+ const pathFor = (points) => points
375
+ .map((point, index) => `${index ? 'L' : 'M'}${point.x},${point.y}`).join(' ');
376
+ const pathData = segments.map(pathFor).join(' ');
377
+ if (fillArea) {
378
+ const zeroY = plot.bottom - ((0 - domain.min) / domain.span) * plot.height;
379
+ for (const points of segments) {
380
+ if (points.length < 2)
381
+ continue;
370
382
  svg.appendChild(svgElement(documentRef, 'path', {
371
- class: 'excel-chart-series-line',
372
- 'data-source-point-count': series.sourcePointCount || series.values.length,
373
- 'data-transferred-point-count': series.values.length,
374
- 'data-rendered-point-count': points.length,
375
- d: pathData,
376
- fill: 'none',
377
- stroke: color,
378
- 'stroke-width': seriesStrokeWidth(series),
379
- ...(dashArray ? { 'stroke-dasharray': dashArray } : {}),
380
- 'stroke-linejoin': 'round',
381
- 'stroke-linecap': 'round'
383
+ class: 'excel-chart-area',
384
+ d: `${pathFor(points)} L${points[points.length - 1].x},${zeroY} L${points[0].x},${zeroY} Z`,
385
+ fill: seriesColor(series, seriesIndex), opacity: 0.2
382
386
  }));
383
387
  }
384
- if (showsSeriesMarker(chart, series)) {
385
- points.forEach((point) => drawSeriesMarker(documentRef, svg, series, color, point.x, point.y));
386
- }
387
- });
388
+ }
389
+ const color = seriesColor(series, seriesIndex);
390
+ const dashArray = seriesDashArray(series);
391
+ if (showsSeriesLine(chart, series)) {
392
+ svg.appendChild(svgElement(documentRef, 'path', {
393
+ class: 'excel-chart-series-line',
394
+ ...(series.valueAxisId ? { 'data-axis-id': series.valueAxisId } : {}),
395
+ 'data-source-point-count': series.sourcePointCount || series.values.length,
396
+ 'data-transferred-point-count': series.values.length,
397
+ 'data-rendered-point-count': points.length,
398
+ d: pathData,
399
+ fill: 'none',
400
+ stroke: color,
401
+ 'stroke-width': seriesStrokeWidth(series),
402
+ ...(dashArray ? { 'stroke-dasharray': dashArray } : {}),
403
+ 'stroke-linejoin': 'round',
404
+ 'stroke-linecap': 'round'
405
+ }));
406
+ }
407
+ if (showsSeriesMarker(chart, series)) {
408
+ points.forEach((point) => drawSeriesMarker(documentRef, svg, series, color, point.x, point.y));
409
+ }
410
+ };
411
+ const drawLineChart = (documentRef, svg, chart, plot, fillArea) => {
412
+ const domain = valueDomain(chart.series);
413
+ const count = chart.series.reduce((pointCount, series) => Math.max(pointCount, series.sourcePointCount || series.values.length), 1);
414
+ const xAt = (index) => plot.left + plot.width * (count > 1 ? index / (count - 1) : 0.5);
415
+ drawValueGrid(documentRef, svg, plot, domain, axisFontSize(chart, chart.valueAxisFontSize, 10));
416
+ chart.series.forEach((series, index) => drawLineSeries(documentRef, svg, chart, plot, { series, index }, domain, xAt, fillArea));
388
417
  drawCategoryLabels(documentRef, svg, chart, plot, true);
389
418
  };
419
+ const drawCombinationChart = (documentRef, svg, chart, plot) => {
420
+ var _a, _b;
421
+ const byAxis = new Map();
422
+ const entries = chart.series.map((series, index) => {
423
+ const group = byAxis.get(series.valueAxisId);
424
+ if (group)
425
+ group.push(series);
426
+ else
427
+ byAxis.set(series.valueAxisId, [series]);
428
+ return { series, index };
429
+ });
430
+ const domains = new Map([...byAxis].map(([id, series]) => [id, valueDomain(series)]));
431
+ const fallback = valueDomain(chart.series);
432
+ const domainFor = (series) => domains.get(series.valueAxisId) || fallback;
433
+ const left = (_a = chart.valueAxes) === null || _a === void 0 ? void 0 : _a.find(axis => axis.position === 'left');
434
+ const right = (_b = chart.valueAxes) === null || _b === void 0 ? void 0 : _b.find(axis => axis.position === 'right' && !axis.hidden);
435
+ drawValueGrid(documentRef, svg, plot, domains.get(left === null || left === void 0 ? void 0 : left.id) || fallback, axisFontSize(chart, (left === null || left === void 0 ? void 0 : left.fontSize) || chart.valueAxisFontSize, 10), left);
436
+ if (right) {
437
+ drawValueGrid(documentRef, svg, plot, domains.get(right.id) || fallback, axisFontSize(chart, right.fontSize, 10), right);
438
+ if (right.title) {
439
+ svg.appendChild(svgText(documentRef, right.title, plot.left + plot.width + 62, plot.top + plot.height / 2, { anchor: 'middle', size: 11, rotate: 90 }));
440
+ }
441
+ }
442
+ const count = chart.series.reduce((length, series) => Math.max(length, series.sourcePointCount || series.values.length, series.categories.length), 1);
443
+ drawColumnSeries(documentRef, svg, plot, entries.filter(({ series }) => series.type === 'bar'), count, domainFor);
444
+ for (const entry of entries) {
445
+ if (entry.series.type === 'line') {
446
+ drawLineSeries(documentRef, svg, chart, plot, entry, domainFor(entry.series), index => plot.left + (index + 0.5) * plot.width / count);
447
+ }
448
+ }
449
+ drawCategoryLabels(documentRef, svg, chart, plot, false, count);
450
+ };
390
451
  const polarPoint = (cx, cy, radius, angle) => {
391
452
  const radians = ((angle - 90) * Math.PI) / 180;
392
453
  return {
@@ -448,6 +509,7 @@ const drawLegend = (documentRef, svg, chart) => {
448
509
  return;
449
510
  }
450
511
  const right = chart.legendPosition === 'right';
512
+ const top = chart.legendPosition === 'top';
451
513
  const categorySeries = chart.type === 'pie' || chart.type === 'doughnut' ? chart.series[0] : undefined;
452
514
  const entries = chart.type === 'pie' || chart.type === 'doughnut'
453
515
  ? ((categorySeries === null || categorySeries === void 0 ? void 0 : categorySeries.values) || []).slice(0, MAX_LEGEND_ITEMS).map((_, index) => ({
@@ -458,9 +520,12 @@ const drawLegend = (documentRef, svg, chart) => {
458
520
  : chart.series;
459
521
  entries.slice(0, MAX_LEGEND_ITEMS).forEach((series, index) => {
460
522
  const x = right ? 510 : 76 + (index % 4) * 136;
461
- const y = right ? 72 + index * 28 : 342 - Math.floor(index / 4) * 20;
523
+ const y = right ? 72 + index * 28 : top
524
+ ? (chart.title ? 48 : 24) + Math.floor(index / 4) * 20
525
+ : 342 - Math.floor(index / 4) * 20;
462
526
  const color = seriesColor(series, index);
463
- const lineLike = chart.type === 'line' || chart.type === 'scatter' || chart.type === 'radar';
527
+ const seriesType = series.type || chart.type;
528
+ const lineLike = seriesType === 'line' || seriesType === 'scatter' || seriesType === 'radar';
464
529
  if (lineLike) {
465
530
  if (showsSeriesLine(chart, series)) {
466
531
  const dashArray = seriesDashArray(series);
@@ -492,6 +557,7 @@ const drawLegend = (documentRef, svg, chart) => {
492
557
  });
493
558
  };
494
559
  export const renderSpreadsheetChart = (documentRef, chart) => {
560
+ var _a;
495
561
  const container = documentRef.createElement('div');
496
562
  container.className = 'excel-chart';
497
563
  container.dataset.chartId = chart.id;
@@ -522,32 +588,37 @@ export const renderSpreadsheetChart = (documentRef, chart) => {
522
588
  fill: '#1f2937'
523
589
  }));
524
590
  }
525
- const plot = createPlot(chart);
526
- switch (chart.type) {
527
- case 'pie':
528
- drawPieChart(documentRef, svg, chart, false);
529
- break;
530
- case 'doughnut':
531
- drawPieChart(documentRef, svg, chart, true);
532
- break;
533
- case 'line':
534
- case 'scatter':
535
- case 'radar':
536
- drawLineChart(documentRef, svg, chart, plot, false);
537
- break;
538
- case 'area':
539
- drawLineChart(documentRef, svg, chart, plot, true);
540
- break;
541
- case 'bar':
542
- default:
543
- if (chart.barDirection === 'bar') {
544
- drawHorizontalBarChart(documentRef, svg, chart, plot);
545
- }
546
- else {
547
- drawColumnChart(documentRef, svg, chart, plot);
548
- }
549
- break;
591
+ const rightAxis = (_a = chart.valueAxes) === null || _a === void 0 ? void 0 : _a.find(axis => axis.position === 'right' && !axis.hidden);
592
+ const plot = createPlot(chart, !!rightAxis);
593
+ if (chart.series.some(series => series.type === 'bar') && chart.series.some(series => series.type === 'line')) {
594
+ drawCombinationChart(documentRef, svg, chart, plot);
550
595
  }
596
+ else
597
+ switch (chart.type) {
598
+ case 'pie':
599
+ drawPieChart(documentRef, svg, chart, false);
600
+ break;
601
+ case 'doughnut':
602
+ drawPieChart(documentRef, svg, chart, true);
603
+ break;
604
+ case 'line':
605
+ case 'scatter':
606
+ case 'radar':
607
+ drawLineChart(documentRef, svg, chart, plot, false);
608
+ break;
609
+ case 'area':
610
+ drawLineChart(documentRef, svg, chart, plot, true);
611
+ break;
612
+ case 'bar':
613
+ default:
614
+ if (chart.barDirection === 'bar') {
615
+ drawHorizontalBarChart(documentRef, svg, chart, plot);
616
+ }
617
+ else {
618
+ drawColumnChart(documentRef, svg, chart, plot);
619
+ }
620
+ break;
621
+ }
551
622
  if (chart.categoryAxisTitle && chart.type !== 'pie' && chart.type !== 'doughnut') {
552
623
  svg.appendChild(svgText(documentRef, chart.categoryAxisTitle, plot.left + plot.width / 2, 324, {
553
624
  anchor: 'middle',
@@ -6,6 +6,7 @@ export declare const PREFETCH_BEHIND = 1;
6
6
  export declare const INDEX_COLUMN_KEY = "__index";
7
7
  export declare const ROW_KEY_FIELD = "__k";
8
8
  export declare const ROW_STATE_FIELD = "__s";
9
+ export declare const getOrdinaryWindowSize: (columns: number) => number;
9
10
  export interface SheetDefaults {
10
11
  rowHeight: number;
11
12
  colWidth: number;
@@ -46,6 +47,7 @@ export interface VirtualSheetState {
46
47
  active: boolean;
47
48
  totalRows: number;
48
49
  totalCols: number;
50
+ windowSize: number;
49
51
  indexOffset: number;
50
52
  defaults: SheetDefaults;
51
53
  dataKeys: string[];
@@ -74,15 +76,16 @@ interface CollectWindowStartsOptions {
74
76
  far?: boolean;
75
77
  startRow: number;
76
78
  totalRows: number;
79
+ windowSize?: number;
77
80
  }
78
- export declare const createEmptyVirtualState: () => VirtualSheetState;
81
+ export declare const createEmptyVirtualState: (windowSize?: number) => VirtualSheetState;
79
82
  export declare const displayCellKey: (row: number, col: number) => string;
80
83
  export declare const getDataKey: (index: number) => string;
81
84
  export declare const getRowState: (row?: VirtualRow | null) => RowStateValue;
82
85
  export declare const buildRows: (count: number) => VirtualRow[];
83
- export declare const getMaxWindowStart: (totalRows: number) => number;
84
- export declare const clampWindowStart: (startRow?: number, totalRows?: number) => number;
85
- export declare const getWindowStart: (row?: number, totalRows?: number) => number;
86
- export declare const collectWindowStarts: ({ startRow, endRow, direction, totalRows, far }: CollectWindowStartsOptions) => number[];
87
- export declare const markWindowState: (rows: VirtualRow[], totalRows: number, windowStart: number, nextState: RowStateValue) => void;
86
+ export declare const getMaxWindowStart: (totalRows: number, windowSize?: number) => number;
87
+ export declare const clampWindowStart: (startRow?: number, totalRows?: number, windowSize?: number) => number;
88
+ export declare const getWindowStart: (row?: number, totalRows?: number, windowSize?: number) => number;
89
+ export declare const collectWindowStarts: ({ startRow, endRow, direction, totalRows, windowSize, far }: CollectWindowStartsOptions) => number[];
90
+ export declare const markWindowState: (rows: VirtualRow[], totalRows: number, windowStart: number, nextState: RowStateValue, windowSize?: number) => void;
88
91
  export {};
@@ -1,9 +1,11 @@
1
+ import { ORDINARY_GRID_BUDGET } from './sourceRegion.js';
1
2
  export const WINDOW_SIZE = 500;
2
3
  export const PREFETCH_AHEAD = 3;
3
4
  export const PREFETCH_BEHIND = 1;
4
5
  export const INDEX_COLUMN_KEY = '__index';
5
6
  export const ROW_KEY_FIELD = '__k';
6
7
  export const ROW_STATE_FIELD = '__s';
8
+ export const getOrdinaryWindowSize = (columns) => Math.min(WINDOW_SIZE, Math.max(1, Math.floor(ORDINARY_GRID_BUDGET.windowCells / Math.max(1, columns))));
7
9
  export const DEFAULT_SHEET_DEFAULTS = {
8
10
  rowHeight: 20,
9
11
  colWidth: 64
@@ -13,10 +15,11 @@ export const RowState = {
13
15
  Loading: 1,
14
16
  Loaded: 2
15
17
  };
16
- export const createEmptyVirtualState = () => ({
18
+ export const createEmptyVirtualState = (windowSize = WINDOW_SIZE) => ({
17
19
  active: false,
18
20
  totalRows: 0,
19
21
  totalCols: 0,
22
+ windowSize,
20
23
  indexOffset: 0,
21
24
  defaults: { ...DEFAULT_SHEET_DEFAULTS },
22
25
  dataKeys: [],
@@ -58,39 +61,39 @@ export const buildRows = (count) => {
58
61
  }
59
62
  return rows;
60
63
  };
61
- export const getMaxWindowStart = (totalRows) => {
64
+ export const getMaxWindowStart = (totalRows, windowSize = WINDOW_SIZE) => {
62
65
  if (!totalRows) {
63
66
  return 0;
64
67
  }
65
- return Math.floor(Math.max(totalRows - 1, 0) / WINDOW_SIZE) * WINDOW_SIZE;
68
+ return Math.floor(Math.max(totalRows - 1, 0) / windowSize) * windowSize;
66
69
  };
67
- export const clampWindowStart = (startRow = 0, totalRows = 0) => {
68
- return Math.min(Math.max(startRow, 0), getMaxWindowStart(totalRows));
70
+ export const clampWindowStart = (startRow = 0, totalRows = 0, windowSize = WINDOW_SIZE) => {
71
+ return Math.min(Math.max(startRow, 0), getMaxWindowStart(totalRows, windowSize));
69
72
  };
70
- export const getWindowStart = (row = 0, totalRows = 0) => {
71
- const start = Math.floor(Math.max(row, 0) / WINDOW_SIZE) * WINDOW_SIZE;
72
- return clampWindowStart(start, totalRows);
73
+ export const getWindowStart = (row = 0, totalRows = 0, windowSize = WINDOW_SIZE) => {
74
+ const start = Math.floor(Math.max(row, 0) / windowSize) * windowSize;
75
+ return clampWindowStart(start, totalRows, windowSize);
73
76
  };
74
- export const collectWindowStarts = ({ startRow, endRow, direction, totalRows, far = false }) => {
77
+ export const collectWindowStarts = ({ startRow, endRow, direction, totalRows, windowSize = WINDOW_SIZE, far = false }) => {
75
78
  const starts = new Set();
76
- const firstWindow = getWindowStart(startRow, totalRows);
77
- const lastWindow = getWindowStart(endRow, totalRows);
78
- for (let current = firstWindow; current <= lastWindow; current += WINDOW_SIZE) {
79
+ const firstWindow = getWindowStart(startRow, totalRows, windowSize);
80
+ const lastWindow = getWindowStart(endRow, totalRows, windowSize);
81
+ for (let current = firstWindow; current <= lastWindow; current += windowSize) {
79
82
  starts.add(current);
80
83
  }
81
84
  const ahead = far ? PREFETCH_AHEAD + 1 : PREFETCH_AHEAD;
82
85
  const behind = far ? PREFETCH_BEHIND + 1 : PREFETCH_BEHIND;
83
86
  const anchor = direction > 0 ? lastWindow : firstWindow;
84
87
  for (let step = 1; step <= ahead; step += 1) {
85
- starts.add(clampWindowStart(anchor + direction * step * WINDOW_SIZE, totalRows));
88
+ starts.add(clampWindowStart(anchor + direction * step * windowSize, totalRows, windowSize));
86
89
  }
87
90
  for (let step = 1; step <= behind; step += 1) {
88
- starts.add(clampWindowStart(anchor - direction * step * WINDOW_SIZE, totalRows));
91
+ starts.add(clampWindowStart(anchor - direction * step * windowSize, totalRows, windowSize));
89
92
  }
90
93
  return Array.from(starts);
91
94
  };
92
- export const markWindowState = (rows, totalRows, windowStart, nextState) => {
93
- const endRow = Math.min(windowStart + WINDOW_SIZE, totalRows);
95
+ export const markWindowState = (rows, totalRows, windowStart, nextState, windowSize = WINDOW_SIZE) => {
96
+ const endRow = Math.min(windowStart + windowSize, totalRows);
94
97
  for (let rowIndex = windowStart; rowIndex < endRow; rowIndex += 1) {
95
98
  const row = rows[rowIndex];
96
99
  if (!row) {
@@ -539,7 +539,10 @@ class SheetJsModel {
539
539
  type: chart.type,
540
540
  title: chart.title,
541
541
  categoryAxisTitle: chart.categoryAxisTitle,
542
+ categoryAxisId: chart.categoryAxisId,
543
+ categoryAxisDate: chart.categoryAxisDate,
542
544
  valueAxisTitle: chart.valueAxisTitle,
545
+ valueAxes: chart.valueAxes,
543
546
  categoryAxisFontSize: chart.categoryAxisFontSize,
544
547
  valueAxisFontSize: chart.valueAxisFontSize,
545
548
  barDirection: chart.barDirection,
@@ -1,7 +1,7 @@
1
1
  import { type XmlReadBudget } from './xmlBudget.js';
2
2
  import { type Document as XmlDocument, type Element as XmlElement, type Node as XmlNode } from '@xmldom/xmldom';
3
3
  import JSZip from 'jszip';
4
- import type { WorkBook } from 'styled-exceljs';
4
+ import { type WorkBook } from 'styled-exceljs';
5
5
  import type { SheetChartDefinition } from '../type.js';
6
6
  export type Relationship = {
7
7
  id: string;