如何防止ChartJS出现标签截断?

时间:2019-05-17 12:56:54

标签: vue.js chart.js

我使用chartjs和clivuejs生成了一个甜甜圈图。 我的问题是取决于图表,外部标签是否可以截断。

使用“检查” chrome模式,我尝试修改画布和不同父div的宽度/高度。

//../src/DoughnutChart.js

import {
    Doughnut,mixins
} from 'vue-chartjs'

export default {
  extends: Doughnut,
    mixins: [mixins.reactiveProp],
    props: ['chartData'],
    data() {
        return {
            options: {
                tooltips: {
                  enabled: true
                },
                pieceLabel: {
                  render: 'label',
                  arc: true,
                  fontColor: '#000',
                  position: 'inside'
                },
                responsive: true,
                legend: {
                  display: false,
                  position: 'top',
                },
                scaleLabel : {
                    display: true
                  },
                maintainAspectRatio: false
            }
        }
    },
    mounted() {
        this.renderChart(this.chartdata, this.options)
    }

}

正如您在附件上看到的那样,外部标签完全不可见或被截断。

enter image description here

编辑: 现在使用Daniel提供的填充建议(感谢Daniel)。如果图表很小的话,我仍然有问题。是否有任何方法可以迫使标签在父画布的基础上具有更智能的位置? enter image description here

0 个答案:

没有答案