Skip to content

Commit d577ea3

Browse files
committed
Sync with Kendo UI Professional
1 parent c77cbef commit d577ea3

File tree

4 files changed

+165
-1
lines changed

4 files changed

+165
-1
lines changed
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
---
2+
title: Using Icons as Markers in Kendo UI for jQuery Chart Line Series
3+
description: Learn how to use font icons from the iconography as series markers in a Kendo UI for jQuery Chart line series.
4+
type: how-to
5+
page_title: How to Use Icons as Markers in Chart Line Series with Kendo UI for jQuery
6+
slug: how-to-use-icons-as-markers-in-kendo-ui-for-jquery-chart
7+
tags: kendo-ui-for-jquery, chart, markers, icons, visualization
8+
res_type: kb
9+
ticketid: 1667208
10+
---
11+
12+
## Environment
13+
14+
<table>
15+
<tbody>
16+
<tr>
17+
<td>Product</td>
18+
<td>Kendo UI for jQuery Chart</td>
19+
</tr>
20+
<tr>
21+
<td>Version</td>
22+
<td>2024.4.1112</td>
23+
</tr>
24+
</tbody>
25+
</table>
26+
27+
## Description
28+
29+
I am working with a Kendo UI for jQuery Chart and want to enhance its appearance by using icons from the iconography as markers for the line series. Is it possible to use font icons as series markers in a line chart?
30+
31+
This knowledge base article also answers the following questions:
32+
- How can I customize markers in a Kendo UI for jQuery Chart line series?
33+
- Is it possible to use [`icons from the iconography`](https://www.telerik.com/design-system/docs/foundation/iconography/icon-list/) as series markers in charts?
34+
- How do I implement font icons as series markers in a Kendo UI for jQuery Chart?
35+
36+
## Solution
37+
38+
To use icons as markers in a line series of a Kendo UI Chart, you need to customize the series markers by implementing a visual function. The visual function allows for the creation of custom visuals for the markers, including the use of font icons from the iconography.
39+
40+
First, ensure you have access to the iconography you want to use. If you're using font icons, include the font icon stylesheet in your project.
41+
42+
Then, follow these steps to implement font icons as series markers:
43+
44+
1. For the series that you want to customize the markers for, add a [`markers`]((https://docs.telerik.com/kendo-ui/api/javascript/dataviz/ui/chart/configuration/series.markers)) configuration object.
45+
46+
2. Inside the [`markers`](https://docs.telerik.com/kendo-ui/api/javascript/dataviz/ui/chart/configuration/series.markers) configuration, specify a [`visual`](https://docs.telerik.com/kendo-ui/api/javascript/dataviz/ui/chart/configuration/series.markers.visual) function. This function will be used to create custom visuals for the markers.
47+
48+
3. In the [`visual`](https://docs.telerik.com/kendo-ui/api/javascript/dataviz/ui/chart/configuration/series.markers.visual) function, create and return a visual element (e.g., a `Path` or `Text` element) that represents the icon. You can set the content of the `Text` element to be the character code of the icon if using font icons.
49+
50+
Here's an example of how to define the `visual` function to use a font icon as a marker in a series:
51+
52+
```dojo
53+
<link rel="stylesheet" href="https://unpkg.com/@progress/kendo-font-icons/dist/index.css"/>
54+
<div class="demo-section wide">
55+
<div id="chart"></div>
56+
</div>
57+
<script>
58+
function createChart() {
59+
$("#chart").kendoChart({
60+
title: {
61+
text: "Gross domestic product growth /GDP annual %/"
62+
},
63+
legend: {
64+
position: "top"
65+
},
66+
seriesDefaults: {
67+
type: "line",
68+
style: "smooth",
69+
markers: {
70+
visual: function (e) {
71+
e.rect.origin.y = e.rect.origin.y - 15;
72+
e.rect.origin.x = e.rect.origin.x + 5;
73+
var rect = new kendo.geometry.Rect(e.rect.origin, [e.rect.size.width, 100]);
74+
var layout = new kendo.drawing.Layout(rect, {
75+
orientation: "vertical",
76+
alignContent: "end"
77+
});
78+
79+
var icon = new kendo.drawing.Text(String.fromCharCode(0xe702), [0, 0], {
80+
fill: {
81+
color: "#888"
82+
},
83+
font: "20px WebComponentsIcons",
84+
tooltip:{
85+
content:"Click Legend items to show more info."
86+
}
87+
});
88+
89+
layout.append(icon);
90+
layout.reflow()
91+
92+
return layout;
93+
}
94+
},
95+
},
96+
series: [
97+
{
98+
name: "India",
99+
data: [3.907, , 4.848, 4.4, null, null, null, null, null]
100+
}, {
101+
name: "Russian Federation",
102+
data: [null, null, null, 4.4, 5.3, 5.8, 6.1, 6.1]
103+
}, {
104+
name: "Germany",
105+
data: [null, null, null, 4.4, 3.690, 3.7, 3.9, 4.2]
106+
},
107+
{
108+
name: "UK",
109+
data: [null, null, null, 4.4, 5.190, 5.3, 5.4, 5.0]
110+
}],
111+
valueAxis: {
112+
labels: {
113+
format: "{0}%"
114+
},
115+
line: {
116+
visible: false
117+
},
118+
axisCrossingValue: 0
119+
},
120+
categoryAxis: {
121+
categories: [2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019],
122+
line: {
123+
visible: false
124+
},
125+
labels: {
126+
position: 'start'
127+
}
128+
},
129+
tooltip: {
130+
visible: true,
131+
format: "{0}%",
132+
template: "#= series.name #: #= value #"
133+
}
134+
});
135+
}
136+
137+
$(document).ready(createChart);
138+
$(document).bind("kendo:skinChange", createChart);
139+
</script>
140+
```
141+
142+
## See Also
143+
144+
- [Kendo UI for jQuery Chart - Overview](https://docs.telerik.com/kendo-ui/controls/charts/overview)
145+
- [Kendo UI Chart API](https://docs.telerik.com/kendo-ui/api/javascript/dataviz/ui/chart)
146+
- [Telerik Design System - Iconography](https://www.telerik.com/design-system/docs/foundation/iconography/icon-list/)

src/kendo.list.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3030,7 +3030,7 @@ export const __meta__ = {
30303030
}
30313031
} else if (that.isFiltered() || that._skipUpdate || that._emptySearch) {
30323032
that.focus(0);
3033-
if (that._skipUpdate) {
3033+
if (that._skipUpdate || (that._emptySearch && that._selectedIndices.length)) {
30343034
that._skipUpdate = false;
30353035
that._selectedIndices = that._valueIndices(that._values, that._selectedIndices);
30363036
}

src/kendo.tooltip.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ export const __meta__ = {
186186

187187
hide: function() {
188188
if (this.popup) {
189+
this._shown = false;
189190
this.popup.close();
190191
}
191192
},

typescript/kendo.all.d.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,22 @@ declare namespace kendo {
225225
function widgetInstance(element: JQuery, suite?: typeof kendo.mobile.ui): kendo.ui.Widget;
226226
function widgetInstance(element: JQuery, suite?: typeof kendo.dataviz.ui): kendo.ui.Widget;
227227

228+
interface MediaQueryListEvent {
229+
isTrusted: boolean;
230+
bubbles: boolean;
231+
cancelBubble: boolean;
232+
composed: boolean;
233+
currentTarget: JQuery;
234+
defaultPrevented: boolean;
235+
eventPhase: number;
236+
matches: boolean;
237+
media: string;
238+
returnValue: boolean;
239+
srcElement: MediaQueryList;
240+
target: MediaQueryList;
241+
timeStamp: number;
242+
type: string;
243+
}
228244
interface MediaQueryHandler {
229245
mediaQueryList: MediaQueryList;
230246
onChange(callback: (e: MediaQueryListEvent) => void): MediaQueryHandler;
@@ -8583,6 +8599,7 @@ declare namespace kendo.ui {
85838599
groupHeaderTemplate?: string|Function | undefined;
85848600
messages?: OrgChartMessages | undefined;
85858601
template?: string|Function | undefined;
8602+
noData?: boolean | undefined;
85868603
cancel?(e: OrgChartCancelEvent): void;
85878604
change?(e: OrgChartChangeEvent): void;
85888605
create?(e: OrgChartCreateEvent): void;

0 commit comments

Comments
 (0)