【发布时间】:2019-10-10 01:25:30
【问题描述】:
generateLegend() 包装器确实调用了我的 Vue 代码中定义的 legendCallback,但我不知道如何在 vue-chartjs 中呈现自定义 HTML。如here 之类的 vue-chartjs api 文档中所述,我该如何处理 htmlLegend。
这是我尝试使用自定义 HTML 对象呈现的折线图组件。
import { Line, mixins } from 'vue-chartjs'
const { reactiveProp } = mixins
export default {
extends: Line,
mixins: [reactiveProp],
props: ['chartData','options'],
data: () => ({
htmlLegend: null
}),
mounted () {
this.renderChart(this.chartData, this.options);
this.htmlLegend = this.generateLegend();
}
}
这是我的 vue 模板
<template>
<div class="col-8">
<line-chart :chart-data="datacollection" :options="chartOptions"></line-chart>
</div>
</template>
【问题讨论】:
标签: vue-chartjs