MCPcopy
hub / github.com/apache/echarts / startRecording

Function startRecording

test/lib/testHelper.js:3368–3412  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3366 var oldRefreshImmediately = chart.getZr().refreshImmediately;
3367
3368 function startRecording() {
3369 // Normal resolution or high resolution?
3370 var compositeCanvas = document.createElement('canvas');
3371 var width = chart.getWidth();
3372 var height = chart.getHeight();
3373 compositeCanvas.width = width;
3374 compositeCanvas.height = height;
3375 var compositeCtx = compositeCanvas.getContext('2d');
3376
3377 chart.getZr().refreshImmediately = function () {
3378 var ret = oldRefreshImmediately.apply(this, arguments);
3379 var canvasList = chart.getDom().querySelectorAll('canvas');
3380 compositeCtx.fillStyle = '#fff';
3381 compositeCtx.fillRect(0, 0, width, height);
3382 for (var i = 0; i < canvasList.length; i++) {
3383 compositeCtx.drawImage(canvasList[i], 0, 0, width, height);
3384 }
3385 return ret;
3386 }
3387
3388 var stream = compositeCanvas.captureStream(25);
3389 recorder = new MediaRecorder(stream, { mimeType: 'video/webm' });
3390
3391 var videoData = [];
3392 recorder.ondataavailable = function (event) {
3393 if (event.data && event.data.size) {
3394 videoData.push(event.data);
3395 }
3396 };
3397
3398 recorder.onstop = function () {
3399 var url = URL.createObjectURL(new Blob(videoData, { type: 'video/webm' }));
3400
3401 var a = document.createElement('a');
3402 a.href = url;
3403 a.download = 'recording.webm';
3404 a.click();
3405
3406 setTimeout(function () {
3407 window.URL.revokeObjectURL(url);
3408 }, 100);
3409 };
3410
3411 recorder.start();
3412 }
3413
3414 function stopRecording() {
3415 if (recorder) {

Callers

nothing calls this directly

Calls 6

getContextMethod · 0.80
getDomMethod · 0.80
startMethod · 0.80
getWidthMethod · 0.65
getHeightMethod · 0.65
getZrMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…