Graph not displaying in Vue-Chartjs

I am currently working on a website project with Laravel and utilizing Vue.js for the front-end management. I am facing an issue where the charts from vue-chartjs are not displaying even though the data is being passed successfully. I have followed the guidelines on their website, but unfortunately, the graph is not showing up. https://i.sstatic.net/RJQHV.png Here is my Vue Component:

<teplate>
    <div>
      ...
    <line-chart :chart-data="datacollection"></line-chart>
    <button @click="fillData()">Randomize</button>
    </div>
</template>

<script>
import Table from '../equipments/table.vue'
import LineChart from '../equipments/LineChart.js'
import DropDownList from '../equipments/dropdownlist.vue'
    export default {
    data () {
      return {
        datacollection: null
      }
    },
        components: {
            LineChart,
            Table,
            DropDownList
        },
    mounted () {
      this.fillData()
    },
    methods: {
      fillData () {
        this.datacollection = {
          labels: ['weqw','wewq'],
          datasets: [
            {
              label: 'Data One',
              backgroundColor: '#f87979',
              data: [this.getRandomInt(), this.getRandomInt()]
            }, 
            {
              label: 'Data One',
              backgroundColor: '#f87979',
              data: [this.getRandomInt(), this.getRandomInt()]
            }
          ]
        }
      },
      getRandomInt () {
        return Math.floor(Math.random() * (50 - 5 + 1)) + 5
      }
    }
  }
</script>

<style>
  .small {
    max-width: 600px;
    margin:  150px auto;
  }
</style>

And here is my Chart.js:

import { Line, mixins } from 'vue-chartjs'
const { reactiveProp } = mixins

export default {
  extends: Line,
  mixins: [reactiveProp],
  props: ['options'],
  mounted () {
    // this.chartData is created in the mixin.
    // If you want to pass options please create a local options object
    this.renderChart(this.chartData, this.options)
  }
}

If anyone can provide some hints or solutions to this issue, I would greatly appreciate it. Thank you in advance.

Answer №1

Vue-chartjs requires version 2.9.4 of chart.js to function properly. Make sure to downgrade your chart.js version if you intend to use Vue-chartjs.

To install, use the command:

npm i <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="5f3c373e2d2b71352c1f6d7166716b">[email protected]</a>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Exploring Discord.js: Sorting a Collection of Retrieved Messages Using .sort()

This is a code example I am working with: .sort((a, b) => b.createdAt - a.createdAt) After fetching and filtering messages from a channel (which has a total of 8 messages), the filter operation returns a collection that may not be sorted in order. Ho ...

Is there a way to submit a form by simply checking a checkbox without causing the page to reload?

I'm in the process of setting up a home automation system using a Raspberry Pi running Raspbian. I plan on creating a web page that will feature checkboxes to control lights through relays. I need help with implementing a checkbox functionality that, ...

What is the method for creating a regex pattern that captures a single symbol under specific conditions?

I am in need of a JavaScript regex that can specifically select a single character with one condition: it must not be followed or preceded by a particular specified character. The target character is /, but I want to select it only if it is not immediatel ...

Error: The property 'condition' is not defined and cannot be read

I've been diving into the world of React and I encountered a roadblock while working on a weather application. Below are snippets from my component and app.js files: import React from 'react' const WeatherCard = (props) => { ret ...

Update the observability status of one observable using a different observable

Upon running the following code, you'll notice that an xhr request is being sent to the console regardless of whether I am subscribed to the subject or not. I would prefer for these requests not to be made if I am not subscribed. // To start, install ...

Having trouble with using the addEventListener method (resize) in VueJS CLI to capture screen width?

I am trying to generate two different HTML codes for two different screen sizes using VueJS. I attempted to use addEventListener to constantly monitor the screen width, but I'm facing some challenges with it. Can anyone provide assistance? Below is m ...

Seamless Integration of Hosted Fields by Braintree

I am currently struggling with setting up Braintree hosted fields on my registration form. Unfortunately, there are significant gaps between the fields which doesn't look appealing. Despite referring to the braintree documentation and guides, I find t ...

The call stack in mongodb has surpassed its maximum size limit

I am currently executing a method. Method execution var message = "Hello" function1("78945612387", message, null, "Portalsms") Node JS Code function function1(mobileno,body,logExtraInfo,messageType){ request(uri, function (error, resp ...

When a project sets useBuiltIns to 'usage', there is an issue with importing the library generated by Webpack

I am eager to create a versatile UI component library and bundle it with Webpack. However, I encountered an issue when trying to import it into another project that has useBuiltIns: 'usage' specified in the babelrc file. The import fails with the ...

Could it be possible that my understanding of hoverIntent is incorrect?

I have a div that holds a series of li elements to construct a menu. Adjacent to the container ul, there is another div intended to appear only when an item in the original menu is hovered over. While I grasp the concept of mouseout and mouseover effects ...

Every time I try to utilize "useCallback," it results in a TypeError error popping up

I am struggling with an issue related to a const experience that involves creating 6 experiences with their respective popovers. I have been instructed to use useCallback, but every time I attempt to do so, I encounter an error message. This relates to my ...

Obtaining the response object for the web browser

Greetings! I currently have a function within router.js in NODEJS : const authenticateUser = (req, res, next) => { //something }; Whenever my application is live, this function is triggered. I am looking for a way to examine the response object. Is ...

Execute index.js code from index.html using NodeJS and Express

Currently, I am diving into the world of NodeJS and Express using Replit.com for a small project. The main objective is to develop a basic input field that, upon submission, will post to different channels such as Discord and Twitter. The piece of code be ...

What are the best ways to gather value using javascript?

My Javascript array looks something like this below: [ { "id": 1, "facilities": [ { "id": 10, "name": "Wifi", "label": "Wifi" }, { "id": 12, "name": "Toll", "label": "Toll" ...

Scrolling horizontally with visible vertical overflow is causing the contents of an absolutely positioned div to be hidden

Note: I have thoroughly searched related questions on stackoverflow and this is not a duplicate question. In my code, I have a `div` with `overflow-x: scroll`, but I want the content in the `div` to be visible in the `y` direction. The issue I'm faci ...

Code has been loaded successfully for react-loadable Chunks, however it has not been

Encountering a problem while trying to implement chunks in my React app using react-loadable Everything functions perfectly on webpack-dev-server in development mode. However, when I build the project and deploy it to the server, async components are ...

Making an Angular 6 HTTP GET call using HTTP-Basic authentication

When attempting to access a URL that requires Basic Authentication, and returns JSON data, what is the proper way to include my username and password in the following HTTP request? private postsURL = "https://jsonExample/posts"; getPosts(): Observable& ...

Retrieve user input from an HTML form and pass it as a parameter in a jQuery AJAX request

Is there a way to pass a value from a user input in an HTML file to jQuery.ajax? Take a look at the code snippet from my JS file: jQuery(document).ready(function() { jQuery.ajax({ type: 'POST', url: 'myurl.asp ...

Prevent JSON.parse() function from stripping away any trailing zeros in a JSON string dataset

After creating a JSON string, I encountered an issue where the values were not being parsed correctly. Here is the code snippet: <script> var string = JSON.parse('{"items":[{"data":[5.1]}, {"values":[5.10]}, {"offer":[3.100]}, {"grandtotal":[12 ...

Checking for any lint errors in all JavaScript files within the project package using JSHint

Currently, I am utilizing the gulp task runner to streamline my workflow. My goal is to implement JsHint for static code analysis. However, I have encountered a setback where I can only run one file at a time. Upon npm installation, "gulp-jshint": "~1.11. ...