Accepted answer

The answer is: Yes, it is. Your print method in the components' script could be:

  printChart() {
    var canvasEle = document.getElementById('total_visits_chart_bar');
    var win ='', 'Print', 'height=600,width=800');
    win.document.write("<br><img src='" + canvasEle.toDataURL() + "' />");
    setTimeout(function(){ //giving it 200 milliseconds time to load
    }, 200);  

You can also add this to your component's style:

@media print{
    @page {
        size: landscape


If you are not against using export to pdf format, you can implement this task using jsPDF library, for example:

    <div class="report">
        <charts v-if="todaySelected"
import jsPDF from 'jspdf'; //for PDF printing
methods: {
  pdfThatThing : function(){
      //Default export is a4 paper, portrait, using milimeters for units      
      let pdfName = 'test'; 
      var doc = new jsPDF();
      doc.text("Header", 20, 20); //at x,y at def.units 2cm
      //chart element
      let canvasEle = document.getElementById('total_visits_chart_bar');
      let chartURL = canvasEle.toDataURL(); //transform path 
      //a4 page is 209mm, adds at 4cm top, 2cm left, for 15cm in size      
      doc.addImage(chartURL, 'PNG', 20, 40, 150, 150 ) + '.pdf');

There is also option to auto show print dialog in pdf viewer:

doc.autoPrint({variant: 'non-conform'})


It seems like the library is based on chartjs not canvasjs you might want to look into how to print a window Quick Print HTML5 Canvas, and remember you have access to the canvas element where your graph is drawn:

 methods: {
     printChart() {
        const canvasEle = this.$el.querySelector('canvas');
        //now your chart image is on canvasEle 


vue-chartjs is based on chart.js and not canvas.js, thus it does not have a "build-in" way of printing.

You have to do it with some custom logic and the native javascript printing functions.

You can however grab the canvas element inside your chart component and generate for example an image and then print that image.

It will get a bit tricky, because you only have access to the canvas inside your chart component. So you will need to maybe wait for an event or prop to trigger the toDataURL call and then emit the image to your parent component where you can print it. If you want to trigger the print in your parent component.

methods: {
   print () {
     // grab the canvas and generate an image
     let image = this.$refs.canvas.toDataURL('image/png')
     // Emits an event with the image
     this.$emit('chart:print', image)

In your parent component:

 <your-chart @chart:print="handlePrint"


methods: {
 handlePrint(image) {
   const win ='', 'Print', 'height=600, width=800')
   win.document.write(`<br><img src='${image}' />`)

Related Query

More Query from same tag