primevue
Version:
PrimeVue is an open source UI library for Vue featuring a rich set of 80+ components, a theme designer, various theme alternatives such as Material, Bootstrap, Tailwind, premium templates and professional support. In addition, it integrates with PrimeBloc
1 lines • 11 kB
Source Map (JSON)
{"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\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"],"names":["name","BaseComponent","props","type","String","data","options","plugins","width","Number","height","canvasProps","style","ChartStyle","provide","$pcChart","$parentInstance","BaseChart","inheritAttrs","emits","chart","watch","handler","reinit","deep","mounted","initChart","beforeUnmount","destroy","methods","_this","then","module","$refs","canvas","$emit","getCanvas","$canvas","getChart","getBase64Image","toBase64Image","refresh","update","onCanvasClick","event","element","getElementsAtEventForMode","intersect","dataset","originalEvent","generateLegend","_openBlock","_createElementBlock","_mergeProps","_ctx","cx","sx","ptmi","_createElementVNode","ref","onClick","_cache","$event","$options","_objectSpread","ptm","_hoisted_1"],"mappings":";;;;AAIA,eAAe;AACXA,EAAAA,IAAI,EAAE,WAAW;AACjB,EAAA,SAAA,EAASC,aAAa;AACtBC,EAAAA,KAAK,EAAE;AACHC,IAAAA,IAAI,EAAEC,MAAM;AACZC,IAAAA,IAAI,EAAE,IAAI;AACVC,IAAAA,OAAO,EAAE,IAAI;AACbC,IAAAA,OAAO,EAAE,IAAI;AACbC,IAAAA,KAAK,EAAE;AACHL,MAAAA,IAAI,EAAEM,MAAM;MACZ,SAAS,EAAA;KACZ;AACDC,IAAAA,MAAM,EAAE;AACJP,MAAAA,IAAI,EAAEM,MAAM;MACZ,SAAS,EAAA;KACZ;AACDE,IAAAA,WAAW,EAAE;AACTR,MAAAA,IAAI,EAAE,IAAI;MACV,SAAS,EAAA;AACb;GACH;AACDS,EAAAA,KAAK,EAAEC,UAAU;EACjBC,OAAO,EAAA,SAAPA,OAAOA,GAAG;IACN,OAA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