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

e.DataItem in click event returns Undefined when using Date Series Chart

3 Answers 137 Views
Charts
This is a migrated thread and some comments may be shown as answers.
Supriya
Top achievements
Rank 1
Supriya asked on 19 Nov 2013, 06:27 PM

code sample below.

<link href="/Content/kendo.common.min.css" rel="stylesheet"/>
<link href="/Content/kendo.dataviz.min.css" rel="stylesheet"/>
<link href="/Content/kendo.default.min.css" rel="stylesheet"/>
  
<script src="/Scripts/jquery-1.8.2.js"></script>
<script src="/Scripts/kendo.all.min.js"></script>
<script src="/Scripts/kendo.aspnetmvc.min.js"></script>
  
<div id="chart" style="width: 350px; height: 250px;"></div>
<script type="text/javascript">
    var salesData = [{
        DOB: new Date("2011/11/1"),
        EmployeeID: 1,
        sales1: 2000
    }, {
        DOB:new Date("2011/11/2"),
        EmployeeID: 2,
        sales1: 2250
    }, {
        DOB: new Date("2011/11/3"),
        EmployeeID: 3,
        sales1: 1550
    }]
  
    $(document).ready(function () {
        $("#chart").kendoChart({
            title: {
                text: "Employee Sales"
            },
            dataSource: {
                data: salesData
            },
            series: [{
                type: "column",
                field: "sales1",
                name: "Sales in Units"
            }],
            categoryAxis: {
                field: "DOB"
            },
            tooltip: {
                visible: true,
                format: "{0}"
            },
            seriesClick: onSeriesClick
        });
    });
  
  
    function onSeriesClick(e) {
        //console.log(e);
        alert("Employee ID is: " + e.dataItem.EmployeeID);
    }
        </script>

if I change the code to below it works
Note The data fields are changed to string
<script type="text/javascript">
    var salesData = [{
        DOB: "2011/11/1",
        EmployeeID: 1,
        sales1: 2000
    }, {
        DOB:"2011/11/2",
        EmployeeID: 2,
        sales1: 2250
    }, {
        DOB: "2011/11/3",
        EmployeeID: 3,
        sales1: 1550
    }]
  
    $(document).ready(function () {
        $("#chart").kendoChart({
            title: {
                text: "Employee Sales"
            },
            dataSource: {
                data: salesData
            },
            series: [{
                type: "column",
                field: "sales1",
                name: "Sales in Units"
            }],
            categoryAxis: {
                field: "DOB"
            },
            tooltip: {
                visible: true,
                format: "{0}"
            },
            seriesClick: onSeriesClick
        });
    });
  
  
    function onSeriesClick(e) {
        //console.log(e);
        alert("Employee ID is: " + e.dataItem.EmployeeID);
    }
        </script>

3 Answers, 1 is accepted

Sort by
0
Supriya
Top achievements
Rank 1
answered on 19 Nov 2013, 07:46 PM
Further review indicated that this issue was only with the library version 2013.2.918
If I switched to version 2013.1.514 it worked fine

http://jsbin.com/IVUHUcUt/1/ using version 2013.1.514
http://jsbin.com/IjuTaWO/1/ using version 2013.2.918
0
Supriya
Top achievements
Rank 1
answered on 19 Nov 2013, 09:33 PM
seems like there is an issue   dataviz.min.js

see http://jsbin.com/iXAWatoB/1/edit

if you use <script src="http://cdn.kendostatic.com/2013.1.514/js/kendo.dataviz.min.js "></script> and click on the graph the alert displays the correct JSON object

if you use <script src="http://cdn.kendostatic.com/2013.2.918/js/kendo.dataviz.min.js "></script> and click on the graph the JSON object contents are incomplete.

0
Iliana Nikolova
Telerik team
answered on 20 Nov 2013, 01:37 PM
Hi Supriya,

I already replied to the same question in your support ticket, however I am pasting my reply here too:

There is an issue in Kendo UI version 2013.2.918 and it is not possible to reach the original data through the dataItem when dates are used. The good news is that our developers have managed to address it and the fix is included in Kendo UI Q3 2013 official release (which is already available for downloading from your account). Please test your application using the latest version of the product and let me know if you still observe any problems.

Regards,
Iliana Nikolova
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Charts
Asked by
Supriya
Top achievements
Rank 1
Answers by
Supriya
Top achievements
Rank 1
Iliana Nikolova
Telerik team
Share this question
or