Error: Trying to access a property "draw" that is not defined and causing a TypeError

   for (var i = 0; i < reduced.length; i++) {



  var innerdata = [];
  for (var j = 0; j < days.length; j++) {

    var rev = 0;

    _.each(reduced[i].data, function(timerevenueObj) {

      var current = new Date(parseInt(timerevenueObj[0]));
      var daysweek = days[j];

      if (current.toDateString() === daysweek.toDateString()) {
        rev = rev + timerevenueObj[1];
      }



    });

    innerdata.push(rev);


  }




  datasets.push({
    label: reduced[i].label,
    fillColor: "rgba(220,220,220,0.2)",
    strokeColor: "rgba(220,220,220,1)",
    pointColor: "rgba(220,220,220,1)",
    pointStrokeColor: "#fff",
    pointHighlightFill: "#fff",
    pointHighlightStroke: "rgba(220,220,220,1)",
    data: innerdata
  });



 }




 data.push({

    labels: ["May 17","May 18","May 19","May 20","May 21","May 22","May 23","May 24","May 25","May 26","May 27"],
    datasets: datasets

  });

reduced is an array of Objects with the following format:

Channel 1

  CreateTime
  Revenue

  CreateTime
  Revenue

Channel2

 CreateTime
 Revenue

 CreateTime
 Revenue

Format of Data:

I encountered an issue while attempting to showcase a Line Chart

Answer №1

When working with Chartjs, remember to pass an object instead of an array. Use data = {} instead of data.push({}).

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

Keep Dropdown menu open when clicking on a menu item to avoid closing

I'm facing an issue with a drop-down menu in the sidebar that contains links as menu items. Whenever I click on a menu item (link), the link works fine but the drop-down menu closes. What I actually want is for the drop-down menu to stay open even af ...

Managing global HTTP response errors on Vue/axios using Vuex

I've encountered an issue in my VueJS SPA where a strange limbo state occurs. The application fails to recognize that the JWT token has expired, leading it to still display as if the user is logged in. This typically happens after periods of hibernati ...

Coffeescript does not allow setting the AngularJS controller property as the last line of code

Having an issue while using Coffeescript to define a controller with the "HomeController as homeCtrl" syntax. angular.module('myApp.controllers',[]).controller("HomeController", -> @someArray = [] # return ) Encountering a problem ...

Automate the execution of webdriver/selenium tests when a form is submitted

I am currently faced with a challenge in setting up an application that will automate some basic predefined tests to eliminate manual testing from our workflow. The concept is to input a URL via a user-friendly form, which will then execute various tests ...

Constructing a genealogical chart using a collection of items

Currently, I am working on constructing a family tree using an array of objects in JavaScript. This data is retrieved from a MySQL database and accessed through a PHP page. The information is transmitted from PHP to JavaScript in the form of an array of o ...

Is there a way to conceal the toggle division following a postback in ASP.NET?

Here is the script code I am working with: <script type="text/javascript> $(document).ready(function () { var $content = $(".contentPersonalDetail").hide(); $(".togglePersonalDetail").on("click", function (e) { $(this ...

Sending a PHP array through AjaxPassing a PHP array

Here is the array in question: $users = array(); // Loop through results and assign to $users array foreach( $select as $email => $ip ) { $users[$email] = $ip; } I now need to send this array to an AJAX request and display it in another script ...

Using Bootstrap 5 in conjunction with Electron is causing compatibility issues

This is my first venture into creating an electron app and I wanted to add some styling using bootstrap 5. Here's what I did: (1) I used npm i --save bootstrap jquery popper.js to install the necessary modules (2) Created a main.scss file including ...

Guide on integrating next-images with rewrite in next.config.js

I'm currently facing a dilemma with my next.config.js file. I've successfully added a proxy to my requests using rewrite, but now I want to incorporate next-images to load svg files as well. However, I'm unsure of how to combine both functio ...

Ways to display a confirmation message prior to deleting?

When deleting, I would like a confirmation message to appear upon clicking the delete button or image. If the user chooses 'Ok', then the deletion will proceed; however, if 'Cancel' is selected, nothing will happen. I attempted to disp ...

JavaScript: Retrieving the names of children within a <div> element

Within my structure setup, there is a tower div with inner elements like this: <div class="tower"> <div class="E0">abc</div> <div class="GU">123</di </div> The challenge I am facing is that I need to access the in ...

Ways to enhance composability by utilizing React higher-order functions

Referring to the section titled "Convention: Maximizing Composability" in the React tutorial (link: https://reactjs.org/docs/higher-order-components.html#convention-maximizing-composability): // connect is a function that returns another function const enh ...

React router updates the URL without affecting the actual display

I am facing an issue in my React project where the URL changes when clicking a link, but the view does not update. I have a separate route and links file, and I can't seem to figure out the problem. Here is my index.js: import React from 'react ...

Unable to add song to collaborative playlist with Spotify Web Api due to 403 Forbidden error

I have encountered a problem while trying to add songs to a collaborative playlist using the code I have implemented. The button I created works perfectly fine for adding songs to my own playlists, but I receive a 403 forbidden error when attempting to add ...

Is there a way to input text instead of a URL into the Smmry API?

I have a very specific question that I'm not sure anyone can answer, but I'll ask anyway. The Reddit TLDR bot uses the Smmry API to summarize content, and I'm trying to create something similar. However, the documentation only mentions passi ...

Troubleshooting a Node.js server issue with a two-dimensional array

I am currently facing an issue with submitting a form that contains two-dimensional array fields on a post request in node.js. The problem lies in the fact that the server side is receiving a one-dimensional array with all the values combined. Below is an ...

convert webpages and images to PDF with a custom watermark

Looking to convert images fetched from the server into PDF format with a watermark by clicking a button. It would be ideal if there is a plugin that allows for PDF preview with disabled user selection and copy options. The website's platform is Sales ...

Can you explain the distinction between "typeof str" and "typeof(str)" when working with JavaScript?

Can you identify the distinction between these two lines of code? if (typeof errorMessage !== undefined) {} and if (typeof (errorMessage) !== undefined) {} ...

Displaying a carousel of cards with a stacking effect using CSS and React

https://i.sstatic.net/254kG.jpgI am looking to design a layout similar to the image provided, where cards are stacked on top of each other with three dots for toggling. Can anyone guide me on how to achieve this visual effect? ...

Developing a script using Browserify results in generating a file with no content

I recently created a build script with the intention of combining all my JavaScript modules into a single file using browserify. The code I used was inspired by a post I found at . function _browserify(srcPath, distPath) { var browserify = require(&apos ...