• <bdo id='Yjm47'></bdo><ul id='Yjm47'></ul>
      1. <small id='Yjm47'></small><noframes id='Yjm47'>

      2. <legend id='Yjm47'><style id='Yjm47'><dir id='Yjm47'><q id='Yjm47'></q></dir></style></legend><tfoot id='Yjm47'></tfoot>
        <i id='Yjm47'><tr id='Yjm47'><dt id='Yjm47'><q id='Yjm47'><span id='Yjm47'><b id='Yjm47'><form id='Yjm47'><ins id='Yjm47'></ins><ul id='Yjm47'></ul><sub id='Yjm47'></sub></form><legend id='Yjm47'></legend><bdo id='Yjm47'><pre id='Yjm47'><center id='Yjm47'></center></pre></bdo></b><th id='Yjm47'></th></span></q></dt></tr></i><div id='Yjm47'><tfoot id='Yjm47'></tfoot><dl id='Yjm47'><fieldset id='Yjm47'></fieldset></dl></div>

        是否可以使用 vue-chartjs 打印图表?

        Is it possible to print a chart with vue-chartjs?(是否可以使用 vue-chartjs 打印图表?)
      3. <i id='SNcKP'><tr id='SNcKP'><dt id='SNcKP'><q id='SNcKP'><span id='SNcKP'><b id='SNcKP'><form id='SNcKP'><ins id='SNcKP'></ins><ul id='SNcKP'></ul><sub id='SNcKP'></sub></form><legend id='SNcKP'></legend><bdo id='SNcKP'><pre id='SNcKP'><center id='SNcKP'></center></pre></bdo></b><th id='SNcKP'></th></span></q></dt></tr></i><div id='SNcKP'><tfoot id='SNcKP'></tfoot><dl id='SNcKP'><fieldset id='SNcKP'></fieldset></dl></div>

        • <bdo id='SNcKP'></bdo><ul id='SNcKP'></ul>
        • <tfoot id='SNcKP'></tfoot>

          <small id='SNcKP'></small><noframes id='SNcKP'>

            <tbody id='SNcKP'></tbody>

          <legend id='SNcKP'><style id='SNcKP'><dir id='SNcKP'><q id='SNcKP'></q></dir></style></legend>

                  本文介绍了是否可以使用 vue-chartjs 打印图表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在使用 vue-chartjs 在 web 应用程序上呈现图形.我知道如果您使用原始 库,您可以打印图表.但是我不知道如何使用库的 vue 版本来做到这一点.

                  I am using vue-chartjs to render graphs on a webapp. I know you can print charts if you are using the original library. However I have no idea on how to do it with the vue version of the library.

                  我在外部charts.js 文件中有我的图表变量

                  I have my charts variable on an external charts.js file

                  import {Bar, mixins } from 'vue-chartjs'
                  Chart.defaults.global
                  let chartOptions = Chart.defaults.global;   
                  const { reactiveProp } = mixins
                  export default {
                     extends: Bar,
                     mixins: [reactiveProp],
                     props: ['options'],
                  
                     mounted () {
                      let that = this;
                      that.chartOptions = {
                        scales: {
                          yAxes: [{
                              ticks: {
                                  suggestedMin: 0,  
                                  fontFamily: "'Overpass_Mono', 'Monaco', monospace",
                                  fontColor: "rgba(254, 255, 248, 0.5)"
                              },
                              gridLines: {
                                  color: 'rgba(255, 80, 248, 0.08)',
                                  zeroLineColor: 'rgb(168, 119, 181)',
                                   zeroLineWidth: 2
                              },
                          }],
                          xAxes: [{
                              ticks: {
                                  suggestedMin: 0,    
                                   fontColor: "rgb(168, 119, 181)"
                  
                              },
                              gridLines: {
                                  color: 'rgba(255, 80, 248, 0.08)',
                                  zeroLineColor: 'transparent',
                              }
                          }],
                      },
                      legend: {
                          labels: {
                              fontColor: 'rgb(168, 119, 181)',
                          }
                      }
                    },
                      this.renderChart(this.chartData, that.chartOptions)
                    }
                  }
                  

                  然后在我的组件模板上我有:

                  Then on my component template I have:

                  <template>
                      <div class="report">
                          <charts v-if="todaySelected"
                                  :chart-id="'total_visits_chart_bar'" 
                                  :height="chartsHeight" 
                                  :options="chartOptions"
                                  :chart-data="datacollection" 
                          ></charts>
                          <div v-if="todaySelected">
                          <button @click="printChart(charts)">Print chart</button>
                      </div>
                  </template>
                  <script>
                  import charts from './chart_0.js'
                      components: {
                         charts,
                      },
                      data() {
                          return{
                               datacollection: {"datasets":[{"label":"Entries Today","data":[15,15,15,0]},{"label":"Currently Inside","data":[2,2,2,0]}],"labels":[]}
                          }
                       }.
                   methods: {
                       printChart(charts) {
                          charts.print();
                       },
                    }
                  </script>
                  

                  任何帮助将不胜感激.

                  推荐答案

                  答案是:是的.您在组件脚本中的打印方法可能是:

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

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

                  您也可以将其添加到组件的样式中:

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

                  @media print{
                      @page {
                          size: landscape
                          }
                  }
                  

                  这篇关于是否可以使用 vue-chartjs 打印图表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  ChartJS Version 3 - common legend for multiple line charts(ChartJS 版本 3 - 多个折线图的常用图例)
                  Chart.js yAxes Ticks stepSize not working (fiddle)(Chart.js yAxes Ticks stepSize 不起作用(小提琴))
                  How to hide value in Chart JS bar(如何在 Chart JS 栏中隐藏值)
                  Show data values in Chart.js bars (version 3)(在 Chart.js 条形图中显示数据值(版本 3))
                  Chart.js show x-axis data from right to left(Chart.js 从右到左显示 x 轴数据)
                  ChartJS - Finding the minimum and maximum labels that are inside a pan (When zooming)(ChartJS - 查找平底锅内的最小和最大标签(缩放时))
                  1. <small id='bvW40'></small><noframes id='bvW40'>

                      <tbody id='bvW40'></tbody>
                    • <tfoot id='bvW40'></tfoot>
                    • <legend id='bvW40'><style id='bvW40'><dir id='bvW40'><q id='bvW40'></q></dir></style></legend>

                            <bdo id='bvW40'></bdo><ul id='bvW40'></ul>
                            <i id='bvW40'><tr id='bvW40'><dt id='bvW40'><q id='bvW40'><span id='bvW40'><b id='bvW40'><form id='bvW40'><ins id='bvW40'></ins><ul id='bvW40'></ul><sub id='bvW40'></sub></form><legend id='bvW40'></legend><bdo id='bvW40'><pre id='bvW40'><center id='bvW40'></center></pre></bdo></b><th id='bvW40'></th></span></q></dt></tr></i><div id='bvW40'><tfoot id='bvW40'></tfoot><dl id='bvW40'><fieldset id='bvW40'></fieldset></dl></div>