(opts?: {
// file type 'png' by default
type?: 'png' | 'jpeg' | 'svg',
pixelRatio?: number,
backgroundColor?: ZRColor,
// component type array
excludeComponents?: ComponentMainType[]
})
| 966 | } |
| 967 | |
| 968 | getDataURL(opts?: { |
| 969 | // file type 'png' by default |
| 970 | type?: 'png' | 'jpeg' | 'svg', |
| 971 | pixelRatio?: number, |
| 972 | backgroundColor?: ZRColor, |
| 973 | // component type array |
| 974 | excludeComponents?: ComponentMainType[] |
| 975 | }): string { |
| 976 | if (this._disposed) { |
| 977 | disposedWarning(this.id); |
| 978 | return; |
| 979 | } |
| 980 | |
| 981 | opts = opts || {}; |
| 982 | const excludeComponents = opts.excludeComponents; |
| 983 | const ecModel = this._model; |
| 984 | const excludesComponentViews: ComponentView[] = []; |
| 985 | const self = this; |
| 986 | |
| 987 | each(excludeComponents, function (componentType) { |
| 988 | ecModel.eachComponent({ |
| 989 | mainType: componentType |
| 990 | }, function (component) { |
| 991 | const view = self._componentsMap[component.__viewId]; |
| 992 | if (!view.group.ignore) { |
| 993 | excludesComponentViews.push(view); |
| 994 | view.group.ignore = true; |
| 995 | } |
| 996 | }); |
| 997 | }); |
| 998 | |
| 999 | const url = this._zr.painter.getType() === 'svg' |
| 1000 | ? this.getSvgDataURL() |
| 1001 | : this.renderToCanvas(opts).toDataURL( |
| 1002 | 'image/' + (opts && opts.type || 'png') |
| 1003 | ); |
| 1004 | |
| 1005 | each(excludesComponentViews, function (view) { |
| 1006 | view.group.ignore = false; |
| 1007 | }); |
| 1008 | |
| 1009 | return url; |
| 1010 | } |
| 1011 | |
| 1012 | getConnectedDataURL(opts?: { |
| 1013 | // file type 'png' by default |
no test coverage detected