Download DOWNLOAD.zip and click *.html file(in DOWNLOAD.zip) to open this demo in local browser!.
For .png DOWNLOAD module, we need first to create a button with the code following.
<div class="svg-box img-container">
<button class="svg-action-btn download-img">Download png ↓</button>
If you are not familiar with the html language, don’t worry, normally you don’t need to change this code block, just add this to your website.
The <div> tag here is to set the button position, you can add this code block up or below the main picture.
For .svg DOWNLOAD module, we need first to create a button with the code following.
<a href="javascript:(function () { var e = document.createElement('script');if (window.location.protocol === 'https:') { e.setAttribute('src', '../lib/svg-crowbar.js'); } else { e.setAttribute('src', '../lib/svg-crowbar.js'); } e.setAttribute('class', 'svg-crowbar'); document.body.appendChild(e); })();" class="DownButtonNormal" >Download svg ↓</a>
If you are not familiar with the html language, don’t worry, normally you don’t need to change this code block, just add this to your website.
The <a> tag here is to set the button position, you can add this code block up or below the main picture.
Add the code block below after the </script> tag of main picture and before the </body> tag:
<script src=../lib/saveSvgAsPng.js></script>
<script>
(function(){
var downloadImg = getEle(".download-img"),
imgName = getEle("."+NGCircos01.svgClassName);
// imgScale = getEle(".img-scale");
downloadImg.addEventListener("click",function(){
var mySvg = getEle("."+NGCircos01.svgClassName),
//iImgScale = parseInt(imgScale.value) || 1,
oImgName = imgName.value || NGCircos01.svgClassName;
// saveSvgAsPng(mySvg, oImgName+".png", iImgScale);
saveSvgAsPng(mySvg, oImgName+".png");
})
function getEle(obj){
var d = document;
return d.querySelector(obj);
}
})()
</script>
Actually, the DOWNLOAD module has already been working after this 2 steps, we still provide the third step for customizing button style.
You may notice both in the code block of .png and .svg DOWNLOAD module, we set a class for both button, which is DownButtonNormal.
You can freely customize these 2 buttons by the <style></style> tag as following:
<style>
.DownButtonNormal{
height: 18px;
line-height: 18px;
padding: 0 11px;
background: #FFFFFF;
border: 1px #D9D9D9 solid;
border-radius: 3px;
display: inline-block;
font-size: 12px;
outline: none;
}
</style>
Please add this before the <body> tag and after the </head> tag in your website.
Download svg ↓