blob: 6f423eb4fd4a808c8d0715f92cfd5a477ae9a328 [file]
<!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/simpleRequire.js"></script>
<script src="lib/config.js"></script>
<script src="lib/facePrint.js"></script>
<script src="lib/testHelper.js"></script>
<link rel="stylesheet" href="lib/reset.css" />
</head>
<body>
<div id="main0"></div>
<div id="main_update1"></div>
<div id="main_update2"></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>
<script>
require([
'echarts',
], function (echarts) {
var _ctx = {
featureList: [
'saveAsImage',
'myTool1',
],
};
_ctx.lastFeatureList = _ctx.featureList;
var MY_THEME = {
toolbox: {
feature: {
// dataView panel theme is customized.
dataView: {
backgroundColor: 'blue',
textColor: 'black',
textareaColor: 'green',
textareaBorderColor: 'green',
buttonColor: 'black',
buttonTextColor: 'green'
}
}
},
};
var allFeatures = {
restore: {},
saveAsImage: {},
dataZoom: {},
dataView: {},
myTool1: {
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');
}
}
};
function createFeaturesOption(addShowProp) {
var featureOption = {};
var featureList = _ctx.featureList;
var lastFeatureList = _ctx.lastFeatureList;
featureList.forEach(function (featureName) {
if (addShowProp) {
featureOption[featureName] = Object.assign({}, allFeatures[featureName]);
featureOption[featureName].show = true;
}
else {
featureOption[featureName] = allFeatures[featureName];
}
});
if (addShowProp) {
lastFeatureList.forEach(function (lastFeatureName) {
if (!featureOption[lastFeatureName]) {
featureOption[lastFeatureName] = {show: false};
}
});
}
return featureOption;
}
function createOption() {
var option = {
tooltip: {},
xAxis: {},
yAxis: {},
series: {
type: 'line',
data: [[11, 22], [33, 44]]
},
toolbox: {
show: true,
right: 20,
feature: createFeaturesOption()
},
animation: false
};
return option;
}
var chart = testHelper.create(echarts, 'main_update1', {
title: [
'Init toolbox features in a theme where dataView panel is customized.',
'In the init state, **dataView** button should not be displayed.',
'Then test update: merge mode, **no "show" specified**, expect no remove',
],
option: createOption(),
theme: MY_THEME,
inputsStyle: 'compact',
inputs: [{
type: 'select',
text: 'update:',
values: [
_ctx.featureList,
[],
['restore', 'dataZoom'],
['restore', 'saveAsImage', 'dataView', 'myTool2']
],
onchange() {
_ctx.lastFeatureList = _ctx.featureList;
_ctx.featureList = this.value;
chart.setOption({
toolbox: {
feature: createFeaturesOption(false),
}
});
}
}]
});
});
</script>
<script>
require([
'echarts',
], function (echarts) {
var _ctx = {
featureList: [
'saveAsImage',
'myTool1',
],
};
_ctx.lastFeatureList = _ctx.featureList;
var MY_THEME = {
toolbox: {
feature: {
// dataView panel theme is customized.
dataView: {
backgroundColor: 'blue',
textColor: 'black',
textareaColor: 'green',
textareaBorderColor: 'green',
buttonColor: 'black',
buttonTextColor: 'green'
}
}
},
};
var allFeatures = {
restore: {},
saveAsImage: {},
dataZoom: {},
dataView: {},
myTool1: {
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');
}
}
};
function createFeaturesOption(addShowProp) {
var featureOption = {};
var featureList = _ctx.featureList;
var lastFeatureList = _ctx.lastFeatureList;
featureList.forEach(function (featureName) {
if (addShowProp) {
featureOption[featureName] = Object.assign({}, allFeatures[featureName]);
featureOption[featureName].show = true;
}
else {
featureOption[featureName] = allFeatures[featureName];
}
});
if (addShowProp) {
lastFeatureList.forEach(function (lastFeatureName) {
if (!featureOption[lastFeatureName]) {
featureOption[lastFeatureName] = {show: false};
}
});
}
return featureOption;
}
function createOption() {
var option = {
tooltip: {},
xAxis: {},
yAxis: {},
series: {
type: 'line',
data: [[11, 22], [33, 44]]
},
toolbox: {
show: true,
right: 20,
feature: createFeaturesOption()
},
animation: false
};
return option;
}
var chart = testHelper.create(echarts, 'main_update2', {
title: [
'Init toolbox features in a theme where dataView panel is customized.',
'In the init state, **dataView** button should not be displayed.',
'Then test update: merge mode, **"show" specified**, expect removable',
],
option: createOption(),
theme: MY_THEME,
inputsStyle: 'compact',
inputs: [{
type: 'select',
text: 'update:',
values: [
_ctx.featureList,
[],
['restore', 'dataZoom'],
['restore', 'saveAsImage','dataZoom','dataView','myTool1']
],
onchange() {
_ctx.lastFeatureList = _ctx.featureList;
_ctx.featureList = this.value;
chart.setOption({
toolbox: {
feature: createFeaturesOption(true),
}
});
}
}]
});
});
</script>
</body>
</html>