Skip to content

Commit

Permalink
wip: download
Browse files Browse the repository at this point in the history
  • Loading branch information
Gurrium committed Sep 14, 2022
1 parent 5f7509c commit 54ebb9d
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,15 +294,23 @@ function download() {
chart.resize(exportImageWidth, exportImageHeight)
}

var outputFileName = 'elevation.png'
var baseOutputFileName = 'elevation'

const inputFile = fileInput.files[0]
if (inputFile != null && inputFile.name.split('.').length > 1) {
outputFileName = inputFile.name.split('.').slice(0, -1).join() + '-' + outputFileName
baseOutputFileName = inputFile.name.split('.').slice(0, -1).join() + '-' + baseOutputFileName
}

hiddenDownloadLink.href = chart.toBase64Image()
hiddenDownloadLink.download = outputFileName
hiddenDownloadLink.click()
if (splitPoints.length > 0) {
// TODO: 表示されている最小値からsplitPoint刻みでダウンロードする
splitPoints.forEach(splitPoint => {
baseOutputFileName += `-${splitPoint}.png`
})
} else {
hiddenDownloadLink.href = chart.toBase64Image()
hiddenDownloadLink.download = baseOutputFileName + '.png'
hiddenDownloadLink.click()
}

chart.resize()
}
Expand Down

0 comments on commit 54ebb9d

Please sign in to comment.