forked from apache/echarts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add -cases.html to test svg and canvas.
- Loading branch information
Showing
168 changed files
with
476 additions
and
188 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<!DOCTYPE> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<title>echarts cases</title> | ||
<script src="lib/jquery.min.js"></script> | ||
<script src="lib/testHelper.js"></script> | ||
<link rel="stylesheet" href="lib/reset.css"> | ||
|
||
<style> | ||
.cases-list { | ||
padding-top: 15px; | ||
position: absolute; | ||
left: 0; | ||
top: 0; | ||
bottom: 0; | ||
width: 230px; | ||
overflow: auto; | ||
font-size: 13px; | ||
} | ||
.cases-list ul { | ||
padding-left: 32px; | ||
list-style-type: decimal; | ||
} | ||
.renderer-selector { | ||
padding-left: 20px; | ||
} | ||
.page-content { | ||
margin-left: 235px; | ||
height: 100%; | ||
padding: 0; | ||
position: relative; | ||
border-left: 1px solid #333; | ||
} | ||
.page-content iframe { | ||
padding: 0; | ||
margin: 0; | ||
border-width: 0; | ||
overflow: visible; | ||
visibility: visible; | ||
position: absolute; | ||
left: 0; | ||
top: 0; | ||
width: 100%; | ||
height: 100%; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div class="cases-list"> | ||
<div class="renderer-selector"> | ||
<input type="radio" value="canvas" name="renderer" /> CANVAS | ||
<input type="radio" value="svg" name="renderer" /> SVG | ||
</div> | ||
<ul></ul> | ||
</div> | ||
|
||
<div class="page-content"> | ||
<iframe frameborder="no" border="0" marginwidth="0" marginheight="0" | ||
hspace="0" vspace="0"> | ||
</iframe> | ||
</div> | ||
|
||
<script src="-cases.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
(function () { | ||
|
||
var testHelper = window.testHelper; | ||
var encodeHTML = testHelper.encodeHTML; | ||
var resolve = testHelper.resolve; | ||
|
||
var SELECTOR_CASES_LIST_CONTAINER = '.cases-list ul'; | ||
var SELECTOR_CASES_ITEM = 'li a'; | ||
var SELECTOR_CONTENT_IFRAME = '.page-content iframe'; | ||
var SELECTOR_RENDERER = '.renderer-selector input'; | ||
|
||
run(); | ||
|
||
function run() { | ||
// Init list | ||
$.ajax({ | ||
url: dir() + '/' | ||
}).then(function (content) { | ||
var pagePaths = fetchPagePaths(content); | ||
render(pagePaths); | ||
}); | ||
|
||
$(window).on('hashchange', function () { | ||
reset(); | ||
}); | ||
|
||
$(SELECTOR_RENDERER).on('click', function (e) { | ||
changeRenderer(e.target.value); | ||
}); | ||
|
||
reset(); | ||
} | ||
|
||
function reset() { | ||
var pageURL = getCurrentPageURL(); | ||
resetRendererSelector(pageURL); | ||
enterPage(pageURL, true); // Init page from hash if exists | ||
} | ||
|
||
function render(pagePaths) { | ||
var html = []; | ||
|
||
for (var i = 0; i < pagePaths.length; i++) { | ||
var path = pagePaths[i]; | ||
html.push('<li><a href="' + encodeHTML(path) + '">' + encodeHTML(path) + '</a></li>'); | ||
} | ||
|
||
var caseListContainer = $(SELECTOR_CASES_LIST_CONTAINER); | ||
|
||
caseListContainer[0].innerHTML = html.join(''); | ||
|
||
caseListContainer.on('click', SELECTOR_CASES_ITEM, function (e) { | ||
enterPage(makePageURL( | ||
e.currentTarget.innerHTML, getCurrentRenderer() | ||
)); | ||
return false; | ||
}); | ||
} | ||
|
||
function getCurrentPageURL() { | ||
return decodeURIComponent( | ||
(location.hash || '').replace(/^#/, '') | ||
); | ||
} | ||
|
||
function getCurrentRenderer(pagePath, renderer) { | ||
var renderer; | ||
$(SELECTOR_RENDERER).each(function (index, el) { | ||
if (el.checked) { | ||
renderer = el.value; | ||
} | ||
}); | ||
return renderer; | ||
} | ||
|
||
function changeRenderer(renderer) { | ||
var pageURL = getCurrentPageURL(); | ||
if (pageURL) { | ||
enterPage(replaceRendererOnPageURL(pageURL, renderer)); | ||
} | ||
} | ||
|
||
function makePageURL(pagePath, renderer) { | ||
return pagePath + '?__ECHARTS__DEFAULT__RENDERER__=' + renderer; | ||
} | ||
|
||
function enterPage(pageURL, dontUpdateHash) { | ||
if (!pageURL) { | ||
return; | ||
} | ||
if (!dontUpdateHash) { | ||
location.hash = '#' + encodeURIComponent(pageURL); | ||
} | ||
var contentIframe = $(SELECTOR_CONTENT_IFRAME); | ||
contentIframe.attr('src', pageURL); | ||
} | ||
|
||
function dir() { | ||
return location.origin + resolve(location.pathname, '..'); | ||
} | ||
|
||
function fetchPagePaths(content) { | ||
var pageList = []; | ||
|
||
singleFetch(/"([^"]+\.html)\s*"/g); | ||
singleFetch(/'([^']+\.html)\s*'/g); | ||
|
||
function singleFetch(pattern) { | ||
var result; | ||
while ((result = pattern.exec(content)) != null) { | ||
pageList.push(result[1]); | ||
} | ||
} | ||
|
||
return pageList; | ||
} | ||
|
||
function resetRendererSelector(pageURL) { | ||
var renderer = getRendererFromPageURL(pageURL) || 'canvas'; | ||
|
||
$(SELECTOR_RENDERER).each(function (index, el) { | ||
el.checked = el.value === renderer; | ||
}); | ||
} | ||
|
||
function getRendererFromPageURL(pageURL) { | ||
if (pageURL) { | ||
var matchResult = pageURL.match(/[?&]__ECHARTS__DEFAULT__RENDERER__=(canvas|svg)(&|$)/); | ||
return matchResult && matchResult[1]; | ||
} | ||
} | ||
|
||
function replaceRendererOnPageURL(pageURL, renderer) { | ||
return pageURL.replace(/([?&]__ECHARTS__DEFAULT__RENDERER__=)([^&]*)(&|$)/, '$1' + renderer + '$3'); | ||
} | ||
|
||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.