MCPcopy Index your code
hub / github.com/apache/echarts / getConnectedDataURL

Method getConnectedDataURL

src/core/echarts.ts:1012–1122  ·  view source on GitHub ↗
(opts?: {
        // file type 'png' by default
        type?: 'png' | 'jpeg' | 'svg',
        pixelRatio?: number,
        backgroundColor?: ZRColor,
        connectedBackgroundColor?: ZRColor
        excludeComponents?: string[]
    })

Source from the content-addressed store, hash-verified

1010 }
1011
1012 getConnectedDataURL(opts?: {
1013 // file type 'png' by default
1014 type?: 'png' | 'jpeg' | 'svg',
1015 pixelRatio?: number,
1016 backgroundColor?: ZRColor,
1017 connectedBackgroundColor?: ZRColor
1018 excludeComponents?: string[]
1019 }): string {
1020 if (this._disposed) {
1021 disposedWarning(this.id);
1022 return;
1023 }
1024
1025 const isSvg = opts.type === 'svg';
1026 const groupId = this.group;
1027 const mathMin = Math.min;
1028 const mathMax = Math.max;
1029 const MAX_NUMBER = Infinity;
1030 if (connectedGroups[groupId]) {
1031 let left = MAX_NUMBER;
1032 let top = MAX_NUMBER;
1033 let right = -MAX_NUMBER;
1034 let bottom = -MAX_NUMBER;
1035 const canvasList: {dom: HTMLCanvasElement | string, left: number, top: number}[] = [];
1036 const dpr = (opts && opts.pixelRatio) || this.getDevicePixelRatio();
1037
1038 each(instances, function (chart, id) {
1039 if (chart.group === groupId) {
1040 const canvas = isSvg
1041 ? (chart.getZr().painter as SVGPainter).getSvgDom().innerHTML
1042 : chart.renderToCanvas(clone(opts));
1043 const boundingRect = chart.getDom().getBoundingClientRect();
1044 left = mathMin(boundingRect.left, left);
1045 top = mathMin(boundingRect.top, top);
1046 right = mathMax(boundingRect.right, right);
1047 bottom = mathMax(boundingRect.bottom, bottom);
1048 canvasList.push({
1049 dom: canvas,
1050 left: boundingRect.left,
1051 top: boundingRect.top
1052 });
1053 }
1054 });
1055
1056 left *= dpr;
1057 top *= dpr;
1058 right *= dpr;
1059 bottom *= dpr;
1060 const width = right - left;
1061 const height = bottom - top;
1062 const targetCanvas = platformApi.createCanvas();
1063 const zr = zrender.init(targetCanvas, {
1064 renderer: isSvg ? 'svg' : 'canvas'
1065 });
1066 zr.resize({
1067 width: width,
1068 height: height
1069 });

Callers 1

onclickMethod · 0.80

Calls 11

getDevicePixelRatioMethod · 0.95
getDataURLMethod · 0.95
disposedWarningFunction · 0.85
cloneFunction · 0.85
renderToCanvasMethod · 0.80
getDomMethod · 0.80
getZrMethod · 0.65
eachFunction · 0.50
initMethod · 0.45
resizeMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected