|  | <!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/jquery.min.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> | 
|  | <div id="main1"></div> | 
|  | <div id="main2"></div> | 
|  | <div id="main3"></div> | 
|  | <div id="main4"></div> | 
|  | <script> | 
|  | require(['echarts'/*, 'map/js/china' */], function (echarts) { | 
|  | var option; | 
|  | var tooltipContent; | 
|  |  | 
|  | option = { | 
|  | xAxis: {}, | 
|  | yAxis: {}, | 
|  | series: { | 
|  | type: 'line', | 
|  | data: [[11, 22], [33, 44]] | 
|  | }, | 
|  | tooltip: { | 
|  | formatter: () => { | 
|  | if (!tooltipContent) { | 
|  | tooltipContent = document.createElement('span'); | 
|  | document.body.appendChild(tooltipContent); | 
|  | var setDate = () => tooltipContent.innerHTML = new Date(); | 
|  | setDate(); | 
|  | setInterval(setDate , 1000); | 
|  | }; | 
|  | return [tooltipContent]; | 
|  | } | 
|  | } | 
|  | }; | 
|  |  | 
|  | var chart = testHelper.create(echarts, 'main0', { | 
|  | title: [ | 
|  | 'Tooltip formatter returns DOM node', | 
|  | '(Tooltip show current time)' | 
|  | ], | 
|  | option: option | 
|  | }); | 
|  | }); | 
|  | </script> | 
|  |  | 
|  | <script> | 
|  | require(['echarts'], function (echarts) { | 
|  | var option; | 
|  | var tooltipContent = document.createElement('span'); | 
|  | tooltipContent.innerText = 'Tooltip formatter is a DOM node (not function callback)'; | 
|  |  | 
|  | option = { | 
|  | xAxis: {}, | 
|  | yAxis: {}, | 
|  | series: { | 
|  | type: 'line', | 
|  | data: [[11, 22], [33, 44], [55, 66]] | 
|  | }, | 
|  | tooltip: { | 
|  | formatter: tooltipContent | 
|  | } | 
|  | }; | 
|  |  | 
|  | var chart = testHelper.create(echarts, 'main1', { | 
|  | title: [ | 
|  | 'Tooltip formatter is DOM node (not function callback)' | 
|  | ], | 
|  | option: option | 
|  | }); | 
|  | }); | 
|  | </script> | 
|  |  | 
|  | <script> | 
|  | require(['echarts'], function (echarts) { | 
|  | var option; | 
|  | var tooltipContent = document.createElement('a'); | 
|  | tooltipContent.href = 'javascript:void(0);'; | 
|  | tooltipContent.onclick = () => console.log('test'); | 
|  | tooltipContent.textContent = 'Olala'; | 
|  |  | 
|  | option = { | 
|  | xAxis: {}, | 
|  | yAxis: {}, | 
|  | series: { | 
|  | type: 'line', | 
|  | data: [[11, 22], [33, 44], [55, 66]] | 
|  | }, | 
|  | tooltip: { | 
|  | position: 'top', | 
|  | enterable: true, | 
|  | formatter: [tooltipContent] | 
|  | } | 
|  | }; | 
|  |  | 
|  | var chart = testHelper.create(echarts, 'main2', { | 
|  | title: [ | 
|  | 'Tooltip should show DOM content instead of the string **[object HTMLSpanElement]**', | 
|  | 'https://github.com/apache/echarts/issues/15307' | 
|  | ], | 
|  | option: option | 
|  | }); | 
|  | }); | 
|  | </script> | 
|  |  | 
|  | <script> | 
|  | require(['echarts'], function (echarts) { | 
|  | var option; | 
|  |  | 
|  | option = { | 
|  | xAxis: {}, | 
|  | yAxis: {}, | 
|  | series: { | 
|  | type: 'line', | 
|  | data: [[11, 22], [33, 44], [55, 66]] | 
|  | }, | 
|  | tooltip: { | 
|  | position: 'top', | 
|  | enterable: true, | 
|  | formatter: [] | 
|  | } | 
|  | }; | 
|  |  | 
|  | var chart = testHelper.create(echarts, 'main3', { | 
|  | title: [ | 
|  | 'Tooltip should show nothing', | 
|  | ], | 
|  | option: option | 
|  | }); | 
|  | }); | 
|  | </script> | 
|  |  | 
|  | <script> | 
|  | require(['echarts'], function (echarts) { | 
|  | var option; | 
|  |  | 
|  | option = { | 
|  | xAxis: {}, | 
|  | yAxis: {}, | 
|  | series: { | 
|  | type: 'line', | 
|  | data: [[11, 22], [33, 44], [55, 66]] | 
|  | }, | 
|  | tooltip: { | 
|  | position: 'top', | 
|  | borderWidth: 40, | 
|  | formatter: '{a}<br>Data is {c}' | 
|  | } | 
|  | }; | 
|  |  | 
|  | var chart = testHelper.create(echarts, 'main4', { | 
|  | title: [ | 
|  | 'Tooltip arrow shouldn\'t cover the content', | 
|  | ], | 
|  | option: option | 
|  | }); | 
|  | }); | 
|  | </script> | 
|  |  | 
|  | </body> | 
|  | </html> |