Custom Elements Documentation

Getting Started

jqxTagCloud is a HTML Element which displays a collection of user-generated tags accompanying the articles, posts, or videos on your website. each tag has weight value which corresponds to its popularity, importance or recurrence on the page. the keywords in the cloud can have their own url which navigates to a collection of items associated with the relevant tag. the user can easily customize the appearance of the control, choose the items that will be displayed in the cloud, their font size and color, sort the tags alphabetically or by value, in ascending or descending order.

Every UI element from jQWidgets toolkit needs its JavaScript files to be included in order to work properly.

The first step is to create html page and add links to the javascript files and css dependencies to your project.

The jqxTagCloud element requires the following files:

<script type="text/javascript" src="../scripts/webcomponents-lite.min.js"></script>
<script type="text/javascript" src="../jqwidgets/jqxcore.js"></script>
<script type="text/javascript" src="../jqwidgets/jqxcore.elements.js"></script>
<script type="text/javascript" src="../jqwidgets/jqxdata.js"></script>
<script type="text/javascript" src="../jqwidgets/jqxtagcloud.js"></script>
The next step is to add the html element within the body of the html page.

<jqx-tag-cloud settings="elementSettings"></jqx-tag-cloud>
The last step is to initialize the element settings:
<script type="text/javascript">
JQXElements.settings["elementSettings"] =
{
source:adapter, displayMember:"countryName", valueMember:"technologyRating", alterTextCase:"titleCase"
}
</script>
To call a function(method), you need to pass the method name and parameters(if any) in the jqxTagCloud's instance.
<script>
window.onload = function () {
var element = document.querySelector("jqx-tag-cloud");
element.destroy();
}
</script>
To get the result of a function after calling it, you can use the following syntax:
<script>
window.onload = function () {
var element = document.querySelector("jqx-tag-cloud");
var result = element.findTagIndex();
}
</script>
To set a property(option), you need to use the property name and value(s) along with the jqxTagCloud's instance.
window.onload = function() {
document.querySelector("jqx-tag-cloud").alterTextCase = ''none'';
}
You can also set properties of HTML Elements by using Attributes. Traditionally, attributes are used to set the initial state of an element. Properties with camelCase naming have dash-based attributes. For example: A property "dataSource" will have an attribute called "data-source".

To get a property(option), you need to use the property name along with the jqxTagCloud's instance.
window.onload = function() {
var propertyValue = document.querySelector("jqx-tag-cloud").alterTextCase;
}

Event binding can be defined in the HTML as an attribute. The syntax is: 'on-' and the event's name. Event Names with camelCase naming have dash-based attributes. The attribute's value is the event handler's name. The addEventListener function can also be used for event binding.

<script>
window.onload = function () {
var element = document.querySelector("jqx-tag-cloud");
element.addEventListener("bindingComplete", function(event){
// Your code here
});
}
</script>

Example

<!DOCTYPE html>
<html lang="en">
<head>
<title id='Description'>Tag Cloud Custom Element</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1 maximum-scale=1 minimum-scale=1" />
<link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" type="text/css" />
<link rel="stylesheet" href="../../styles/demos.css" type="text/css" />
<script type="text/javascript" src="../../scripts/webcomponents-lite.min.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxcore.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxcore.elements.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxdata.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxtagcloud.js"></script>
<script type="text/javascript" src="../../scripts/demos.js"></script>
<script>
var data = [
{ countryName: "Australia", technologyRating: 35 },
{ countryName: "United States", technologyRating: 60 },
{ countryName: "Germany", technologyRating: 55 },
{ countryName: "Brasil", technologyRating: 20 },
{ countryName: "United Kingdom", technologyRating: 50 },
{ countryName: "Japan", technologyRating: 80 }
];
var adapter = new jqx.dataAdapter({
localdata: data,
datatype: "array",
datafields: [
{ name: 'countryName' },
{ name: 'technologyRating' }
]
});
JQXElements.settings["tagCloudSettings"] =
{
source:adapter, displayMember:"countryName", valueMember:"technologyRating", alterTextCase:"titleCase"
}
</script>
</head>
<body>
<jqx-tag-cloud settings="tagCloudSettings"></jqx-tag-cloud>
</body>
</html>

The result of the above code is: