未验证 提交 0ac6f319 编写于 作者: Y Yi Shen 提交者: GitHub

Merge pull request #14408 from apache/fix-toolbox-custom

fix(toolbox): the `show` option of customized toolbox button does not work.
......@@ -127,17 +127,21 @@ class ToolboxView extends ComponentView {
feature.ecModel = ecModel;
feature.api = api;
if (feature instanceof ToolboxFeature) {
if (!featureName && oldName) {
feature.dispose && feature.dispose(ecModel, api);
return;
}
const isToolboxFeature = feature instanceof ToolboxFeature;
if (!featureName && oldName) {
isToolboxFeature
&& (feature as ToolboxFeature).dispose
&& (feature as ToolboxFeature).dispose(ecModel, api);
return;
}
if (!featureModel.get('show') || feature.unusable) {
feature.remove && feature.remove(ecModel, api);
return;
}
if (!featureModel.get('show') || (isToolboxFeature && (feature as ToolboxFeature).unusable)) {
isToolboxFeature
&& (feature as ToolboxFeature).remove
&& (feature as ToolboxFeature).remove(ecModel, api);
return;
}
createIconPaths(featureModel, feature, featureName);
featureModel.setIconStatus = function (this: ToolboxFeatureModel, iconName: string, status: DisplayState) {
......@@ -354,4 +358,4 @@ class ToolboxView extends ComponentView {
function isUserFeatureName(featureName: string): boolean {
return featureName.indexOf('my') === 0;
}
export default ToolboxView;
\ No newline at end of file
export default ToolboxView;
<!DOCTYPE html>
<!--
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">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<script src="lib/esl.js"></script>
<script src="lib/config.js"></script>
<script src="lib/facePrint.js"></script>
<script src="lib/testHelper.js"></script>
<!-- <script src="ut/lib/canteen.js"></script> -->
<link rel="stylesheet" href="lib/reset.css" />
</head>
<body>
<div id="main0"></div>
<script>
require(['echarts'], function (echarts) {
var option = {
xAxis: {},
yAxis: {},
series: {
type: 'line',
data: [[11, 22], [33, 44]]
},
toolbox: {
show: true,
right: 20,
feature: {
restore: {},
saveAsImage: {},
dataZoom: {},
dataView: {
show: false
},
myTool1: {
show: false,
title: 'myTool1',
icon: 'path://M432.45,595.444c0,2.177-4.661,6.82-11.305,6.82c-6.475,0-11.306-4.567-11.306-6.82s4.852-6.812,11.306-6.812C427.841,588.632,432.452,593.191,432.45,595.444L432.45,595.444z M421.155,589.876c-3.009,0-5.448,2.495-5.448,5.572s2.439,5.572,5.448,5.572c3.01,0,5.449-2.495,5.449-5.572C426.604,592.371,424.165,589.876,421.155,589.876L421.155,589.876z M421.146,591.891c-1.916,0-3.47,1.589-3.47,3.549c0,1.959,1.554,3.548,3.47,3.548s3.469-1.589,3.469-3.548C424.614,593.479,423.062,591.891,421.146,591.891L421.146,591.891zM421.146,591.891',
onclick: function (){
alert('myToolHandler1')
}
},
myTool2: {
show: true,
title: 'myTool2',
icon: 'image://data:image/gif;base64,R0lGODlhEAAQAMQAAORHHOVSKudfOulrSOp3WOyDZu6QdvCchPGolfO0o/XBs/fNwfjZ0frl3/zy7////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAkAABAALAAAAAAQABAAAAVVICSOZGlCQAosJ6mu7fiyZeKqNKToQGDsM8hBADgUXoGAiqhSvp5QAnQKGIgUhwFUYLCVDFCrKUE1lBavAViFIDlTImbKC5Gm2hB0SlBCBMQiB0UjIQA7',
onclick: function () {
alert('myToolHandler2')
}
}
}
},
animation: false
};
var chart = testHelper.create(echarts, 'main0', {
title: [
'Customized toolbox button **should not be visible** when `show` is set to be `false`',
'myTool1 should be **invisible**, myTool2 should be **visible**',
'See https://github.com/apache/echarts/issues/14405'
],
option: option
});
});
</script>
</body>
</html>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册