@extend-ai/react-xlsx 0.20.2 → 0.20.4
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/dist/browser-IQ4UDS5M.js +209 -0
- package/dist/browser-IQ4UDS5M.js.map +1 -0
- package/dist/browser-S6E2BS5S.cjs +212 -0
- package/dist/browser-S6E2BS5S.cjs.map +1 -0
- package/dist/{chart-renderer-F355CYSE.js → chart-renderer-4HTNG3SX.js} +94 -180
- package/dist/chart-renderer-4HTNG3SX.js.map +1 -0
- package/dist/{chart-renderer-7DTEXXG6.js → chart-renderer-5IN2B3YS.js} +94 -180
- package/dist/chart-renderer-5IN2B3YS.js.map +1 -0
- package/dist/{chart-renderer-LGW4EH4M.cjs → chart-renderer-6CWSXOSC.cjs} +324 -410
- package/dist/chart-renderer-6CWSXOSC.cjs.map +1 -0
- package/dist/{chart-renderer-3QDNTMRN.cjs → chart-renderer-H4BLRO5P.cjs} +324 -410
- package/dist/chart-renderer-H4BLRO5P.cjs.map +1 -0
- package/dist/chunk-GX5LAENE.cjs +108 -0
- package/dist/chunk-GX5LAENE.cjs.map +1 -0
- package/dist/{chunk-GXYDJPHM.js → chunk-H62SZBEY.js} +401 -132
- package/dist/chunk-H62SZBEY.js.map +1 -0
- package/dist/{chunk-3LMOGW6A.js → chunk-IISMO3AX.js} +30 -15
- package/dist/chunk-IISMO3AX.js.map +1 -0
- package/dist/{chunk-ZJ76CZAL.cjs → chunk-KQSUAIZD.cjs} +1168 -899
- package/dist/chunk-KQSUAIZD.cjs.map +1 -0
- package/dist/{chunk-IYGZTLDY.js → chunk-LZXL5E4W.js} +16 -7
- package/dist/chunk-LZXL5E4W.js.map +1 -0
- package/dist/chunk-MYN475JP.cjs +32 -0
- package/dist/chunk-MYN475JP.cjs.map +1 -0
- package/dist/{chunk-D2UA4P6N.cjs → chunk-NAYVSTCX.cjs} +22 -9
- package/dist/chunk-NAYVSTCX.cjs.map +1 -0
- package/dist/chunk-PK3MCNDK.js +32 -0
- package/dist/chunk-PK3MCNDK.js.map +1 -0
- package/dist/full-3FSPB3R6.cjs +212 -0
- package/dist/full-3FSPB3R6.cjs.map +1 -0
- package/dist/full-GPY27HZY.js +209 -0
- package/dist/full-GPY27HZY.js.map +1 -0
- package/dist/index.cjs +834 -602
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +57 -1
- package/dist/index.d.ts +57 -1
- package/dist/index.js +347 -115
- package/dist/index.js.map +1 -1
- package/dist/{internal-BJsg5os3.d.cts → internal-Cks9H21d.d.cts} +56 -1
- package/dist/{internal-BJsg5os3.d.ts → internal-Cks9H21d.d.ts} +56 -1
- package/dist/internal.cjs +3 -3
- package/dist/internal.d.cts +1 -1
- package/dist/internal.d.ts +1 -1
- package/dist/internal.js +2 -2
- package/dist/office_charts_bg.wasm +0 -0
- package/dist/office_charts_full_bg.wasm +0 -0
- package/dist/payload-B55ZKNYO.js +6 -0
- package/dist/payload-B55ZKNYO.js.map +1 -0
- package/dist/payload-E2KM77DZ.js +6 -0
- package/dist/payload-E2KM77DZ.js.map +1 -0
- package/dist/payload-K4S5RLJN.cjs +8 -0
- package/dist/payload-K4S5RLJN.cjs.map +1 -0
- package/dist/payload-PL4646XV.cjs +8 -0
- package/dist/payload-PL4646XV.cjs.map +1 -0
- package/dist/rust-office-charts-LICENSE.txt +21 -0
- package/dist/{shared-chart-3STFRVWT.js → shared-chart-5KTGZEZ5.js} +38 -20
- package/dist/shared-chart-5KTGZEZ5.js.map +1 -0
- package/dist/{shared-chart-DVC5S2P6.cjs → shared-chart-ACR4M7BP.cjs} +37 -20
- package/dist/shared-chart-ACR4M7BP.cjs.map +1 -0
- package/dist/{shared-chart-BFQNYOIQ.js → shared-chart-EGN5JTKT.js} +37 -20
- package/dist/shared-chart-EGN5JTKT.js.map +1 -0
- package/dist/{shared-chart-MFQSQG4K.cjs → shared-chart-XAV7VA45.cjs} +37 -19
- package/dist/shared-chart-XAV7VA45.cjs.map +1 -0
- package/dist/{surface-regl-R2N54JT2.js → surface-webgl-2ZZ6JQR2.js} +87 -151
- package/dist/surface-webgl-2ZZ6JQR2.js.map +1 -0
- package/dist/{surface-regl-BBJ6OIKK.cjs → surface-webgl-3HS6VBCK.cjs} +88 -152
- package/dist/surface-webgl-3HS6VBCK.cjs.map +1 -0
- package/dist/{surface-regl-7CDGGVDG.js → surface-webgl-4DQXDDXU.js} +87 -151
- package/dist/surface-webgl-4DQXDDXU.js.map +1 -0
- package/dist/{surface-regl-SUJ2TFZA.cjs → surface-webgl-SVYD564V.cjs} +88 -152
- package/dist/surface-webgl-SVYD564V.cjs.map +1 -0
- package/dist/vanilla.cjs +3 -3
- package/dist/vanilla.d.cts +2 -2
- package/dist/vanilla.d.ts +2 -2
- package/dist/vanilla.js +2 -2
- package/dist/xlsx-worker.js +298 -92
- package/dist/xlsx-worker.js.map +1 -1
- package/package.json +7 -15
- package/dist/chart-renderer-3QDNTMRN.cjs.map +0 -1
- package/dist/chart-renderer-7DTEXXG6.js.map +0 -1
- package/dist/chart-renderer-F355CYSE.js.map +0 -1
- package/dist/chart-renderer-LGW4EH4M.cjs.map +0 -1
- package/dist/chunk-3LMOGW6A.js.map +0 -1
- package/dist/chunk-D2UA4P6N.cjs.map +0 -1
- package/dist/chunk-GXYDJPHM.js.map +0 -1
- package/dist/chunk-IYGZTLDY.js.map +0 -1
- package/dist/chunk-OCF75R75.cjs +0 -90
- package/dist/chunk-OCF75R75.cjs.map +0 -1
- package/dist/chunk-ZJ76CZAL.cjs.map +0 -1
- package/dist/region-map-geography-24TXETDP.cjs +0 -184
- package/dist/region-map-geography-24TXETDP.cjs.map +0 -1
- package/dist/region-map-geography-OR6DHAF7.js +0 -182
- package/dist/region-map-geography-OR6DHAF7.js.map +0 -1
- package/dist/shared-chart-3STFRVWT.js.map +0 -1
- package/dist/shared-chart-BFQNYOIQ.js.map +0 -1
- package/dist/shared-chart-DVC5S2P6.cjs.map +0 -1
- package/dist/shared-chart-MFQSQG4K.cjs.map +0 -1
- package/dist/surface-regl-7CDGGVDG.js.map +0 -1
- package/dist/surface-regl-BBJ6OIKK.cjs.map +0 -1
- package/dist/surface-regl-R2N54JT2.js.map +0 -1
- package/dist/surface-regl-SUJ2TFZA.cjs.map +0 -1
- package/dist/world-atlas-LICENSE.txt +0 -13
- /package/dist/{us-atlas-LICENSE.txt → rust-office-charts-MAP-DATA-LICENSE.txt} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
@@ -22,8 +22,7 @@ var _chunk5ERNVHSOcjs = require('./chunk-5ERNVHSO.cjs');
|
|
|
22
22
|
var _chunkAZWBTFJIcjs = require('./chunk-AZWBTFJI.cjs');
|
|
23
23
|
require('./chunk-AD4CGQN2.cjs');
|
|
24
24
|
|
|
25
|
-
// src/surface-
|
|
26
|
-
var _regl = require('regl'); var _regl2 = _interopRequireDefault(_regl);
|
|
25
|
+
// src/surface-webgl.tsx
|
|
27
26
|
function clamp(value, min, max) {
|
|
28
27
|
return Math.max(min, Math.min(max, value));
|
|
29
28
|
}
|
|
@@ -483,6 +482,73 @@ function buildSurfaceMesh(chart, palette, layout) {
|
|
|
483
482
|
wallPositions: new Float32Array(wallPositions)
|
|
484
483
|
};
|
|
485
484
|
}
|
|
485
|
+
function paintSurface(gl, scene) {
|
|
486
|
+
const program = gl.createProgram();
|
|
487
|
+
if (!program) throw new Error("Cannot create surface program");
|
|
488
|
+
const positionBuffer = gl.createBuffer();
|
|
489
|
+
const colorBuffer = gl.createBuffer();
|
|
490
|
+
function attachShader(type, source) {
|
|
491
|
+
const shader = gl.createShader(type);
|
|
492
|
+
if (!shader) throw new Error("Cannot create surface shader");
|
|
493
|
+
gl.shaderSource(shader, source);
|
|
494
|
+
gl.compileShader(shader);
|
|
495
|
+
gl.attachShader(program, shader);
|
|
496
|
+
gl.deleteShader(shader);
|
|
497
|
+
}
|
|
498
|
+
try {
|
|
499
|
+
if (!positionBuffer || !colorBuffer) throw new Error("Cannot create surface buffers");
|
|
500
|
+
attachShader(gl.VERTEX_SHADER, `
|
|
501
|
+
precision mediump float;
|
|
502
|
+
attribute vec3 position;
|
|
503
|
+
attribute vec4 color;
|
|
504
|
+
varying vec4 vColor;
|
|
505
|
+
void main() {
|
|
506
|
+
gl_Position = vec4(position, 1.0);
|
|
507
|
+
vColor = color;
|
|
508
|
+
}`);
|
|
509
|
+
attachShader(gl.FRAGMENT_SHADER, `
|
|
510
|
+
precision mediump float;
|
|
511
|
+
varying vec4 vColor;
|
|
512
|
+
void main() {
|
|
513
|
+
gl_FragColor = vColor;
|
|
514
|
+
}`);
|
|
515
|
+
gl.linkProgram(program);
|
|
516
|
+
if (!gl.getProgramParameter(program, gl.LINK_STATUS)) throw new Error("Cannot link surface program");
|
|
517
|
+
gl.useProgram(program);
|
|
518
|
+
const position = gl.getAttribLocation(program, "position");
|
|
519
|
+
const color = gl.getAttribLocation(program, "color");
|
|
520
|
+
gl.enableVertexAttribArray(position);
|
|
521
|
+
gl.enableVertexAttribArray(color);
|
|
522
|
+
gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
|
|
523
|
+
gl.enable(gl.DEPTH_TEST);
|
|
524
|
+
gl.enable(gl.BLEND);
|
|
525
|
+
gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
|
|
526
|
+
gl.clearColor(0, 0, 0, 0);
|
|
527
|
+
gl.clearDepth(1);
|
|
528
|
+
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
|
|
529
|
+
const draw = (positions, colors, mode, depth) => {
|
|
530
|
+
if (positions.length === 0) return;
|
|
531
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer);
|
|
532
|
+
gl.bufferData(gl.ARRAY_BUFFER, positions, gl.STREAM_DRAW);
|
|
533
|
+
gl.vertexAttribPointer(position, 3, gl.FLOAT, false, 0, 0);
|
|
534
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, colorBuffer);
|
|
535
|
+
gl.bufferData(gl.ARRAY_BUFFER, colors, gl.STREAM_DRAW);
|
|
536
|
+
gl.vertexAttribPointer(color, 4, gl.FLOAT, false, 0, 0);
|
|
537
|
+
gl.depthFunc(depth);
|
|
538
|
+
gl.drawArrays(mode, 0, positions.length / 3);
|
|
539
|
+
};
|
|
540
|
+
draw(scene.wallPositions, scene.wallColors, gl.TRIANGLES, gl.LEQUAL);
|
|
541
|
+
draw(scene.fillPositions, scene.fillColors, gl.TRIANGLES, gl.LESS);
|
|
542
|
+
draw(scene.linePositions, scene.lineColors, gl.LINES, gl.LEQUAL);
|
|
543
|
+
gl.disableVertexAttribArray(position);
|
|
544
|
+
gl.disableVertexAttribArray(color);
|
|
545
|
+
} finally {
|
|
546
|
+
gl.useProgram(null);
|
|
547
|
+
gl.deleteBuffer(positionBuffer);
|
|
548
|
+
gl.deleteBuffer(colorBuffer);
|
|
549
|
+
gl.deleteProgram(program);
|
|
550
|
+
}
|
|
551
|
+
}
|
|
486
552
|
var MemoSurfaceChartComposite = _chunkAZWBTFJIcjs.N.call(void 0, function MemoSurfaceChartComposite2({
|
|
487
553
|
background,
|
|
488
554
|
borderColor,
|
|
@@ -509,165 +575,34 @@ var MemoSurfaceChartComposite = _chunkAZWBTFJIcjs.N.call(void 0, function MemoSu
|
|
|
509
575
|
if (!canvas) {
|
|
510
576
|
return;
|
|
511
577
|
}
|
|
512
|
-
let cancelled = false;
|
|
513
|
-
let reglInstance = null;
|
|
514
578
|
const drawSurface = () => {
|
|
515
579
|
try {
|
|
516
580
|
const scene = buildSurfaceMesh(chart, palette, layout);
|
|
517
|
-
if (!scene)
|
|
518
|
-
if (!cancelled) {
|
|
519
|
-
setFailed(true);
|
|
520
|
-
setReady(false);
|
|
521
|
-
}
|
|
522
|
-
return;
|
|
523
|
-
}
|
|
581
|
+
if (!scene) throw new Error("Empty surface");
|
|
524
582
|
const dpr = window.devicePixelRatio || 1;
|
|
525
583
|
canvas.width = Math.max(1, Math.round(layout.width * dpr));
|
|
526
584
|
canvas.height = Math.max(1, Math.round(layout.height * dpr));
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
premultipliedAlpha: true
|
|
533
|
-
},
|
|
534
|
-
canvas
|
|
535
|
-
});
|
|
536
|
-
const fillCommand = scene.fillPositions.length > 0 ? reglInstance({
|
|
537
|
-
attributes: {
|
|
538
|
-
color: scene.fillColors,
|
|
539
|
-
position: scene.fillPositions
|
|
540
|
-
},
|
|
541
|
-
blend: {
|
|
542
|
-
enable: true,
|
|
543
|
-
func: {
|
|
544
|
-
dstRGB: "one minus src alpha",
|
|
545
|
-
dstAlpha: "one minus src alpha",
|
|
546
|
-
srcRGB: "src alpha",
|
|
547
|
-
srcAlpha: "src alpha"
|
|
548
|
-
}
|
|
549
|
-
},
|
|
550
|
-
count: scene.fillPositions.length / 3,
|
|
551
|
-
depth: {
|
|
552
|
-
enable: true
|
|
553
|
-
},
|
|
554
|
-
frag: `
|
|
555
|
-
precision mediump float;
|
|
556
|
-
varying vec4 vColor;
|
|
557
|
-
void main() {
|
|
558
|
-
gl_FragColor = vColor;
|
|
559
|
-
}
|
|
560
|
-
`,
|
|
561
|
-
primitive: "triangles",
|
|
562
|
-
vert: `
|
|
563
|
-
precision mediump float;
|
|
564
|
-
attribute vec3 position;
|
|
565
|
-
attribute vec4 color;
|
|
566
|
-
varying vec4 vColor;
|
|
567
|
-
void main() {
|
|
568
|
-
gl_Position = vec4(position, 1.0);
|
|
569
|
-
vColor = color;
|
|
570
|
-
}
|
|
571
|
-
`
|
|
572
|
-
}) : null;
|
|
573
|
-
const wallCommand = scene.wallPositions.length > 0 ? reglInstance({
|
|
574
|
-
attributes: {
|
|
575
|
-
color: scene.wallColors,
|
|
576
|
-
position: scene.wallPositions
|
|
577
|
-
},
|
|
578
|
-
blend: {
|
|
579
|
-
enable: true,
|
|
580
|
-
func: {
|
|
581
|
-
dstRGB: "one minus src alpha",
|
|
582
|
-
dstAlpha: "one minus src alpha",
|
|
583
|
-
srcRGB: "src alpha",
|
|
584
|
-
srcAlpha: "src alpha"
|
|
585
|
-
}
|
|
586
|
-
},
|
|
587
|
-
count: scene.wallPositions.length / 3,
|
|
588
|
-
depth: {
|
|
589
|
-
enable: true,
|
|
590
|
-
func: "lequal"
|
|
591
|
-
},
|
|
592
|
-
frag: `
|
|
593
|
-
precision mediump float;
|
|
594
|
-
varying vec4 vColor;
|
|
595
|
-
void main() {
|
|
596
|
-
gl_FragColor = vColor;
|
|
597
|
-
}
|
|
598
|
-
`,
|
|
599
|
-
primitive: "triangles",
|
|
600
|
-
vert: `
|
|
601
|
-
precision mediump float;
|
|
602
|
-
attribute vec3 position;
|
|
603
|
-
attribute vec4 color;
|
|
604
|
-
varying vec4 vColor;
|
|
605
|
-
void main() {
|
|
606
|
-
gl_Position = vec4(position, 1.0);
|
|
607
|
-
vColor = color;
|
|
608
|
-
}
|
|
609
|
-
`
|
|
610
|
-
}) : null;
|
|
611
|
-
const lineCommand = scene.linePositions.length > 0 ? reglInstance({
|
|
612
|
-
attributes: {
|
|
613
|
-
color: scene.lineColors,
|
|
614
|
-
position: scene.linePositions
|
|
615
|
-
},
|
|
616
|
-
blend: {
|
|
617
|
-
enable: true,
|
|
618
|
-
func: {
|
|
619
|
-
dstRGB: "one minus src alpha",
|
|
620
|
-
dstAlpha: "one minus src alpha",
|
|
621
|
-
srcRGB: "src alpha",
|
|
622
|
-
srcAlpha: "src alpha"
|
|
623
|
-
}
|
|
624
|
-
},
|
|
625
|
-
count: scene.linePositions.length / 3,
|
|
626
|
-
depth: {
|
|
627
|
-
enable: true,
|
|
628
|
-
func: "lequal"
|
|
629
|
-
},
|
|
630
|
-
frag: `
|
|
631
|
-
precision mediump float;
|
|
632
|
-
varying vec4 vColor;
|
|
633
|
-
void main() {
|
|
634
|
-
gl_FragColor = vColor;
|
|
635
|
-
}
|
|
636
|
-
`,
|
|
637
|
-
lineWidth: 1,
|
|
638
|
-
primitive: "lines",
|
|
639
|
-
vert: `
|
|
640
|
-
precision mediump float;
|
|
641
|
-
attribute vec3 position;
|
|
642
|
-
attribute vec4 color;
|
|
643
|
-
varying vec4 vColor;
|
|
644
|
-
void main() {
|
|
645
|
-
gl_Position = vec4(position, 1.0);
|
|
646
|
-
vColor = color;
|
|
647
|
-
}
|
|
648
|
-
`
|
|
649
|
-
}) : null;
|
|
650
|
-
reglInstance.clear({ color: [0, 0, 0, 0], depth: 1 });
|
|
651
|
-
_optionalChain([wallCommand, 'optionalCall', _113 => _113()]);
|
|
652
|
-
_optionalChain([fillCommand, 'optionalCall', _114 => _114()]);
|
|
653
|
-
_optionalChain([lineCommand, 'optionalCall', _115 => _115()]);
|
|
654
|
-
if (!cancelled) {
|
|
655
|
-
setReady(true);
|
|
656
|
-
setFailed(false);
|
|
657
|
-
}
|
|
585
|
+
const gl = canvas.getContext("webgl", { alpha: true, antialias: true, depth: true, premultipliedAlpha: true });
|
|
586
|
+
if (!gl || gl.isContextLost()) throw new Error("WebGL unavailable");
|
|
587
|
+
paintSurface(gl, scene);
|
|
588
|
+
setReady(true);
|
|
589
|
+
setFailed(false);
|
|
658
590
|
} catch (e) {
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
setFailed(true);
|
|
662
|
-
}
|
|
591
|
+
setReady(false);
|
|
592
|
+
setFailed(true);
|
|
663
593
|
}
|
|
664
594
|
};
|
|
665
|
-
|
|
666
|
-
|
|
595
|
+
const onLost = (event) => {
|
|
596
|
+
event.preventDefault();
|
|
597
|
+
setReady(false);
|
|
598
|
+
setFailed(true);
|
|
599
|
+
};
|
|
600
|
+
canvas.addEventListener("webglcontextlost", onLost);
|
|
601
|
+
canvas.addEventListener("webglcontextrestored", drawSurface);
|
|
667
602
|
drawSurface();
|
|
668
603
|
return () => {
|
|
669
|
-
|
|
670
|
-
|
|
604
|
+
canvas.removeEventListener("webglcontextlost", onLost);
|
|
605
|
+
canvas.removeEventListener("webglcontextrestored", drawSurface);
|
|
671
606
|
};
|
|
672
607
|
}, [
|
|
673
608
|
chart,
|
|
@@ -680,6 +615,7 @@ var MemoSurfaceChartComposite = _chunkAZWBTFJIcjs.N.call(void 0, function MemoSu
|
|
|
680
615
|
"div",
|
|
681
616
|
{
|
|
682
617
|
"aria-label": _nullishCoalesce(_nullishCoalesce(chart.title, () => ( chart.name)), () => ( "Chart")),
|
|
618
|
+
"data-xlsx-chart-renderer": "legacy",
|
|
683
619
|
role: "img",
|
|
684
620
|
style: {
|
|
685
621
|
background,
|
|
@@ -726,4 +662,4 @@ var MemoSurfaceChartComposite = _chunkAZWBTFJIcjs.N.call(void 0, function MemoSu
|
|
|
726
662
|
|
|
727
663
|
|
|
728
664
|
exports.MemoSurfaceChartComposite = MemoSurfaceChartComposite;
|
|
729
|
-
//# sourceMappingURL=surface-
|
|
665
|
+
//# sourceMappingURL=surface-webgl-3HS6VBCK.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/react-xlsx/react-xlsx/packages/react-xlsx/dist/surface-webgl-3HS6VBCK.cjs","../src/surface-webgl.tsx"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;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AAA,UAAA;AACM,YAAA;AACE,YAAA;AACoC,cAAA;AACjC,cAAA;AACD,cAAA;AACG,cAAA;AACH,cAAA;AACT,YAAA;AAAA,UAAA;AACF,QAAA;AACA,wBAAA;AAAC,UAAA;AAAA,UAAA;AACC,YAAA;AACA,YAAA;AACqD,YAAA;AACR,YAAA;AAE5C,YAAA;AAAkC,cAAA;AAClC,cAAA;AAAA,YAAA;AAAA,UAAA;AACH,QAAA;AAAA,MAAA;AAAA,IAAA;AACF,EAAA;AAIuB;ADnI+C;AACA;AACA","file":"/home/runner/work/react-xlsx/react-xlsx/packages/react-xlsx/dist/surface-webgl-3HS6VBCK.cjs","sourcesContent":[null,"import { getBuiltinChartColor, getBuiltinChartSurfaceLine, resolveBuiltinChartColor } from \"./builtin-chart-styles\";\nimport * as React from \"react\";\nimport { shadeSurfaceMatteColor, surfaceNormal, transformSurfaceNormal } from \"./surface-lighting\";\nimport { clipSurfaceBand, groupSurfaceBandEdges, normalizeSurfaceValue, surfaceDataRatios, triangulateSurfaceQuad } from \"./surface-geometry\";\nimport type { XlsxChart } from \"./types\";\n\ntype SurfacePalette = {\n border: string;\n mutedText: string;\n surface: string;\n text: string;\n};\n\ntype SurfaceLayout = {\n height: number;\n plot: {\n height: number;\n left: number;\n top: number;\n width: number;\n };\n width: number;\n};\n\ntype SurfaceCompositeProps = {\n background: string;\n borderColor: string;\n chart: XlsxChart;\n fontFamily: string;\n layout: SurfaceLayout;\n onDoubleClick?: React.MouseEventHandler<SVGSVGElement>;\n onPointerDown?: React.PointerEventHandler<SVGSVGElement>;\n overlay: React.ReactNode;\n palette: SurfacePalette;\n fallback: React.ReactNode;\n};\n\ntype SurfaceDomain = {\n maxValue: number;\n minValue: number;\n safeMax: number;\n ticks: number[];\n};\n\ntype SurfacePoint3D = {\n depth: number;\n worldX: number;\n worldY: number;\n worldZ: number;\n x: number;\n y: number;\n};\n\ntype SurfaceVertex = {\n bandColor: string;\n point: SurfacePoint3D;\n value: number;\n};\n\ntype SolidSurfaceTriangle = {\n color: string;\n points: [SurfacePoint3D, SurfacePoint3D, SurfacePoint3D];\n};\n\ntype SurfaceScene = {\n fillColors: Float32Array;\n fillPositions: Float32Array;\n lineColors: Float32Array;\n linePositions: Float32Array;\n wallColors: Float32Array;\n wallPositions: Float32Array;\n};\n\nfunction clamp(value: number, min: number, max: number) {\n return Math.max(min, Math.min(max, value));\n}\n\nfunction safeNumber(value: unknown) {\n if (typeof value === \"number\" && Number.isFinite(value)) {\n return value;\n }\n if (typeof value === \"string\") {\n const normalized = value.trim().replace(/,/g, \"\");\n if (!normalized) {\n return null;\n }\n const parsed = Number(normalized);\n return Number.isFinite(parsed) ? parsed : null;\n }\n return null;\n}\n\nfunction parseRgbColor(color: string) {\n const match = /^#?([0-9a-f]{6})$/i.exec(color);\n if (!match) {\n return null;\n }\n return {\n blue: Number.parseInt(match[1].slice(4, 6), 16),\n green: Number.parseInt(match[1].slice(2, 4), 16),\n red: Number.parseInt(match[1].slice(0, 2), 16)\n };\n}\n\nfunction mixRgbColor(color: string, mixWith: string, ratio: number) {\n const base = parseRgbColor(color);\n const target = parseRgbColor(mixWith);\n if (!base || !target) {\n return color;\n }\n const clamped = clamp(ratio, 0, 1);\n const mixChannel = (left: number, right: number) => Math.round(left + (right - left) * clamped);\n return `#${[\n mixChannel(base.red, target.red),\n mixChannel(base.green, target.green),\n mixChannel(base.blue, target.blue)\n ].map((value) => value.toString(16).padStart(2, \"0\")).join(\"\")}`;\n}\n\nfunction lightenColor(color: string, ratio: number) {\n return mixRgbColor(color, \"#ffffff\", ratio);\n}\n\nfunction darkenColor(color: string, ratio: number) {\n return mixRgbColor(color, \"#000000\", ratio);\n}\n\nfunction resolveSurfaceBaseColor(chart: XlsxChart, palette: Pick<SurfacePalette, \"text\">) {\n return chart.chartColorPalette?.[0]\n ?? chart.series[0]?.color\n ?? chart.series[0]?.lineColor\n ?? chart.axisLineColor\n ?? chart.textColor\n ?? palette.text;\n}\n\nfunction normalizeSurfaceRendererHexColor(value: unknown) {\n if (typeof value !== \"string\") {\n return null;\n }\n const trimmed = value.trim();\n if (!trimmed) {\n return null;\n }\n const normalized = trimmed.startsWith(\"#\") ? trimmed.slice(1) : trimmed;\n return /^[0-9a-f]{6}$/i.test(normalized) ? `#${normalized.toLowerCase()}` : null;\n}\n\nfunction resolveExplicitSurfaceSeriesColor(chart: XlsxChart, kind: \"fill\" | \"line\") {\n const shape = chart.series[0]?.shapeProperties;\n if (kind === \"fill\" ? shape?.xmlFillHidden === true : shape?.xmlLineHidden === true) return \"transparent\";\n const color = kind === \"fill\"\n ? shape?.xmlFillColor ?? shape?.solidFillHex\n : shape?.xmlLineColor ?? shape?.lineColorHex;\n return normalizeSurfaceRendererHexColor(color);\n}\n\nfunction getSurfaceColorStops(chart: XlsxChart, palette: SurfacePalette) {\n const explicitFill = resolveExplicitSurfaceSeriesColor(chart, \"fill\");\n if (explicitFill) return [explicitFill];\n const colors = (chart.chartColorPalette ?? []).filter((value): value is string => typeof value === \"string\" && value.length > 0);\n return colors.length > 0 ? colors : [resolveSurfaceBaseColor(chart, palette)];\n}\n\nfunction getSurfaceDomain(chart: XlsxChart): SurfaceDomain | null {\n const numericValues = chart.series.flatMap((series) => (\n series.values\n .map((value) => safeNumber(value))\n .filter((value): value is number => value != null)\n ));\n if (numericValues.length === 0) {\n return null;\n }\n const explicitMin = typeof chart.valueAxis?.min === \"number\" && Number.isFinite(chart.valueAxis.min)\n ? chart.valueAxis.min\n : null;\n const explicitMax = typeof chart.valueAxis?.max === \"number\" && Number.isFinite(chart.valueAxis.max)\n ? chart.valueAxis.max\n : null;\n const rawMin = Math.min(...numericValues);\n const rawMax = Math.max(...numericValues);\n const spanBase = Math.max(1e-6, rawMax - Math.min(0, rawMin));\n const roughStep = spanBase / 5;\n const magnitude = Math.pow(10, Math.floor(Math.log10(Math.max(roughStep, 1e-6))));\n const normalized = roughStep / magnitude;\n const niceStep = normalized <= 1 ? 1 : normalized <= 2 ? 2 : normalized <= 5 ? 5 : 10;\n const step = typeof chart.valueAxis?.majorUnit === \"number\" && chart.valueAxis.majorUnit > 0\n ? chart.valueAxis.majorUnit\n : niceStep * magnitude;\n const minValue = explicitMin ?? (rawMin >= 0 ? 0 : Math.floor(rawMin / step) * step);\n const maxValue = explicitMax ?? Math.ceil(rawMax / step) * step;\n const safeMax = maxValue <= minValue ? minValue + step : maxValue;\n const ticks: number[] = [];\n for (let current = minValue; current <= safeMax + step * 0.001; current += step) {\n ticks.push(Number(current.toFixed(8)));\n }\n const boundedTicks = [...new Set([...ticks.filter((tick) => tick < safeMax), safeMax])];\n return {\n maxValue,\n minValue,\n safeMax,\n ticks: boundedTicks.length >= 2 ? boundedTicks : [minValue, safeMax]\n };\n}\n\nfunction resolveSurfaceBandPaletteColor(chart: XlsxChart, palette: SurfacePalette, domain: SurfaceDomain, value: number) {\n const bandIndex = resolveSurfaceBandIndex(domain, value);\n const explicitColor = resolveSurfaceBandFormatColor(chart, \"bandFormatColors\", bandIndex);\n if (explicitColor) return explicitColor;\n const explicitFill = resolveExplicitSurfaceSeriesColor(chart, \"fill\");\n if (explicitFill) return explicitFill;\n const themeColors = chart.raw?.builtinThemeColors as Record<number, string> | undefined;\n const paletteCount = Math.trunc((domain.safeMax - domain.minValue) / (domain.ticks[1] - domain.ticks[0])) + 1;\n const builtinColor = themeColors ? resolveBuiltinChartColor(getBuiltinChartColor(chart.chartStyleId, bandIndex % paletteCount, paletteCount), themeColors) : undefined;\n if (builtinColor) return builtinColor;\n const stops = getSurfaceColorStops(chart, palette);\n if (stops.length === 0) {\n return resolveSurfaceBaseColor(chart, palette);\n }\n return stops[Math.min(stops.length - 1, Math.max(0, bandIndex))] ?? stops[stops.length - 1] ?? resolveSurfaceBaseColor(chart, palette);\n}\n\nfunction resolveSurfaceBandIndex(domain: SurfaceDomain, value: number) {\n const ticks = domain.ticks;\n for (let index = 0; index < ticks.length - 1; index += 1) {\n const end = ticks[index + 1] ?? domain.safeMax;\n if (value <= end || index === ticks.length - 2) {\n return index;\n }\n }\n return Math.max(0, ticks.length - 2);\n}\n\nfunction resolveSurfaceBandColor(chart: XlsxChart, palette: SurfacePalette, domain: SurfaceDomain, value: number) {\n return resolveSurfaceBandPaletteColor(chart, palette, domain, value);\n}\n\nfunction resolveSurfaceBandFormatColor(chart: XlsxChart, key: \"bandFormatColors\" | \"bandFormatLineColors\", index: number) {\n const colors = chart.raw?.[key];\n if (!colors || typeof colors !== \"object\" || !Object.prototype.hasOwnProperty.call(colors, index)) return null;\n const color = (colors as Record<number, unknown>)[index];\n return typeof color === \"string\" && color.length > 0 ? color : null;\n}\n\nfunction resolveSurfaceWireframeColor(chart: XlsxChart, palette: SurfacePalette, domain: SurfaceDomain, value: number) {\n const bandIndex = resolveSurfaceBandIndex(domain, value);\n const themeColors = chart.raw?.builtinThemeColors as Record<number, string> | undefined;\n const paletteCount = Math.trunc((domain.safeMax - domain.minValue) / (domain.ticks[1] - domain.ticks[0])) + 1;\n const builtinLine = themeColors ? resolveBuiltinChartColor(getBuiltinChartSurfaceLine(chart.chartStyleId, bandIndex, paletteCount), themeColors) : undefined;\n return resolveSurfaceBandFormatColor(chart, \"bandFormatLineColors\", bandIndex)\n ?? resolveExplicitSurfaceSeriesColor(chart, \"line\")\n ?? builtinLine\n ?? resolveSurfaceBandPaletteColor(chart, palette, domain, value);\n}\n\nfunction colorToRgba(color: string, alpha = 1) {\n if (color === \"transparent\") return [0, 0, 0, 0] as const;\n const rgb = parseRgbColor(color);\n if (!rgb) {\n return [0.1, 0.1, 0.1, alpha] as const;\n }\n return [rgb.red / 255, rgb.green / 255, rgb.blue / 255, alpha] as const;\n}\n\nfunction normalizeSurfaceX(column: number, cols: number) {\n return cols <= 1 ? 0 : ((column / (cols - 1)) - 0.5) * 2;\n}\n\nfunction normalizeSurfaceY(row: number, rows: number) {\n return rows <= 1 ? 0 : ((row / (rows - 1)) - 0.5) * 2;\n}\n\nfunction normalizeSurfaceZ(value: number, domain: SurfaceDomain, heightExtent: number, axis?: XlsxChart[\"valueAxis\"]) {\n return -(normalizeSurfaceValue(value, domain.minValue, domain.safeMax, axis) - 0.5) * heightExtent;\n}\n\nfunction projectCartesian3dPoint(\n x: number,\n y: number,\n z: number,\n rotXRad: number,\n rotYRad: number,\n usePerspective: boolean,\n perspectiveStrength: number,\n rightAngleAxes: boolean\n) {\n if (rightAngleAxes) {\n return { depth: z, x: x + z * Math.sin(rotYRad), y: y - z * Math.sin(rotXRad) };\n }\n const cosX = Math.cos(rotXRad);\n const sinX = Math.sin(rotXRad);\n const cosY = Math.cos(rotYRad);\n const sinY = Math.sin(rotYRad);\n const x1 = x * cosY + z * sinY;\n const z1 = -x * sinY + z * cosY;\n const y1 = y * cosX - z1 * sinX;\n const z2 = y * sinX + z1 * cosX;\n const perspective = usePerspective\n ? 1 / Math.max(0.18, 1 + z2 * (0.24 + perspectiveStrength * 0.5))\n : 1;\n return {\n depth: z2,\n x: x1 * perspective,\n y: y1 * perspective\n };\n}\n\nfunction withProjectedDepth(point: SurfacePoint3D, depth: number): SurfacePoint3D {\n return {\n ...point,\n depth\n };\n}\n\nfunction nudgeProjectedDepth(point: SurfacePoint3D, delta: number): SurfacePoint3D {\n return {\n ...point,\n depth: point.depth + delta\n };\n}\n\nfunction isContourSurfaceChart(chart: XlsxChart) {\n const rawChartType = chart.raw && typeof chart.raw === \"object\" && typeof chart.raw.xmlChartType === \"string\"\n ? chart.raw.xmlChartType\n : \"\";\n if (rawChartType === \"surfaceChart\") {\n return true;\n }\n if (rawChartType === \"surface3DChart\") {\n return false;\n }\n return chart.chartType === \"Surface\" && chart.is3d !== true;\n}\n\nfunction buildSurfaceMesh(chart: XlsxChart, palette: SurfacePalette, layout: SurfaceLayout): SurfaceScene | null {\n const rows = chart.series.length;\n const cols = chart.series.reduce((max, series) => Math.max(max, series.values.length), 0);\n if (rows < 2 || cols < 2) {\n return null;\n }\n const matrix = chart.series.map((series) => (\n Array.from({ length: cols }, (_, columnIndex) => safeNumber(series.values[columnIndex]))\n ));\n const domain = getSurfaceDomain(chart);\n if (!domain) {\n return null;\n }\n const isContour = isContourSurfaceChart(chart);\n const isWireframe = chart.wireframe === true;\n const fillVertices: SurfaceVertex[] = [];\n const wallTriangles: SolidSurfaceTriangle[] = [];\n const contourLines: Array<{ color: string; from: SurfacePoint3D; to: SurfacePoint3D }> = [];\n const meshLines: Array<{ color: string; from: SurfacePoint3D; to: SurfacePoint3D }> = [];\n const rotX = (chart.view3d?.rotX ?? 25) * (Math.PI / 180);\n const rotY = (chart.view3d?.rotY ?? 30) * (Math.PI / 180);\n const usePerspective = !isContour && chart.view3d?.rAngAx === false;\n const perspectiveStrength = clamp((chart.view3d?.perspective ?? (usePerspective ? 30 : 0)) / 100, 0, 1);\n const ratios = surfaceDataRatios(rows, cols, chart.valueAxis?.crossBetween !== \"midCat\", chart.view3d?.heightPercent, chart.view3d?.depthPercent, layout);\n const depthScale = ratios.depth;\n const heightExtent = 2 * ratios.height;\n const usesFlatMaterial = chart.surfaceMaterial === \"flat\";\n const wallLineColor = chart.valueAxis?.majorGridlineColor ?? chart.backWall?.lineColor ?? chart.sideWall?.lineColor ?? chart.floor?.lineColor ?? chart.axisLineColor ?? \"#a6a6a6\";\n const backWallFill = chart.backWall?.fillColor ?? \"#d9d9df\";\n const sideWallFill = chart.sideWall?.fillColor ?? \"#d5d7dc\";\n const floorFill = chart.floor?.fillColor ?? \"#d0d2d8\";\n const projectPoint = (column: number, row: number, value: number): SurfacePoint3D => {\n const worldX = normalizeSurfaceX(column, cols);\n if (isContour) {\n return {\n depth: 0,\n worldX,\n worldY: normalizeSurfaceY(row, rows),\n worldZ: 0,\n x: worldX,\n y: normalizeSurfaceY(row, rows)\n };\n }\n const worldY = normalizeSurfaceZ(value, domain, heightExtent, chart.valueAxis);\n const worldZ = normalizeSurfaceY(row, rows) * depthScale;\n const projected = projectCartesian3dPoint(worldX, worldY, worldZ, rotX, rotY, usePerspective, perspectiveStrength, chart.view3d?.rAngAx !== false);\n return {\n depth: projected.depth,\n worldX,\n worldY,\n worldZ,\n x: projected.x,\n y: projected.y\n };\n };\n const addWallQuad = (a: SurfacePoint3D, b: SurfacePoint3D, c: SurfacePoint3D, d: SurfacePoint3D, color: string) => {\n wallTriangles.push(\n { color, points: [a, b, c] },\n { color, points: [a, c, d] }\n );\n };\n const addMeshLine = (from: SurfacePoint3D, to: SurfacePoint3D, color: string) => {\n meshLines.push({ color, from, to });\n };\n\n for (let rowIndex = 0; rowIndex < rows - 1; rowIndex += 1) {\n for (let columnIndex = 0; columnIndex < cols - 1; columnIndex += 1) {\n const p00 = matrix[rowIndex]?.[columnIndex];\n const p10 = matrix[rowIndex]?.[columnIndex + 1];\n const p01 = matrix[rowIndex + 1]?.[columnIndex];\n const p11 = matrix[rowIndex + 1]?.[columnIndex + 1];\n if (p00 == null || p10 == null || p01 == null || p11 == null) {\n continue;\n }\n const triangles = triangulateSurfaceQuad([\n { value: p00, x: columnIndex, y: rowIndex },\n { value: p10, x: columnIndex + 1, y: rowIndex },\n { value: p11, x: columnIndex + 1, y: rowIndex + 1 },\n { value: p01, x: columnIndex, y: rowIndex + 1 }\n ], chart.valueAxis);\n for (const triangle of triangles) {\n for (let band = 0; band < domain.ticks.length - 1; band += 1) {\n const lower = domain.ticks[band];\n const upper = domain.ticks[band + 1];\n const polygon = clipSurfaceBand(clipSurfaceBand(triangle, lower, true, chart.valueAxis, band === 0), upper, false, chart.valueAxis);\n if (polygon.length < 3) continue;\n const bandColor = resolveSurfaceBandColor(chart, palette, domain, (lower + upper) / 2);\n if (!isWireframe && bandColor !== \"transparent\") {\n for (let index = 1; index < polygon.length - 1; index += 1) {\n for (const vertex of [polygon[0], polygon[index], polygon[index + 1]]) {\n const point = projectPoint(vertex.x, vertex.y, vertex.value);\n fillVertices.push({ bandColor, point: isContour ? withProjectedDepth(point, 0.08) : point, value: vertex.value });\n }\n }\n }\n for (const group of groupSurfaceBandEdges(polygon, triangle, band, lower, isWireframe)) {\n const edgeMidpoint = (domain.ticks[group.band] + domain.ticks[group.band + 1]) / 2;\n const color = resolveSurfaceWireframeColor(chart, palette, domain, edgeMidpoint);\n if (color !== \"transparent\") {\n for (const [from, to] of group.edges) {\n contourLines.push({ color, from: projectPoint(from.x, from.y, from.value), to: projectPoint(to.x, to.y, to.value) });\n }\n }\n }\n }\n }\n }\n }\n\n const columnSkip = Math.max(1, chart.categoryAxis?.tickMarkSkip ?? 1);\n const rowSkip = Math.max(1, chart.seriesAxis?.tickMarkSkip ?? 1);\n if (isContour) {\n const topLeft = withProjectedDepth(projectPoint(0, 0, domain.minValue), -0.12);\n const topRight = withProjectedDepth(projectPoint(cols - 1, 0, domain.minValue), -0.12);\n const bottomRight = withProjectedDepth(projectPoint(cols - 1, rows - 1, domain.minValue), -0.12);\n const bottomLeft = withProjectedDepth(projectPoint(0, rows - 1, domain.minValue), -0.12);\n if (chart.backWall?.hidden !== true && backWallFill !== \"transparent\") {\n addWallQuad(topLeft, topRight, bottomRight, bottomLeft, backWallFill);\n }\n for (let columnIndex = 0; columnIndex < cols; columnIndex += columnSkip) {\n addMeshLine(\n withProjectedDepth(projectPoint(columnIndex, 0, domain.minValue), 0.04),\n withProjectedDepth(projectPoint(columnIndex, rows - 1, domain.minValue), 0.04),\n wallLineColor\n );\n }\n for (let rowIndex = 0; rowIndex < rows; rowIndex += rowSkip) {\n addMeshLine(\n withProjectedDepth(projectPoint(0, rowIndex, domain.minValue), 0.04),\n withProjectedDepth(projectPoint(cols - 1, rowIndex, domain.minValue), 0.04),\n wallLineColor\n );\n }\n } else {\n const minPlaneValue = domain.minValue;\n const wallDepthOffset = 0;\n const backRow = chart.view3d?.rAngAx !== false || Math.cos(rotX) * Math.cos(rotY) >= 0 ? rows - 1 : 0;\n const sideColumn = Math.sin(rotY) >= 0 ? 0 : cols - 1;\n if (chart.floor?.hidden !== true && floorFill !== \"transparent\") {\n addWallQuad(\n nudgeProjectedDepth(projectPoint(0, 0, minPlaneValue), wallDepthOffset),\n nudgeProjectedDepth(projectPoint(cols - 1, 0, minPlaneValue), wallDepthOffset),\n nudgeProjectedDepth(projectPoint(cols - 1, rows - 1, minPlaneValue), wallDepthOffset),\n nudgeProjectedDepth(projectPoint(0, rows - 1, minPlaneValue), wallDepthOffset),\n floorFill\n );\n }\n if (chart.backWall?.hidden !== true && backWallFill !== \"transparent\") {\n addWallQuad(\n nudgeProjectedDepth(projectPoint(0, backRow, domain.safeMax), wallDepthOffset),\n nudgeProjectedDepth(projectPoint(cols - 1, backRow, domain.safeMax), wallDepthOffset),\n nudgeProjectedDepth(projectPoint(cols - 1, backRow, minPlaneValue), wallDepthOffset),\n nudgeProjectedDepth(projectPoint(0, backRow, minPlaneValue), wallDepthOffset),\n backWallFill\n );\n }\n if (chart.sideWall?.hidden !== true && sideWallFill !== \"transparent\") {\n addWallQuad(\n nudgeProjectedDepth(projectPoint(sideColumn, 0, domain.safeMax), wallDepthOffset),\n nudgeProjectedDepth(projectPoint(sideColumn, rows - 1, domain.safeMax), wallDepthOffset),\n nudgeProjectedDepth(projectPoint(sideColumn, rows - 1, minPlaneValue), wallDepthOffset),\n nudgeProjectedDepth(projectPoint(sideColumn, 0, minPlaneValue), wallDepthOffset),\n sideWallFill\n );\n }\n for (const tick of chart.valueAxis?.majorGridlines ? domain.ticks : []) {\n if (chart.backWall?.hidden !== true && wallLineColor !== \"transparent\") {\n addMeshLine(nudgeProjectedDepth(projectPoint(0, backRow, tick), wallDepthOffset * 0.75), nudgeProjectedDepth(projectPoint(cols - 1, backRow, tick), wallDepthOffset * 0.75), wallLineColor);\n }\n if (chart.sideWall?.hidden !== true && wallLineColor !== \"transparent\") {\n addMeshLine(nudgeProjectedDepth(projectPoint(sideColumn, 0, tick), wallDepthOffset * 0.75), nudgeProjectedDepth(projectPoint(sideColumn, rows - 1, tick), wallDepthOffset * 0.75), wallLineColor);\n }\n }\n for (let columnIndex = 0; chart.categoryAxis?.majorGridlines && columnIndex < cols; columnIndex += columnSkip) {\n if (chart.floor?.hidden !== true && wallLineColor !== \"transparent\") {\n addMeshLine(nudgeProjectedDepth(projectPoint(columnIndex, 0, minPlaneValue), wallDepthOffset * 0.75), nudgeProjectedDepth(projectPoint(columnIndex, rows - 1, minPlaneValue), wallDepthOffset * 0.75), wallLineColor);\n }\n if (chart.backWall?.hidden !== true && wallLineColor !== \"transparent\") {\n addMeshLine(nudgeProjectedDepth(projectPoint(columnIndex, backRow, minPlaneValue), wallDepthOffset * 0.75), nudgeProjectedDepth(projectPoint(columnIndex, backRow, domain.safeMax), wallDepthOffset * 0.75), wallLineColor);\n }\n }\n for (let rowIndex = 0; chart.seriesAxis?.majorGridlines && rowIndex < rows; rowIndex += rowSkip) {\n if (chart.floor?.hidden !== true && wallLineColor !== \"transparent\") {\n addMeshLine(nudgeProjectedDepth(projectPoint(0, rowIndex, minPlaneValue), wallDepthOffset * 0.75), nudgeProjectedDepth(projectPoint(cols - 1, rowIndex, minPlaneValue), wallDepthOffset * 0.75), wallLineColor);\n }\n if (chart.sideWall?.hidden !== true && wallLineColor !== \"transparent\") {\n addMeshLine(nudgeProjectedDepth(projectPoint(sideColumn, rowIndex, minPlaneValue), wallDepthOffset * 0.75), nudgeProjectedDepth(projectPoint(sideColumn, rowIndex, domain.safeMax), wallDepthOffset * 0.75), wallLineColor);\n }\n }\n }\n\n const allPoints = [\n ...fillVertices.map((vertex) => vertex.point),\n ...wallTriangles.flatMap((triangle) => triangle.points),\n ...meshLines.flatMap((line) => [line.from, line.to]),\n ...contourLines.flatMap((line) => [line.from, line.to])\n ];\n if (allPoints.length === 0) {\n return null;\n }\n\n const minX = Math.min(...allPoints.map((point) => point.x));\n const maxX = Math.max(...allPoints.map((point) => point.x));\n const minY = Math.min(...allPoints.map((point) => point.y));\n const maxY = Math.max(...allPoints.map((point) => point.y));\n const minDepth = Math.min(...allPoints.map((point) => point.depth));\n const maxDepth = Math.max(...allPoints.map((point) => point.depth));\n const scale = Math.min(\n layout.plot.width / Math.max(0.25, maxX - minX),\n layout.plot.height / Math.max(0.25, maxY - minY)\n );\n const centerX = layout.plot.left + layout.plot.width / 2;\n const centerY = layout.plot.top + layout.plot.height / 2;\n const centerRawX = (minX + maxX) / 2;\n const centerRawY = (minY + maxY) / 2;\n const toScreenX = (x: number) => centerX + (x - centerRawX) * scale;\n const toScreenY = (y: number) => centerY + (y - centerRawY) * scale;\n const toClipPoint = (point: SurfacePoint3D) => {\n const screenX = toScreenX(point.x);\n const screenY = toScreenY(point.y);\n return {\n x: (screenX / layout.width) * 2 - 1,\n y: 1 - (screenY / layout.height) * 2,\n z: clamp(((point.depth - minDepth) / Math.max(1e-6, maxDepth - minDepth)) * 2 - 1, -1, 1)\n };\n };\n\n const fillPositions: number[] = [];\n const fillColors: number[] = [];\n const wallPositions: number[] = [];\n const wallColors: number[] = [];\n for (const triangle of wallTriangles) {\n const world = triangle.points.map(point => ({ x: point.worldX, y: point.worldY, z: -point.worldZ }));\n const normal = transformSurfaceNormal(surfaceNormal(world[0], world[1], world[2]), chart.view3d?.rotX ?? 25, chart.view3d?.rotY ?? 30, chart.view3d?.rAngAx !== false);\n const rgba = colorToRgba(usesFlatMaterial ? triangle.color : shadeSurfaceMatteColor(triangle.color, normal), 1);\n for (const point of triangle.points) {\n const clip = toClipPoint(point);\n wallPositions.push(clip.x, clip.y, clip.z);\n wallColors.push(rgba[0], rgba[1], rgba[2], rgba[3]);\n }\n }\n for (let index = 0; index < fillVertices.length; index += 3) {\n const left = fillVertices[index];\n const middle = fillVertices[index + 1];\n const right = fillVertices[index + 2];\n if (!left || !middle || !right) {\n continue;\n }\n const world = [left, middle, right].map(vertex => ({ x: vertex.point.worldX, y: vertex.point.worldY, z: -vertex.point.worldZ }));\n const normal = transformSurfaceNormal(surfaceNormal(world[0], world[1], world[2]), chart.view3d?.rotX ?? 25, chart.view3d?.rotY ?? 30, chart.view3d?.rAngAx !== false);\n const shaded = colorToRgba(usesFlatMaterial ? left.bandColor : shadeSurfaceMatteColor(left.bandColor, normal), 1);\n [left, middle, right].forEach((vertex) => {\n const clip = toClipPoint(vertex.point);\n fillPositions.push(clip.x, clip.y, clip.z);\n fillColors.push(shaded[0], shaded[1], shaded[2], shaded[3]);\n });\n }\n\n const linePositions: number[] = [];\n const lineColors: number[] = [];\n meshLines.forEach((line) => {\n const from = toClipPoint(line.from);\n const to = toClipPoint(line.to);\n const rgba = colorToRgba(line.color, 1);\n linePositions.push(from.x, from.y, from.z - 0.00001, to.x, to.y, to.z - 0.00001);\n lineColors.push(rgba[0], rgba[1], rgba[2], rgba[3], rgba[0], rgba[1], rgba[2], rgba[3]);\n });\n contourLines.forEach((line) => {\n const from = toClipPoint(line.from);\n const to = toClipPoint(line.to);\n const rgba = colorToRgba(line.color, 1);\n linePositions.push(from.x, from.y, from.z - 0.00001, to.x, to.y, to.z - 0.00001);\n lineColors.push(rgba[0], rgba[1], rgba[2], rgba[3], rgba[0], rgba[1], rgba[2], rgba[3]);\n });\n\n return {\n fillColors: new Float32Array(fillColors),\n fillPositions: new Float32Array(fillPositions),\n lineColors: new Float32Array(lineColors),\n linePositions: new Float32Array(linePositions),\n wallColors: new Float32Array(wallColors),\n wallPositions: new Float32Array(wallPositions)\n };\n}\n\nfunction paintSurface(gl: WebGLRenderingContext, scene: SurfaceScene) {\n const program = gl.createProgram();\n if (!program) throw new Error(\"Cannot create surface program\");\n const positionBuffer = gl.createBuffer();\n const colorBuffer = gl.createBuffer();\n function attachShader(type: number, source: string) {\n const shader = gl.createShader(type);\n if (!shader) throw new Error(\"Cannot create surface shader\");\n gl.shaderSource(shader, source);\n gl.compileShader(shader);\n gl.attachShader(program!, shader);\n gl.deleteShader(shader);\n }\n try {\n if (!positionBuffer || !colorBuffer) throw new Error(\"Cannot create surface buffers\");\n attachShader(gl.VERTEX_SHADER, `\n precision mediump float;\n attribute vec3 position;\n attribute vec4 color;\n varying vec4 vColor;\n void main() {\n gl_Position = vec4(position, 1.0);\n vColor = color;\n }`);\n attachShader(gl.FRAGMENT_SHADER, `\n precision mediump float;\n varying vec4 vColor;\n void main() {\n gl_FragColor = vColor;\n }`);\n gl.linkProgram(program);\n if (!gl.getProgramParameter(program, gl.LINK_STATUS)) throw new Error(\"Cannot link surface program\");\n gl.useProgram(program);\n const position = gl.getAttribLocation(program, \"position\");\n const color = gl.getAttribLocation(program, \"color\");\n gl.enableVertexAttribArray(position);\n gl.enableVertexAttribArray(color);\n gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);\n gl.enable(gl.DEPTH_TEST);\n gl.enable(gl.BLEND);\n gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);\n gl.clearColor(0, 0, 0, 0);\n gl.clearDepth(1);\n gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);\n const draw = (positions: Float32Array, colors: Float32Array, mode: number, depth: number) => {\n if (positions.length === 0) return;\n gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer);\n gl.bufferData(gl.ARRAY_BUFFER, positions, gl.STREAM_DRAW);\n gl.vertexAttribPointer(position, 3, gl.FLOAT, false, 0, 0);\n gl.bindBuffer(gl.ARRAY_BUFFER, colorBuffer);\n gl.bufferData(gl.ARRAY_BUFFER, colors, gl.STREAM_DRAW);\n gl.vertexAttribPointer(color, 4, gl.FLOAT, false, 0, 0);\n gl.depthFunc(depth);\n gl.drawArrays(mode, 0, positions.length / 3);\n };\n draw(scene.wallPositions, scene.wallColors, gl.TRIANGLES, gl.LEQUAL);\n draw(scene.fillPositions, scene.fillColors, gl.TRIANGLES, gl.LESS);\n draw(scene.linePositions, scene.lineColors, gl.LINES, gl.LEQUAL);\n gl.disableVertexAttribArray(position);\n gl.disableVertexAttribArray(color);\n } finally {\n gl.useProgram(null);\n gl.deleteBuffer(positionBuffer);\n gl.deleteBuffer(colorBuffer);\n gl.deleteProgram(program);\n }\n}\n\nexport const MemoSurfaceChartComposite = React.memo(function MemoSurfaceChartComposite({\n background,\n borderColor,\n chart,\n fontFamily,\n layout,\n onDoubleClick,\n onPointerDown,\n overlay,\n palette,\n fallback\n}: SurfaceCompositeProps) {\n const canvasRef = React.useRef<HTMLCanvasElement | null>(null);\n const [ready, setReady] = React.useState(false);\n const [failed, setFailed] = React.useState(false);\n const isContour = isContourSurfaceChart(chart);\n\n React.useEffect(() => {\n if (isContour) {\n setReady(false);\n setFailed(false);\n return;\n }\n const canvas = canvasRef.current;\n if (!canvas) {\n return;\n }\n const drawSurface = () => {\n try {\n const scene = buildSurfaceMesh(chart, palette, layout);\n if (!scene) throw new Error(\"Empty surface\");\n const dpr = window.devicePixelRatio || 1;\n canvas.width = Math.max(1, Math.round(layout.width * dpr));\n canvas.height = Math.max(1, Math.round(layout.height * dpr));\n const gl = canvas.getContext(\"webgl\", { alpha: true, antialias: true, depth: true, premultipliedAlpha: true });\n if (!gl || gl.isContextLost()) throw new Error(\"WebGL unavailable\");\n paintSurface(gl, scene);\n setReady(true);\n setFailed(false);\n } catch {\n setReady(false);\n setFailed(true);\n }\n };\n const onLost = (event: Event) => {\n event.preventDefault();\n setReady(false);\n setFailed(true);\n };\n canvas.addEventListener(\"webglcontextlost\", onLost);\n canvas.addEventListener(\"webglcontextrestored\", drawSurface);\n drawSurface();\n return () => {\n canvas.removeEventListener(\"webglcontextlost\", onLost);\n canvas.removeEventListener(\"webglcontextrestored\", drawSurface);\n };\n }, [\n chart,\n isContour,\n layout,\n palette\n ]);\n\n const shouldRenderFallback = isContour || failed || !ready;\n\n return (\n <div\n aria-label={chart.title ?? chart.name ?? \"Chart\"}\n data-xlsx-chart-renderer=\"legacy\"\n role=\"img\"\n style={{\n background,\n border: borderColor.trim().toLowerCase() === \"transparent\" ? \"none\" : `1px solid ${borderColor}`,\n boxSizing: \"border-box\",\n fontFamily,\n height: \"100%\",\n overflow: \"hidden\",\n pointerEvents: \"auto\",\n position: \"relative\",\n width: \"100%\"\n }}\n >\n <canvas\n ref={canvasRef}\n style={{\n display: shouldRenderFallback ? \"none\" : \"block\",\n height: \"100%\",\n inset: 0,\n position: \"absolute\",\n width: \"100%\"\n }}\n />\n <svg\n onDoubleClick={onDoubleClick}\n onPointerDown={onPointerDown}\n style={{ display: \"block\", height: \"100%\", inset: 0, position: \"absolute\", width: \"100%\" }}\n viewBox={`0 0 ${layout.width} ${layout.height}`}\n >\n {shouldRenderFallback ? fallback : null}\n {overlay}\n </svg>\n </div>\n );\n}, (prev, next) => (\n prev.chart === next.chart\n && prev.palette === next.palette\n && prev.background === next.background\n && prev.borderColor === next.borderColor\n && prev.fontFamily === next.fontFamily\n && prev.onDoubleClick === next.onDoubleClick\n && prev.onPointerDown === next.onPointerDown\n && prev.layout.width === next.layout.width\n && prev.layout.height === next.layout.height\n && prev.layout.plot.left === next.layout.plot.left\n && prev.layout.plot.top === next.layout.plot.top\n && prev.layout.plot.width === next.layout.plot.width\n && prev.layout.plot.height === next.layout.plot.height\n && prev.overlay === next.overlay\n && prev.fallback === next.fallback\n));\n"]}
|
|
@@ -14,8 +14,7 @@ import {
|
|
|
14
14
|
resolveBuiltinChartColor
|
|
15
15
|
} from "./chunk-VWGKYABF.js";
|
|
16
16
|
|
|
17
|
-
// src/surface-
|
|
18
|
-
import createREGL from "regl";
|
|
17
|
+
// src/surface-webgl.tsx
|
|
19
18
|
import * as React from "react";
|
|
20
19
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
21
20
|
function clamp(value, min, max) {
|
|
@@ -477,6 +476,73 @@ function buildSurfaceMesh(chart, palette, layout) {
|
|
|
477
476
|
wallPositions: new Float32Array(wallPositions)
|
|
478
477
|
};
|
|
479
478
|
}
|
|
479
|
+
function paintSurface(gl, scene) {
|
|
480
|
+
const program = gl.createProgram();
|
|
481
|
+
if (!program) throw new Error("Cannot create surface program");
|
|
482
|
+
const positionBuffer = gl.createBuffer();
|
|
483
|
+
const colorBuffer = gl.createBuffer();
|
|
484
|
+
function attachShader(type, source) {
|
|
485
|
+
const shader = gl.createShader(type);
|
|
486
|
+
if (!shader) throw new Error("Cannot create surface shader");
|
|
487
|
+
gl.shaderSource(shader, source);
|
|
488
|
+
gl.compileShader(shader);
|
|
489
|
+
gl.attachShader(program, shader);
|
|
490
|
+
gl.deleteShader(shader);
|
|
491
|
+
}
|
|
492
|
+
try {
|
|
493
|
+
if (!positionBuffer || !colorBuffer) throw new Error("Cannot create surface buffers");
|
|
494
|
+
attachShader(gl.VERTEX_SHADER, `
|
|
495
|
+
precision mediump float;
|
|
496
|
+
attribute vec3 position;
|
|
497
|
+
attribute vec4 color;
|
|
498
|
+
varying vec4 vColor;
|
|
499
|
+
void main() {
|
|
500
|
+
gl_Position = vec4(position, 1.0);
|
|
501
|
+
vColor = color;
|
|
502
|
+
}`);
|
|
503
|
+
attachShader(gl.FRAGMENT_SHADER, `
|
|
504
|
+
precision mediump float;
|
|
505
|
+
varying vec4 vColor;
|
|
506
|
+
void main() {
|
|
507
|
+
gl_FragColor = vColor;
|
|
508
|
+
}`);
|
|
509
|
+
gl.linkProgram(program);
|
|
510
|
+
if (!gl.getProgramParameter(program, gl.LINK_STATUS)) throw new Error("Cannot link surface program");
|
|
511
|
+
gl.useProgram(program);
|
|
512
|
+
const position = gl.getAttribLocation(program, "position");
|
|
513
|
+
const color = gl.getAttribLocation(program, "color");
|
|
514
|
+
gl.enableVertexAttribArray(position);
|
|
515
|
+
gl.enableVertexAttribArray(color);
|
|
516
|
+
gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
|
|
517
|
+
gl.enable(gl.DEPTH_TEST);
|
|
518
|
+
gl.enable(gl.BLEND);
|
|
519
|
+
gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
|
|
520
|
+
gl.clearColor(0, 0, 0, 0);
|
|
521
|
+
gl.clearDepth(1);
|
|
522
|
+
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
|
|
523
|
+
const draw = (positions, colors, mode, depth) => {
|
|
524
|
+
if (positions.length === 0) return;
|
|
525
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer);
|
|
526
|
+
gl.bufferData(gl.ARRAY_BUFFER, positions, gl.STREAM_DRAW);
|
|
527
|
+
gl.vertexAttribPointer(position, 3, gl.FLOAT, false, 0, 0);
|
|
528
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, colorBuffer);
|
|
529
|
+
gl.bufferData(gl.ARRAY_BUFFER, colors, gl.STREAM_DRAW);
|
|
530
|
+
gl.vertexAttribPointer(color, 4, gl.FLOAT, false, 0, 0);
|
|
531
|
+
gl.depthFunc(depth);
|
|
532
|
+
gl.drawArrays(mode, 0, positions.length / 3);
|
|
533
|
+
};
|
|
534
|
+
draw(scene.wallPositions, scene.wallColors, gl.TRIANGLES, gl.LEQUAL);
|
|
535
|
+
draw(scene.fillPositions, scene.fillColors, gl.TRIANGLES, gl.LESS);
|
|
536
|
+
draw(scene.linePositions, scene.lineColors, gl.LINES, gl.LEQUAL);
|
|
537
|
+
gl.disableVertexAttribArray(position);
|
|
538
|
+
gl.disableVertexAttribArray(color);
|
|
539
|
+
} finally {
|
|
540
|
+
gl.useProgram(null);
|
|
541
|
+
gl.deleteBuffer(positionBuffer);
|
|
542
|
+
gl.deleteBuffer(colorBuffer);
|
|
543
|
+
gl.deleteProgram(program);
|
|
544
|
+
}
|
|
545
|
+
}
|
|
480
546
|
var MemoSurfaceChartComposite = React.memo(function MemoSurfaceChartComposite2({
|
|
481
547
|
background,
|
|
482
548
|
borderColor,
|
|
@@ -503,165 +569,34 @@ var MemoSurfaceChartComposite = React.memo(function MemoSurfaceChartComposite2({
|
|
|
503
569
|
if (!canvas) {
|
|
504
570
|
return;
|
|
505
571
|
}
|
|
506
|
-
let cancelled = false;
|
|
507
|
-
let reglInstance = null;
|
|
508
572
|
const drawSurface = () => {
|
|
509
573
|
try {
|
|
510
574
|
const scene = buildSurfaceMesh(chart, palette, layout);
|
|
511
|
-
if (!scene)
|
|
512
|
-
if (!cancelled) {
|
|
513
|
-
setFailed(true);
|
|
514
|
-
setReady(false);
|
|
515
|
-
}
|
|
516
|
-
return;
|
|
517
|
-
}
|
|
575
|
+
if (!scene) throw new Error("Empty surface");
|
|
518
576
|
const dpr = window.devicePixelRatio || 1;
|
|
519
577
|
canvas.width = Math.max(1, Math.round(layout.width * dpr));
|
|
520
578
|
canvas.height = Math.max(1, Math.round(layout.height * dpr));
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
premultipliedAlpha: true
|
|
527
|
-
},
|
|
528
|
-
canvas
|
|
529
|
-
});
|
|
530
|
-
const fillCommand = scene.fillPositions.length > 0 ? reglInstance({
|
|
531
|
-
attributes: {
|
|
532
|
-
color: scene.fillColors,
|
|
533
|
-
position: scene.fillPositions
|
|
534
|
-
},
|
|
535
|
-
blend: {
|
|
536
|
-
enable: true,
|
|
537
|
-
func: {
|
|
538
|
-
dstRGB: "one minus src alpha",
|
|
539
|
-
dstAlpha: "one minus src alpha",
|
|
540
|
-
srcRGB: "src alpha",
|
|
541
|
-
srcAlpha: "src alpha"
|
|
542
|
-
}
|
|
543
|
-
},
|
|
544
|
-
count: scene.fillPositions.length / 3,
|
|
545
|
-
depth: {
|
|
546
|
-
enable: true
|
|
547
|
-
},
|
|
548
|
-
frag: `
|
|
549
|
-
precision mediump float;
|
|
550
|
-
varying vec4 vColor;
|
|
551
|
-
void main() {
|
|
552
|
-
gl_FragColor = vColor;
|
|
553
|
-
}
|
|
554
|
-
`,
|
|
555
|
-
primitive: "triangles",
|
|
556
|
-
vert: `
|
|
557
|
-
precision mediump float;
|
|
558
|
-
attribute vec3 position;
|
|
559
|
-
attribute vec4 color;
|
|
560
|
-
varying vec4 vColor;
|
|
561
|
-
void main() {
|
|
562
|
-
gl_Position = vec4(position, 1.0);
|
|
563
|
-
vColor = color;
|
|
564
|
-
}
|
|
565
|
-
`
|
|
566
|
-
}) : null;
|
|
567
|
-
const wallCommand = scene.wallPositions.length > 0 ? reglInstance({
|
|
568
|
-
attributes: {
|
|
569
|
-
color: scene.wallColors,
|
|
570
|
-
position: scene.wallPositions
|
|
571
|
-
},
|
|
572
|
-
blend: {
|
|
573
|
-
enable: true,
|
|
574
|
-
func: {
|
|
575
|
-
dstRGB: "one minus src alpha",
|
|
576
|
-
dstAlpha: "one minus src alpha",
|
|
577
|
-
srcRGB: "src alpha",
|
|
578
|
-
srcAlpha: "src alpha"
|
|
579
|
-
}
|
|
580
|
-
},
|
|
581
|
-
count: scene.wallPositions.length / 3,
|
|
582
|
-
depth: {
|
|
583
|
-
enable: true,
|
|
584
|
-
func: "lequal"
|
|
585
|
-
},
|
|
586
|
-
frag: `
|
|
587
|
-
precision mediump float;
|
|
588
|
-
varying vec4 vColor;
|
|
589
|
-
void main() {
|
|
590
|
-
gl_FragColor = vColor;
|
|
591
|
-
}
|
|
592
|
-
`,
|
|
593
|
-
primitive: "triangles",
|
|
594
|
-
vert: `
|
|
595
|
-
precision mediump float;
|
|
596
|
-
attribute vec3 position;
|
|
597
|
-
attribute vec4 color;
|
|
598
|
-
varying vec4 vColor;
|
|
599
|
-
void main() {
|
|
600
|
-
gl_Position = vec4(position, 1.0);
|
|
601
|
-
vColor = color;
|
|
602
|
-
}
|
|
603
|
-
`
|
|
604
|
-
}) : null;
|
|
605
|
-
const lineCommand = scene.linePositions.length > 0 ? reglInstance({
|
|
606
|
-
attributes: {
|
|
607
|
-
color: scene.lineColors,
|
|
608
|
-
position: scene.linePositions
|
|
609
|
-
},
|
|
610
|
-
blend: {
|
|
611
|
-
enable: true,
|
|
612
|
-
func: {
|
|
613
|
-
dstRGB: "one minus src alpha",
|
|
614
|
-
dstAlpha: "one minus src alpha",
|
|
615
|
-
srcRGB: "src alpha",
|
|
616
|
-
srcAlpha: "src alpha"
|
|
617
|
-
}
|
|
618
|
-
},
|
|
619
|
-
count: scene.linePositions.length / 3,
|
|
620
|
-
depth: {
|
|
621
|
-
enable: true,
|
|
622
|
-
func: "lequal"
|
|
623
|
-
},
|
|
624
|
-
frag: `
|
|
625
|
-
precision mediump float;
|
|
626
|
-
varying vec4 vColor;
|
|
627
|
-
void main() {
|
|
628
|
-
gl_FragColor = vColor;
|
|
629
|
-
}
|
|
630
|
-
`,
|
|
631
|
-
lineWidth: 1,
|
|
632
|
-
primitive: "lines",
|
|
633
|
-
vert: `
|
|
634
|
-
precision mediump float;
|
|
635
|
-
attribute vec3 position;
|
|
636
|
-
attribute vec4 color;
|
|
637
|
-
varying vec4 vColor;
|
|
638
|
-
void main() {
|
|
639
|
-
gl_Position = vec4(position, 1.0);
|
|
640
|
-
vColor = color;
|
|
641
|
-
}
|
|
642
|
-
`
|
|
643
|
-
}) : null;
|
|
644
|
-
reglInstance.clear({ color: [0, 0, 0, 0], depth: 1 });
|
|
645
|
-
wallCommand?.();
|
|
646
|
-
fillCommand?.();
|
|
647
|
-
lineCommand?.();
|
|
648
|
-
if (!cancelled) {
|
|
649
|
-
setReady(true);
|
|
650
|
-
setFailed(false);
|
|
651
|
-
}
|
|
579
|
+
const gl = canvas.getContext("webgl", { alpha: true, antialias: true, depth: true, premultipliedAlpha: true });
|
|
580
|
+
if (!gl || gl.isContextLost()) throw new Error("WebGL unavailable");
|
|
581
|
+
paintSurface(gl, scene);
|
|
582
|
+
setReady(true);
|
|
583
|
+
setFailed(false);
|
|
652
584
|
} catch {
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
setFailed(true);
|
|
656
|
-
}
|
|
585
|
+
setReady(false);
|
|
586
|
+
setFailed(true);
|
|
657
587
|
}
|
|
658
588
|
};
|
|
659
|
-
|
|
660
|
-
|
|
589
|
+
const onLost = (event) => {
|
|
590
|
+
event.preventDefault();
|
|
591
|
+
setReady(false);
|
|
592
|
+
setFailed(true);
|
|
593
|
+
};
|
|
594
|
+
canvas.addEventListener("webglcontextlost", onLost);
|
|
595
|
+
canvas.addEventListener("webglcontextrestored", drawSurface);
|
|
661
596
|
drawSurface();
|
|
662
597
|
return () => {
|
|
663
|
-
|
|
664
|
-
|
|
598
|
+
canvas.removeEventListener("webglcontextlost", onLost);
|
|
599
|
+
canvas.removeEventListener("webglcontextrestored", drawSurface);
|
|
665
600
|
};
|
|
666
601
|
}, [
|
|
667
602
|
chart,
|
|
@@ -674,6 +609,7 @@ var MemoSurfaceChartComposite = React.memo(function MemoSurfaceChartComposite2({
|
|
|
674
609
|
"div",
|
|
675
610
|
{
|
|
676
611
|
"aria-label": chart.title ?? chart.name ?? "Chart",
|
|
612
|
+
"data-xlsx-chart-renderer": "legacy",
|
|
677
613
|
role: "img",
|
|
678
614
|
style: {
|
|
679
615
|
background,
|
|
@@ -720,4 +656,4 @@ var MemoSurfaceChartComposite = React.memo(function MemoSurfaceChartComposite2({
|
|
|
720
656
|
export {
|
|
721
657
|
MemoSurfaceChartComposite
|
|
722
658
|
};
|
|
723
|
-
//# sourceMappingURL=surface-
|
|
659
|
+
//# sourceMappingURL=surface-webgl-4DQXDDXU.js.map
|