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

cant access dataItem properties in chart.series.notes.label.template

1 Answer 153 Views
Charts
This is a migrated thread and some comments may be shown as answers.
Morten
Top achievements
Rank 2
Iron
Iron
Veteran
Morten asked on 20 Jan 2016, 09:30 PM

after upgrading to "2016.1.118" my code (see below) produce an "Uncaught TypeError: Cannot read property 'date' of undefined" when trying to access dataItem properties in chart.series.notes.label.template:

The code:

var devChart = $("#chart").kendoStockChart({
    theme: "bootstrap",
    dataSource: chartDs,
    dateField: "date",
    series: [{
        type: "line",
        style: "smooth",
        field: "pct",
        noteTextField: "date", // keep, however overruled by label.template
        notes: {
            position: "bottom",
            icon: {
                visible: false
            },
            label: {
                color: "white",
                border: {
                    dashType: "dash"
                },
                background: "#777",
                rotation: -90,
                position: "inside",
                template: "#:kendo.toString(category, 'dd-MMM-yyyy')#" // this code works in "2016.1.118" version
                //template: "#:kendo.toString(dataItem.date, 'dd-MMM-yyyy')#" // this code worked in pre-"2016.1.118" version
            }
        }
    }],
    ...

 

My dataset:

[{"rId":6789,"date":"2015-05-06T12:28:33.643+02:00","max":160.00,"score":140.0,"pct":88.0,"survey":"survey 1"},{"rId":7228,"date":"2015-05-29T11:14:42.047+02:00","max":160.00,"score":150.0,"pct":94.0,"survey":"survey 1"},{"rId":9590,"date":"2015-08-11T13:53:27+02:00","max":160.00,"score":160.0,"pct":100.0,"survey":"survey 1"},{"rId":12770,"date":"2015-10-02T10:53:55+02:00","max":160.00,"score":140.0,"pct":88.0,"survey":"survey 1"},{"rId":14890,"date":"2015-10-28T12:41:27+01:00","max":160.00,"score":140.0,"pct":88.0,"survey":"survey 1"},{"rId":16222,"date":"2015-11-06T13:12:12+01:00","max":365.00,"score":365.0,"pct":100.0,"survey":"survey 2"}]

1 Answer, 1 is accepted

Sort by
0
EZ
Top achievements
Rank 2
answered on 21 Jan 2016, 02:55 PM

It seems like the date in the dataItem is not being parsed properly. You can change your template to

 

template: "#:kendo.toString(kendo.parseDate(dataItem.date), 'dd-MMM-yyyy')#"   

 Even better is to add an explicit schema to the datasource specifying that the field is a date:

dataSource: {
    data: chartDS,
    schema: {
      model: {
          fields: {
              date: {
                  type: "date"
              }
          }
      }
  }

 

Here is a DOJO demo

Tags
Charts
Asked by
Morten
Top achievements
Rank 2
Iron
Iron
Veteran
Answers by
EZ
Top achievements
Rank 2
Share this question
or