Utilizing Angular to Bind Data Visualization Charts Locally

I am attempting to use the Kendo UI Angular directives to bind a DataViz pie chart locally, but I am encountering an error that says:

TypeError: Cannot call method 'toLowerCase' of undefined
    at h (http://localhost:51717/Scripts/kendo/kendo.dataviz.min.js:11:5351)
    at Object.o.aggregate (http://localhost:51717/Scripts/kendo/kendo.dataviz.min.js:11:20999)
    at g (http://localhost:51717/Scripts/kendo/kendo.dataviz.min.js:11:5624)
    at ct.extend._process (http://localhost:51717/Scripts/kendo/kendo.dataviz.min.js:11:31624)
    at ct.extend.success (http://localhost:51717/Scripts/kendo/kendo.dataviz.min.js:11:28852)
    at Object.proxy [as success] (http://localhost:51717/Scripts/jquery-1.10.2.js:841:14)
    at ct.extend.read (http://localhost:51717/Scripts/kendo/kendo.web.min.js:11:21673)
    at http://localhost:51717/Scripts/kendo/kendo.dataviz.min.js:11:28381
    at ct.extend._queueRequest (http://localhost:51717/Scripts/kendo/kendo.dataviz.min.js:11:30001)
    at ct.extend.read (http://localhost:51717/Scripts/kendo/kendo.dataviz.min.js:11:28266) 

HTML

<div kendo-chart k-options="pie" k-data-source="countries" />

Angular

$scope.countries = {
    data: [
        {
            category: "Asia",
            value: 53.8,
            color: "#9de219"
        }, {
            category: "Europe",
            value: 16.1,
            color: "#90cc38"
        }, {
            category: "Latin America",
            value: 11.3,
            color: "#068c35"
        }, {
            category: "Africa",
            value: 9.6,
            color: "#006634"
        }, {
            category: "Middle East",
            value: 5.2,
            color: "#004d38"
        }, {
            category: "North America",
            value: 3.6,
            color: "#033939"
        }
    ]
};

$scope.pie = {
    title: {
        position: "bottom",
        text: "Share of Internet Population Growth, 2007 - 2012"
    },
    legend: {
        visible: false
    },
    chartArea: {
        background: ""
    },
    seriesDefaults: {
        labels: {
            visible: true,
            background: "transparent",
            template: "#= category #: #= value#%"
        }
    },
    series: [{
        type: "pie",
        field: "value",
        categoryField: "category"
    }],
    tooltip: {
        visible: true,
        format: "{0}%"
    }
};

Answer №1

Make sure to check your libraries for compatibility with supported versions. It's important to use the latest version of KendoUI. As stated in the KendoUI->Angular GitHub repository, the required versions are:

  • jQuery v1.9.1 (uncertain if later versions are supported)
  • Angular v1.0.5
  • KendoUI vCurrent

A functional example has been provided on JSBin for your reference. Here's the code snippet:

<!DOCTYPE html>
<html>
<head>
<meta name="description" content="Angular + KendoUI DataViz" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.min.js"></script>
<script src="http://cdn.kendostatic.com/2013.3.1119/js/kendo.all.min.js"></script>
<script src="http://rawgithub.com/kendo-labs/angular-kendo/master/build/angular-kendo.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body ng-app="chart-example">
  <div ng-controller="ChartController">    
    <div kendo-chart k-options="pie" k-data-source="countries" />
  </div>
</body>
</html>

...

var app = angular.module('chart-example', ['kendo.directives']);

function ChartController($scope) {
  $scope.pie = {
    title: {
        position: "bottom",
        text: "Share of Internet Population Growth, 2007 - 2012"
    },
    legend: {
        visible: false
    },
    chartArea: {
        background: ""
    },
    seriesDefaults: {
        labels: {
            visible: true,
            background: "transparent",
            template: "#= category #: #= value#%"
        }
    },
    series: [{
        type: "pie",
        field: "value",
        categoryField: "category"
    }],
    tooltip: {
        visible: true,
        format: "{0}%"
    }
  };

  $scope.countries = {
    data: [
        {
            category: "Asia",
            value: 53.8,
            color: "#9de219"
        }, {
            category: "Europe",
            value: 16.1,
            color: "#90cc38"
        }, {
            category: "Latin America",
            value: 11.3,
            color: "#068c35"
        }, {
            category: "Africa",
            value: 9.6,
            color: "#006634"
        }, {
            category: "Middle East",
            value: 5.2,
            color: "#004d38"
        }, {
            category: "North America",
            value: 3.6,
            color: "#033939"
        }
    ]
  };
}

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

What is the best way to incorporate variables into strings using JavaScript?

Can someone help me achieve the following task: var positionX = 400px; $(".element").css("transform", "translate(0, positionX)"); Your assistance is greatly appreciated! ...

The parameter value experiences an abrupt and immediate transformation

I recently created an electron app using Node.js and encountered a peculiar issue that I am unable to resolve: Below is the object that I passed as input: { lessons: [ name: "math", scores: [90, 96, 76], isEmpty: false ] } ...

"Encountering a UI grid 400 error while using Chrome Dev Tools to load an image in the Cell

Looking for help with a problem - can anyone assist? When loading this in Chrome Dev Tools, a 400 error (Bad Request) is displayed. Check out the issue here The issue seems to occur when using row.entity.imgurl inside the cellTemplate. angular.module(&ap ...

Ways to substitute a single parameter within Vue.js router

We are working on a complex multi-level multi-tenant application, where the hostname is used to identify the 'supplier' account and the customer account is included in the URL structure. For example, our routes are structured like this: /:local ...

Customizing the display field in an ExtJs Combobox

I am working on a java web application that utilizes an entity class to populate a combobox with ExtJs. The issue I am facing is as follows: Some entries in the displayField may contain html code. To prevent any issues, I used flexjson.HTMLEncoder during ...

Receiving "this" as an undefined value within the TypeScript class

Currently developing a rest api using express.js, typescript, and typeorm. Initially thought the issue was with AppDataSource, but it seems to be functioning properly. Below is my controller class: import { RequestWithBody } from '@utils/types/reque ...

Updating backgroundPosition for dual background images within an HTML element using Javascript

Issue at Hand: I am currently facing a challenge with two background images positioned on the body tag; one floating left and the other right. The image on the left has a padding of 50px on the left side, while the image on the right has a padding of 50px ...

Understanding the concept of hoisting in JavaScript for global variables and functions

I've been curious about hoisting. I understand that if a global function shares the same name as a global variable, the function will overwrite the variable's name. Is this correct? Here is an example code snippet. (function() { console.log ...

Combine the object with TypeScript

Within my Angular application, the data is structured as follows: forEachArrayOne = [ { id: 1, name: "userOne" }, { id: 2, name: "userTwo" }, { id: 3, name: "userThree" } ] forEachArrayTwo = [ { id: 1, name: "userFour" }, { id: ...

Using Node.JS, Sequelize, and Moment.JS to format dates

Seeking help on formatting a date loaded from Sequelize in my database. I'm working on a blog and need to display the creation date of an article. Here's my route: app.get("/", (req,res) =>{ Article.findAll({ order:[ [ ...

For the past two days, there has been an ongoing issue that I just can't seem to figure out when running npm start

After multiple failed attempts, I have exhausted all troubleshooting steps including executing npm clear cache --force, deleting node_modules/ and package-lock.json, followed by running npm install, npm build, and eventually npm run dev. The errors encoun ...

Encountering an issue with WebDriver in the realm of JavaScript

I am struggling to use JavaScript to locate specific controls and send values to them. One example is changing the text in a textbox with the ID "ID" to "123456". Below is the code I tried: ((IJavaScriptExecutor)driver).ExecuteScript("document.getElement ...

Utilizing Typescript for manipulation of Javascript objects

Currently, I am working on a project using Node.js. Within one of my JavaScript files, I have the following object: function Person { this.name = 'Peter', this.lastname = 'Cesar', this.age = 23 } I am trying to create an instanc ...

encountering a type mismatch error while trying to retrieve data from an array

While attempting to retrieve data from a nested array, I encountered the error "TypeError: Cannot read property 'value' of undefined". It seems like I might be calling back incorrectly as I am receiving both the output and the error message in th ...

Arrange a JavaScript map based on its values and ensure that a specific field index remains at the top position

I'm sure this question may seem simple to some, but as a JavaScript novice, I couldn't find the answer myself. Here is the code snippet I'm working with: Let map = new Map<String,String> map.set('0', select) map.set('1&a ...

Continuously improving the form as they evolve

I am interested in creating a form that automatically sends data when users make changes to it. For instance: Imagine a scenario where a moderator is editing an article and changes values in a select field. As soon as the change is made, an ajax request ...

Error in React UseTable: Attempting to read properties of an undefined object (specifically trying to use a forEach loop)

https://i.stack.imgur.com/ZSLSN.pngHaving an issue here that I need some quick help with! Whenever I attempt to render data into a React table, I encounter the error mentioned above. The data is fetched from an API using Axios. Let's take a look at t ...

Guide to incorporating a scroll-follow effect in multiple directions

I am facing a challenge with managing an array of divs that exceed the dimensions of their container. I have set overflow to hidden on the container and used JQuery Overscroll to achieve an iPhone-like scrolling effect on the map. The problem I'm try ...

arranging data in html table columns using angular 2

I am facing a challenge where I require each column of a table to be sorted in ascending order every time it is clicked. The sorting logic implemented is a standard JavaScript method. While this method works well in most scenarios, it encounters issues whe ...

Express displays HTML code as plain text

I am currently facing an issue where I am trying to display an html table on /guestbook.ejs and then redirect it to /guestbook. However, the content of my guestbook.ejs file is being displayed as plain text rather than rendering the HTML code. Below is th ...