首页 > 解决方案 > 如何始终显示工具提示?我正在使用 vue-chartjs v3.4

问题描述

我需要始终显示工具提示

我尝试 了如何始终在 Chart.js 上显示工具提示 2 我想在饼图中显示标签的值。(vue-chartjs/pieceLabel) 等。

import { Line } from 'vue-chartjs'

export default {
  extends: Line,
  props: {
    linechartData: {
      type: Array | Object,
      required: true
    },
    linechartLabels: {
      type: Array,
      required: true
    }
  },
  data () {
    return {
      options: {
        title: {
          display: true,
          text: 'MONTHLY FEEDBACKS RECEIVED (LAST 12 MONTHS)'
        },
        scales: {
          yAxes: [{
            ticks: {
              beginAtZero: true
            },
            gridLines: {
              display: true
            }
          }],
          xAxes: [{
            gridLines: {
              display: true
            },
            display: false
          }]
        },
        legend: {
          display: false
        },
        responsive: true,
        maintainAspectRatio: false
      }
    }
  },
  mounted () {
    this.renderChart({
      labels: this.linechartLabels,
      datasets: [{
        borderColor: '#027be3',
        pointBackgroundColor: 'rgb(38, 166, 154, 0.5)',
        borderWidth: 1,
        pointBorderColor: '#249EBF',
        backgroundColor: 'rgb(38, 166, 154, 0.5)',
        data: this.linechartData
      }]
    }, this.options)
  }
}

我希望工具提示始终默认显示

标签: vue-chartjs

解决方案


推荐阅读