You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by ov...@apache.org on 2019/04/03 07:11:25 UTC
[incubator-echarts] branch heads/for/fix-10099 created (now b0eeda9)
This is an automated email from the ASF dual-hosted git repository.
ovilia pushed a change to branch heads/for/fix-10099
in repository https://gitbox.apache.org/repos/asf/incubator-echarts.git.
at b0eeda9 feat: support backgroundColor for connected charts in toolbox toolbox.feature.saveAsImage.connectedBackgroundColor can be used to set the background color. Fix #10099
This branch includes the following new commits:
new b0eeda9 feat: support backgroundColor for connected charts in toolbox toolbox.feature.saveAsImage.connectedBackgroundColor can be used to set the background color. Fix #10099
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
[incubator-echarts] 01/01: feat: support backgroundColor for
connected charts in toolbox
toolbox.feature.saveAsImage.connectedBackgroundColor can be used to set the
background color. Fix #10099
Posted by ov...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ovilia pushed a commit to branch heads/for/fix-10099
in repository https://gitbox.apache.org/repos/asf/incubator-echarts.git
commit b0eeda9b882e929c50420aabea622c63d1e55b6e
Author: Ovilia <zw...@gmail.com>
AuthorDate: Wed Apr 3 15:10:06 2019 +0800
feat: support backgroundColor for connected charts in toolbox
toolbox.feature.saveAsImage.connectedBackgroundColor can be used to set
the background color.
Fix #10099
---
src/component/toolbox/feature/SaveAsImage.js | 2 +
src/echarts.js | 15 +++
test/toolbox-saveImage-background.html | 168 +++++++++++++++++++++++++++
3 files changed, 185 insertions(+)
diff --git a/src/component/toolbox/feature/SaveAsImage.js b/src/component/toolbox/feature/SaveAsImage.js
index 0b18aab..d81a06d 100644
--- a/src/component/toolbox/feature/SaveAsImage.js
+++ b/src/component/toolbox/feature/SaveAsImage.js
@@ -36,6 +36,7 @@ SaveAsImage.defaultOption = {
type: 'png',
// Default use option.backgroundColor
// backgroundColor: '#fff',
+ connectedBackgroundColor: '#fff',
name: '',
excludeComponents: ['toolbox'],
pixelRatio: 1,
@@ -54,6 +55,7 @@ proto.onclick = function (ecModel, api) {
type: type,
backgroundColor: model.get('backgroundColor', true)
|| ecModel.get('backgroundColor') || '#fff',
+ connectedBackgroundColor: model.get('connectedBackgroundColor'),
excludeComponents: model.get('excludeComponents'),
pixelRatio: model.get('pixelRatio')
});
diff --git a/src/echarts.js b/src/echarts.js
index 0ba60fc..035b454 100644
--- a/src/echarts.js
+++ b/src/echarts.js
@@ -567,6 +567,21 @@ echartsProto.getConnectedDataURL = function (opts) {
targetCanvas.height = height;
var zr = zrender.init(targetCanvas);
+ // Background between the charts
+ if (opts.connectedBackgroundColor) {
+ zr.add(new graphic.Rect({
+ shape: {
+ x: 0,
+ y: 0,
+ width: width,
+ height: height
+ },
+ style: {
+ fill: opts.connectedBackgroundColor
+ }
+ }));
+ }
+
each(canvasList, function (item) {
var img = new graphic.Image({
style: {
diff --git a/test/toolbox-saveImage-background.html b/test/toolbox-saveImage-background.html
new file mode 100644
index 0000000..a8701d7
--- /dev/null
+++ b/test/toolbox-saveImage-background.html
@@ -0,0 +1,168 @@
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<html>
+
+<head>
+ <meta charset="utf-8">
+ <script src="lib/esl.js"></script>
+ <script src="lib/config.js"></script>
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
+</head>
+
+<body>
+ <style>
+ html,
+ body {
+ width: 80%;
+ height: 100%;
+ margin: 0;
+ }
+
+ #chart1, #chart2 {
+ background: #fff;
+ margin-bottom: 20px;
+ width: 80%;
+ height: 100%;
+ }
+ </style>
+
+ <p>The background of the exported png using toolbox should be yellow.</p>
+
+ <div id="chart1"></div>
+ <div id="chart2"></div>
+ <script>
+
+ require([
+ 'echarts'
+ // 'echarts/chart/bar',
+ // 'echarts/component/polar',
+ // 'zrender/vml/vml'
+ ], function (echarts) {
+ var chart1 = echarts.init(document.getElementById('chart1'));
+ var chart2 = echarts.init(document.getElementById('chart2'));
+
+ var data1 = [];
+
+ var symbolCount = 6;
+
+ for (var i = 0; i < 100; i++) {
+ data1.push([
+ Math.random() * 5,
+ Math.random() * 4,
+ Math.random() * 20,
+ Math.round(Math.random() * (symbolCount - 1))
+ ]);
+ }
+
+ chart1.setOption({
+ backgroundColor: 'red',
+ "toolbox": {
+ "feature": {
+ "saveAsImage": {
+ "show": true,
+ "title": "Save as image",
+ "type": "png",
+ connectedBackgroundColor: 'yellow'
+ },
+ "dataZoom": {
+ "yAxisIndex": "none",
+ "show": true,
+ "title": {
+ "zoom": "Zoom in",
+ "back": "Zoom out"
+ },
+ }
+ },
+ "show": true,
+ "itemGap": 1,
+ "top": 20,
+ "right": 35
+ },
+ legend: {
+ top: 50,
+ data: ['scatter']
+ },
+ tooltip: {
+ formatter: '{c}'
+ },
+ grid: {
+ top: '26%',
+ bottom: '26%'
+ },
+ xAxis: {
+ type: 'value',
+ splitLine: {
+ show: false
+ }
+ },
+ yAxis: {
+ type: 'value',
+ splitLine: {
+ show: false
+ }
+ },
+ series: [{
+ name: 'scatter',
+ type: 'scatter',
+ symbolSize: 30,
+ data: data1
+ }]
+ });
+
+ chart2.setOption({
+ backgroundColor: 'green',
+ legend: {
+ top: 50,
+ data: ['scatter']
+ },
+ tooltip: {
+ formatter: '{c}'
+ },
+ grid: {
+ top: '26%',
+ bottom: '26%'
+ },
+ xAxis: {
+ type: 'value',
+ splitLine: {
+ show: false
+ }
+ },
+ yAxis: {
+ type: 'value',
+ splitLine: {
+ show: false
+ }
+ },
+ series: [{
+ name: 'scatter',
+ type: 'scatter',
+ symbolSize: 30,
+ data: data1
+ }]
+ });
+
+ echarts.connect([chart1, chart2]);
+
+ });
+ </script>
+</body>
+
+</html>
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org