-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Save as PNG --------- Co-authored-by: jrobinso <933148+jrobinso@users.noreply.github.com>
- Loading branch information
Showing
5 changed files
with
140 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
|
||
<title>PNG Output Demo</title> | ||
|
||
|
||
</head> | ||
|
||
<body> | ||
|
||
<div> | ||
<div id='app-container'></div> | ||
</div> | ||
|
||
<div> | ||
<button id='igv-save-as-png-button' type="button"> | ||
<label>Save As PNG</label> | ||
</button> | ||
</div> | ||
|
||
<div id="igv-svg-container"> | ||
</div> | ||
|
||
</body> | ||
|
||
<script type="module"> | ||
|
||
// import igv from '../../js/index.js' | ||
import igv from '../../dist/igv.esm.js' | ||
|
||
const bedgraph_options = { | ||
locus: '19:49301000-49305700', | ||
genome: "hg19", | ||
tracks: [ | ||
{ | ||
name: 'All negative points', | ||
url: '../../test/data/wig/allNegativewig.bedgraph', | ||
indexed: false, | ||
graphType: "points", | ||
guideLines: | ||
[ | ||
{dotted: true, y: 0, color: "green"}, | ||
{dotted: true, y: -0.25, color: "blue"}, | ||
{dotted: true, y: -0.5, color: "red"} | ||
] | ||
}, | ||
{ | ||
name: 'All negative bars', | ||
url: '../../test/data/wig/allNegativewig.bedgraph', | ||
indexed: false | ||
}, | ||
{ | ||
name: 'Mixed_pos_neg_points', | ||
url: '../../test/data/wig/mixedPosNeg.bedgraph', | ||
indexed: false, | ||
graphType: "points", | ||
guideLines: | ||
[ | ||
{dotted: true, y: 0, color: "green"}, | ||
{dotted: true, y: -0.5, color: "blue"}, | ||
{dotted: true, y: 0.5, color: "red"} | ||
] | ||
}, | ||
{ | ||
name: 'Mixed pos neg bars', | ||
url: '../../test/data/wig/mixedPosNeg.bedgraph', | ||
indexed: false | ||
}, | ||
{ | ||
name: 'All pos points', | ||
url: '../../test/data/wig/allPositive.bedgraph', | ||
indexed: false, | ||
graphType: "points", | ||
guideLines: | ||
[ | ||
{dotted: true, y: 0, color: "green"}, | ||
{dotted: true, y: 0.25, color: "blue"}, | ||
{dotted: true, y: 0.5, color: "red"} | ||
] | ||
}, | ||
{ | ||
name: 'All pos bars', | ||
url: '../../test/data/wig/allPositive.bedgraph', | ||
indexed: false | ||
} | ||
] | ||
}; | ||
|
||
|
||
igv.createBrowser(document.getElementById('app-container'), bedgraph_options) | ||
.then(browser => { | ||
console.log(`${ browser.guid } is good to go`) | ||
|
||
document.querySelector('#igv-save-as-png-button').addEventListener('click', () => { | ||
browser.savePNGtoFile(`igvjs-screendump-${ browser.guid }.png`) | ||
}) | ||
|
||
}) | ||
|
||
</script> | ||
</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
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,23 @@ | ||
/* | ||
* Workaround for nodes archaic insistence that es modules have ".mjs" extensions or have "type=module" in package.json. | ||
* This script will insert "type": "module" into the package.json of listed modules* | ||
*/ | ||
|
||
const fs = require('fs') | ||
|
||
const packages = ['html2canvas'] | ||
|
||
for (let p of packages) { | ||
forceESM(p) | ||
} | ||
function forceESM(packageName) { | ||
|
||
const packageJSON = require(`../../node_modules/${packageName}/package.json`) | ||
packageJSON['type'] = 'module' | ||
|
||
const outputFile = require.resolve(`../../node_modules/${packageName}/package.json`) | ||
fs.writeFileSync(outputFile, JSON.stringify(packageJSON, null, 2)) | ||
|
||
|
||
} | ||
|
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