1 line
11 KiB
Plaintext
1 line
11 KiB
Plaintext
|
|
{"version":3,"file":"index.mjs","sources":["../../src/chart/BaseChart.vue","../../src/chart/Chart.vue","../../src/chart/Chart.vue?vue&type=template&id=f9908118&lang.js"],"sourcesContent":["<script>\nimport BaseComponent from '@primevue/core/basecomponent';\nimport ChartStyle from 'primevue/chart/style';\n\nexport default {\n name: 'BaseChart',\n extends: BaseComponent,\n props: {\n type: String,\n data: null,\n options: null,\n plugins: null,\n width: {\n type: Number,\n default: 300\n },\n height: {\n type: Number,\n default: 150\n },\n canvasProps: {\n type: null,\n default: null\n }\n },\n style: ChartStyle,\n provide() {\n return {\n $pcChart: this,\n $parentInstance: this\n };\n }\n};\n</script>\n","<template>\n <div :class=\"cx('root')\" :style=\"sx('root')\" v-bind=\"ptmi('root')\">\n <canvas ref=\"canvas\" :width=\"width\" :height=\"height\" @click=\"onCanvasClick($event)\" v-bind=\"{ ...canvasProps, ...ptm('canvas') }\"></canvas>\n </div>\n</template>\n\n<script>\nimport BaseChart from './BaseChart.vue';\n\nexport default {\n name: 'Chart',\n extends: BaseChart,\n inheritAttrs: false,\n emits: ['select', 'loaded'],\n chart: null,\n watch: {\n /*\n * Use deep watch to enable triggering watch for changes within structure\n * otherwise the entire data object needs to be replaced to trigger watch\n */\n data: {\n handler() {\n this.reinit();\n },\n deep: true\n },\n type() {\n this.reinit();\n },\n options() {\n this.reinit();\n }\n },\n mounted() {\n this.initChart();\n },\n beforeUnmount() {\n if (this.chart) {\n this.chart.destroy();\n this.chart = null;\n }\n },\n methods: {\n initChart() {\n import('chart.js/auto').then((module) => {\n if (this.chart) {\n this.chart.destroy();\n this.chart = null;\n }\n\n if (module && module.default) {\n this.chart = new module.default(this.$refs.canvas, {\n type: this.type,\n data: this.data,\n options: this.options,\n plugins: this.plugins\n });\n }\n\n this.$emit('loaded', this.chart);\n });\n },\n getCanvas() {\n return this.$canvas;\n },\n getChart() {\n return this.chart;\n },\n getBase64Image() {\n return this.chart.toBase64Image();\n },\n refresh() {\n if (this.chart) {\n this.chart.update();\n }\n },\n reinit() {\n this.initChart();\n },\n onCanvasClick(event) {\n if (this.chart) {\n const element = this.chart.getElementsAtEventForMode(event, 'nearest', { intersect: true }, false);\n const dataset = this.chart.getElementsAtEventForMode(event, 'dataset', { intersect: true }, false);\n\n if (element && element[0] && dataset) {\n this.$emit('select', { originalEvent: event, element: element[0], dataset: dataset });\n }\n }\n },\n generateLegend() {\n if (this.chart) {\n return this.chart.generateLegend();\n }\n }\n }\n};\n</script>\n","<template>\n <div :class=\"cx('root')\" :style=\"sx('root')\" v-bind=\"ptmi('root')\">\n <canvas ref=\"canvas\" :width=\"width\" :height=\"height\" @click=\"onCanvasClick($event)\" v-bind=\"{ ...canvasProps, ...ptm('canvas') }\"></canvas>\n </div>\n</template>\n\n<script>\nimport BaseChart from './BaseChart.vue';\n\nex
|