Closed benjaminh closed 3 years ago
For the record and anyone facing the same issue, here is how I solve the problem (thanks to mit who guided me in the right direction on stackoverflow : https://stackoverflow.com/questions/65826540/how-to-override-plotly-js-methods-downloadimage-using-vue-plotly-module) :
display-mode-bar
option, I tried to pass a to-image-button-options
prop to Plotly
component<template>
<v-container>
<Plotly
v-if='!loading'
:data.sync="data"
:layout="layout"
:to-image-button-options="toImageButtonOptions"
></Plotly>
</v-container>
</template>
<script>
import { Plotly } from 'vue-plotly';
export default {
components: {
Plotly
},
},
data () {
return {
data: [],
layout: {
autosize: true,
title: "MyTitle",
showlegend: true,
},
toImageButtonOptions: {
format: 'svg',
filename: 'svg_image',
height: 500,
width: 700,
scale: 1
}
loading: false,
};
},
mounted () {
this.loading = true;
this.loadData().then(data => {
this.data = data;
}).catch( (error) => console.log("Error loading data: ", error) );
this.loading = false;
},
methods: {
loadData () {
// Loading my data
},
}
By default, vue-plotly component provides a download button with arbitrary values for the output image, resulting in low quality PNG. Is it possible to override the downloadImage method ? Can someone provide a minimal example on how to do so ?
I tried the following with no success: