This is a migrated thread and some comments may be shown as answers.

TypeError: Cannot read property 'getTime' of undefined

6 Answers 814 Views
This is a migrated thread and some comments may be shown as answers.
Rich
Top achievements
Rank 1
Rich asked on 25 Sep 2018, 10:38 PM

In my chart I am binding two series. On create of my component I build the series and bind to the kendo ui chart component. The series look like [{Price:xxxx, DateTime:xxxx}, {Price:xxxx, DateTime:xxxx}, {Price:xxxx, DateTime:xxxx} .... etc] . I set the series data by setting the chartSeries.data property. The chart displays correctly but I get this error:

TypeError: Cannot read property 'getTime' of undefined

 

6 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 27 Sep 2018, 10:53 AM
Hello Rich,

In general, categorical series such as Bar, Line, Area and other Kendo UI Charts, have built-in support for displaying dates that include:

  • Automatic selection of granularity/base unit (minutes, hours, days, etc.).

  • Label formatting matched to the granularity.

  • Grouping of categories into base units and series aggregates.

Refer to the following Chart Demo, where working with dates is demonstrated:


I would suggest to use similar approach for configuring the Chart component. With it, no JavaScript error is being thrown in the browser console and the component is being successfully rendered.

Regards,
Dimitar
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Rich
Top achievements
Rank 1
answered on 01 Oct 2018, 07:52 PM

Hi Dimitar, thanks for the response.

I am trying to avoid additional data transformation wherever possible. From what I can tell from the documentation what I am doing should be working without error. I don't see an example doing exactly what I am doing but unfortunately there is no example of binding multiple series without passing a category array of value to the categoryaxis prop.

In my case each point in the series hold both the value and the data. [{Price:xxxx, DateTime:xxxx}, {Price:xxxx, DateTime:xxxx}, {Price:xxxx, DateTime:xxxx} .... etc] I am not setting the dates in the category axis. I have a computed property that is bound to the :series prop of the chart:

series() {
      let chartSeries = [];
      this.itemPrices.forEach(commodSeriesData => {
        chartSeries.push({
          type: "line",
          data: commodSeriesData,
          field: "Price",
          categoryField: "DateTime",
          categoryAxis: "DateTime",
          style: "normal",
          markers: { visible: false },
          labels: { visible: false }
        });
      });
      return chartSeries;
    }

 

Formatting in this message is difficult to use. Sorry I'll have to continue inside the code formatting :) Anyway, can you see anything that would be causing issue? On top of the "getTime" error the series I am still experiencing the series does not seem to be reactively bound to the chart. I have to redraw the chart to see the changes.

 

0
Ivan Danchev
Telerik team
answered on 03 Oct 2018, 01:49 PM
Hi Rich,

Could you post a stackblitz example that demonstrates the chart configuration, the date it is populated with and the exception you are getting?

Regards,
Ivan Danchev
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Rich
Top achievements
Rank 1
answered on 03 Oct 2018, 02:25 PM
Hi Ivan, the issue was caused by an oversight on my part. I was originally binding to the :data-source prop and switched to the :series prop binding. I had accidentally left the :data-source prop bound in the template. It appears as though the series was binding first and then the kendo exception would fire as it tried to bind the data-source. Once I realized the data-source prop was still in the template I removed it and everything is working as it should.  Thanks for your help!
0
Lee
Top achievements
Rank 2
Bronze
Bronze
Bronze
answered on 13 May 2020, 05:38 PM
The link above goes to a 404 page.
0
Ivan Danchev
Telerik team
answered on 15 May 2020, 02:24 PM

Hello,

Here's a valid link: Date Axes.

Regards,
Ivan Danchev
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Asked by
Rich
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Rich
Top achievements
Rank 1
Ivan Danchev
Telerik team
Lee
Top achievements
Rank 2
Bronze
Bronze
Bronze
Share this question
or