提交 90ae5407 编写于 作者: L lang

save as image default use option backgroundColor

上级 1fdc7047
......@@ -10,7 +10,8 @@ define(function (require) {
M29.2,45.1L29.2,0',
title: '保存为图片',
type: 'png',
backgroundColor: '#fff',
// Default use option.backgroundColor
// backgroundColor: '#fff',
name: '',
excludeComponents: ['toolbox'],
pixelRatio: 1
......@@ -27,7 +28,8 @@ define(function (require) {
$a.target = '_blank';
$a.href = api.getConnectedDataURL({
type: type,
backgroundColor: model.get('backgroundColor'),
backgroundColor: model.get('backgroundColor', true)
|| ecModel.get('backgroundColor') || '#fff',
excludeComponents: model.get('excludeComponents'),
pixelRatio: model.get('pixelRatio')
});
......
......@@ -212,7 +212,7 @@ define(function (require) {
opts = opts || {};
opts.pixelRatio = opts.pixelRatio || 1;
opts.backgroundColor = opts.backgroundColor
|| this._model.option.backgroundColor;
|| this._model.get('backgroundColor');
var zr = this._zr;
var list = zr.storage.getDisplayList();
// Stop animations
......@@ -229,11 +229,13 @@ define(function (require) {
* @param {string} [opts.backgroundColor]
*/
echartsProto.getDataURL = function (opts) {
var excludeComponents = opts;
opts = opts || {};
var excludeComponents = opts.excludeComponents;
var ecModel = this._model;
var excludesComponentViews = [];
var self = this;
excludeComponents = each(excludeComponents, function (componentType) {
each(excludeComponents, function (componentType) {
ecModel.eachComponent({
mainType: componentType
}, function (component) {
......@@ -281,7 +283,9 @@ define(function (require) {
for (var id in instances) {
var chart = instances[id];
if (chart.group === groupId) {
var canvas = chart.getRenderedCanvas(opts);
var canvas = chart.getRenderedCanvas(
zrUtil.clone(opts)
);
var boundingRect = chart.getDom().getBoundingClientRect();
left = mathMin(boundingRect.left, left);
top = mathMin(boundingRect.top, top);
......@@ -368,13 +372,16 @@ define(function (require) {
backgroundColor = 'transparent';
}
}
// TODO all use clearColor ?
if (env.node) {
this._zr.configLayer(0, {
clearColor: backgroundColor
});
}
else {
backgroundColor && (this._dom.style.backgroundColor = backgroundColor);
backgroundColor = backgroundColor || 'transparent';
this._dom.style.backgroundColor = backgroundColor;
}
// console.time && console.timeEnd('update');
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册