vutran6853 / vue3-chart-v2

vue3-chart-v2 is a wrapper for Chart.js in vue 3. You can easily create reuseable chart components. Inspired by vue-chartjs
https://vue3-chart-v2.netlify.app/
38 stars 30 forks source link

**Module parse failed: Unexpected token (92:28) #5

Open tusciati opened 3 years ago

tusciati commented 3 years ago

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch vue3-chart-v2@0.8.1 for the project I'm working on.

There is an expection when i run my solution :

**Module parse failed: Unexpected token (92:28) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders | | // REMOVE OLD DATA FIRST BEFORE UPDATE.

    this.state.chartObj?.data?.datasets.pop()**

Here is the diff that solved my problem:

diff --git a/node_modules/vue3-chart-v2/src/components/BaseChart.js b/node_modules/vue3-chart-v2/src/components/BaseChart.js
index 31055e8..cee2f1a 100644
--- a/node_modules/vue3-chart-v2/src/components/BaseChart.js
+++ b/node_modules/vue3-chart-v2/src/components/BaseChart.js
@@ -89,7 +89,10 @@ function generateChart(chartsId, chartsType) {
         // }

         // REMOVE OLD DATA FIRST BEFORE UPDATE.
-        this.state.chartObj?.data?.datasets.pop()
+        if (this.state.charObj != null && this.state.chartObj.data != null) 
+          this.state.chartObj.data.datasets.pop()
+        
+        //  this.state.chartObj?.data?.datasets.pop()

         let ctx = this.$refs.canvas.getContext('2d')
         this.state.chartObj = new Chart(ctx, {

This issue body was partially generated by patch-package.

tusciati commented 3 years ago

Ok, I will do, Thanks


De : Bobakanoosh @.> Envoyé : mardi 13 avril 2021 03:14 À : vutran6853/vue3-chart-v2 @.> Cc : tusciati @.>; Author @.> Objet : Re: [vutran6853/vue3-chart-v2] **Module parse failed: Unexpected token (92:28) (#5)

@vutran6853https://github.com/vutran6853 Could you please merge the above change into the codebase? It fixed it for me and several others.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/vutran6853/vue3-chart-v2/issues/5#issuecomment-818354990, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AC4BJYRYX36HQVMGLDK3ZZTTIOLINANCNFSM42JD7GPA.