-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(charts): Add download button to save charts as png
- Loading branch information
1 parent
dadcefa
commit 3ee43ec
Showing
5 changed files
with
119 additions
and
26 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
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,41 @@ | ||
<template> | ||
<a | ||
:href="link" | ||
:download="name + '.png'" | ||
title="Download as PNG" | ||
class="Chart__download" | ||
> | ||
🖨 | ||
</a> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: 'DownloadButton', | ||
props: { | ||
name: { | ||
type: String, | ||
default: 'chart' | ||
}, | ||
link: { | ||
type: String, | ||
default: '' | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
@import "../assets/styles/_variables.scss"; | ||
.Chart__download { | ||
cursor: pointer; | ||
border: 1px solid #f1f1f1; | ||
border-radius: rem(5); | ||
padding: rem(5); | ||
text-decoration: none; | ||
&:hover { | ||
border-color: color(robin-egg-blue); | ||
} | ||
} | ||
</style> |
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,8 @@ | ||
export default { | ||
methods: { | ||
download () { | ||
let image = this.$refs.canvas.toDataURL('image/png') | ||
this.$emit('generate', image) | ||
} | ||
} | ||
} |
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