我用vue-chartjs绘制一些图表,如线条、条形图等.
在我的项目中,有很多情况是使用图表中数据的特定值或可用值。使用vue-chartjs的工具提示选项,我可以在悬停时检查数据项的值或标签。
我想知道如何访问或获取特定数据的信息,在点击时与图形上的点匹配(而不是悬停)。这是我关于图表选项的代码。
chartOptions: {
responsive: false,
onClick: function(evt){
//Some logic to get value of label of specific data...(type, label, v
我试图使用chartjs-plugin-datalables对特定的图表使用vue-chartjs。因此,首先,我从我的main.js文件中注销了插件,因为它是在导入时在全球注册的。
import Chart from 'chart.js';
import ChartDataLabels from 'chartjs-plugin-datalabels';
Chart.defaults.global.plugins.datalabels.display = false;
然后我要为特定的图表添加插件。但没有任何标签显示。
import { Pie } from
我不知道我做错了什么。我得到以下错误:
控制台中的错误消息:
[Vue warn]: Failed to mount component: template or render function not defined.
found in
---> <VueChartjs>
<Chatjsvue> at src\components\vueChartjs\Chatjsvue.vue
<App> at src\App.vue
<Root>
index.js
import Vue fro
我用vue-chartjs创建了一个Vue.js项目。我尝试重新安装库,但仍然出现以下错误: error in ./node_modules/chart.js/dist/chart.esm.js
Module parse failed: Unexpected token (6613:12)
You may need an appropriate loader to handle this file type.
| if (intermediateIndex1 !== startIndex && intermediateIndex1 !== lastIndex
我安装了vue-chartjs,还添加了chart.js,两者都使用NPM
当我运行npm start时,我的服务器启动了,但在浏览器控制台中,我得到一个错误
TypeError: __WEBPACK_IMPORTED_MODULE_0_vue_chartjs__.Doughnut.extend is not a function
我不确定这是什么意思。我重新安装了所有的包,也使用npm install vue-chartjs安装了这个包。
当我试图使vue-chartjs工作时,我会遇到这个错误。
WARN in ./node_modules/vue-chartjs/es/BaseCharts.js
"export 'default' (imported as 'Chart') was not found in 'chart.js'
在devtools里也是这样的:
TypeError: chart_js__WEBPACK_IMPORTED_MODULE_0__.default is not a constructor
重建步骤:
使用:$ yarn create n
刚刚开始Vue.js和webpack。我正在尝试在我的项目中添加vue-chartjs功能。我收到以下错误:
Uncaught TypeError: _vueChartjs.Line.extend is not a function
at Object.defineProperty.value (..\..\CommodityChart.vue:5)
at __webpack_require__ (bootstrap 7040a42393b737f78245:659)
at fn (bootstrap 7040a42393b737f78245:85)
at Object.<anonymo
在编译我的Vue 2项目后,我得到了这个错误:
Failed to compile.
./node_modules/vue-chartjs/dist/index.js 85:11-26
"export 'defineComponent' was not found in 'vue'
上面文件中导致此行为的行是:
import { defineComponent, shallowRef, ref, watch, onMounted, onBeforeUnmount, toRaw, h, isProxy } from 'vue';
所有这些
我正在尝试将一个名为chartjs- plugin -annotation (https://github.com/chartjs/chartjs-plugin-annotation)的chartjs插件添加到我的vue-chartjs项目中。在我的BarChart.vue文件中,我首先导入了chartjs注解插件 <script>
import { Bar, mixins } from "vue-chartjs";
import chartjsPluginAnnotation from "chartjs-plugin-annotation";
c