- Header
- Format
- Tooltip template
- Fixed tooltip
- Customization
- Customization of individual tooltip
Contact Support
Tooltip in EJ2 JavaScript 3D Circular Chart control
19 Mar 202422 minutes to read
The 3D Circular Chart will display details about the points through a tooltip, when the mouse is moved over a specific point. By default, the tooltip is not visible. It can be enabled by using the enable
property in tooltip
to true.
var circularchart = new ej.charts.CircularChart3D({
series: [
{
dataSource: [
{ x: 'Jan', y: 13 },
{ x: 'Feb', y: 13 },
{ x: 'Mar', y: 17 },
{ x: 'Apr', y: 13.5 }
],
xName: 'x',
yName: 'y'
}
],
tilt: -45,
tooltip: { enable: true },
legendSettings: {
visible: false
}
}, '#element');
<!DOCTYPE html><html lang="en"><head>
<title>EJ2 Animation</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Typescript UI Controls">
<meta name="author" content="Syncfusion">
<link href="index.css" rel="stylesheet">
<script src="https://cdn.syncfusion.com/ej2/29.2.4/dist/ej2.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>
To use tooltip feature, inject the
CircularChartTooltip3D
using theCircularChart3D.Inject(CircularChartTooltip3D)
method.
Header
You can specify a header for the tooltip by using the header
property in tooltip
.
var circularchart = new ej.charts.CircularChart3D({
series: [
{
dataSource: [
{ x: 'Jan', y: 13 },
{ x: 'Feb', y: 13 },
{ x: 'Mar', y: 17 },
{ x: 'Apr', y: 13.5 }
],
xName: 'x',
yName: 'y'
}
],
tilt: -45,
tooltip: { enable: true, header: 'Pie Chart' },
legendSettings: {
visible: false
}
}, '#element');
<!DOCTYPE html><html lang="en"><head>
<title>EJ2 Animation</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Typescript UI Controls">
<meta name="author" content="Syncfusion">
<link href="index.css" rel="stylesheet">
<script src="https://cdn.syncfusion.com/ej2/29.2.4/dist/ej2.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>
Format
By default, the tooltip shows information about the x and y values in points. Additionally, more information can be displayed in the tooltip by using the format
property. For example, the format ${series.name} : ${point.x}
shows the series name and the point’s x value.
var circularchart = new ej.charts.CircularChart3D({
series: [
{
dataSource: [
{ x: 'Jan', y: 13 },
{ x: 'Feb', y: 13 },
{ x: 'Mar', y: 17 },
{ x: 'Apr', y: 13.5 }
],
xName: 'x',
yName: 'y'
}
],
tilt: -45,
tooltip: { enable: true, format: '${point.x} : <b>${point.y}%</b>' },
legendSettings: {
visible: false
}
}, '#element');
<!DOCTYPE html><html lang="en"><head>
<title>EJ2 Animation</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Typescript UI Controls">
<meta name="author" content="Syncfusion">
<link href="index.css" rel="stylesheet">
<script src="https://cdn.syncfusion.com/ej2/29.2.4/dist/ej2.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>
Tooltip template
Any HTML elements can be displayed in the tooltip by using the template
property in the tooltip.
var circularchart = new ej.charts.CircularChart3D({
series: [
{
dataSource: [
{ x: 'Jan', y: 13 },
{ x: 'Feb', y: 13 },
{ x: 'Mar', y: 17 },
{ x: 'Apr', y: 13.5 }
],
xName: 'x',
yName: 'y'
}
],
tilt: -45,
tooltip: {
enable: true,
template: "<div id='templateWrap' style='background-color:#bd18f9;border-radius: 3px; float: right;padding: 2px;line-height: 20px;text-align: center;'>"+
"<img src='https://ej2.syncfusion.com/demos/src/chart/images/sunny.png' />" +
"<div style='color:white; font-family:Roboto; font-style: medium; fontp-size:14px;float: right;padding: 2px;line-height: 20px;text-align: center;padding-right:6px'><span>${y}</span></div></div>"
},
legendSettings: {
visible: false
}
}, '#element');
<!DOCTYPE html><html lang="en"><head>
<title>EJ2 Animation</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Typescript UI Controls">
<meta name="author" content="Syncfusion">
<link href="index.css" rel="stylesheet">
<script src="https://cdn.syncfusion.com/ej2/29.2.4/dist/ej2.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>
Fixed tooltip
By default, the tooltip tracks the mouse movement, but it can be set to a fixed position using the location
property in tooltip
.
var circularchart = new ej.charts.CircularChart3D({
series: [
{
dataSource: [
{ x: 'Jan', y: 13 },
{ x: 'Feb', y: 13 },
{ x: 'Mar', y: 17 },
{ x: 'Apr', y: 13.5 }
],
xName: 'x',
yName: 'y'
}
],
tilt: -45,
tooltip: { enable: true, location: { x: 200, y: 20 } },
legendSettings: {
visible: false
}
}, '#element');
<!DOCTYPE html><html lang="en"><head>
<title>EJ2 Animation</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Typescript UI Controls">
<meta name="author" content="Syncfusion">
<link href="index.css" rel="stylesheet">
<script src="https://cdn.syncfusion.com/ej2/29.2.4/dist/ej2.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>
Customization
The fill
and border
properties are used to customize the background color and border of the tooltip, respectively. The textStyle
property in the tooltip is used to customize the font of the tooltip text. Additionally, the highlightColor
property can be used to change the color of the data point when hovering.
var circularchart = new ej.charts.CircularChart3D({
series: [
{
dataSource: [
{ x: 'Jan', y: 13 },
{ x: 'Feb', y: 13 },
{ x: 'Mar', y: 17 },
{ x: 'Apr', y: 13.5 }
],
xName: 'x',
yName: 'y'
}
],
tilt: -45,
tooltip: {
enable: true,
format: '${series.name} ${point.x} : ${point.y}',
fill: '#7bb4eb',
border: {
width: 2,
color: 'grey'
}
},
highlightColor: 'red',
highlightMode: 'Point',
legendSettings: {
visible: false
}
}, '#element');
<!DOCTYPE html><html lang="en"><head>
<title>EJ2 Animation</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Typescript UI Controls">
<meta name="author" content="Syncfusion">
<link href="index.css" rel="stylesheet">
<script src="https://cdn.syncfusion.com/ej2/29.2.4/dist/ej2.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>
Customization of individual tooltip
Using the tooltipRender
event, you can customize tooltip values for a particular point.
var circularchart = new ej.charts.CircularChart3D({
series: [
{
dataSource: [
{ x: 'Jan', y: 13 },
{ x: 'Feb', y: 13 },
{ x: 'Mar', y: 17 },
{ x: 'Apr', y: 13.5 }
],
xName: 'x',
yName: 'y'
}
],
tilt: -45,
tooltip: { enable: true },
legendSettings: {
visible: false
},
tooltipRender: (args) => {
if (args.point.index === 3) {
args.text = args.point.x + '' + ':' + args.point.y + '' + ' ' +'customtext';
args.textStyle.color = '#f48042';
}
}
}, '#element');
<!DOCTYPE html><html lang="en"><head>
<title>EJ2 Animation</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Typescript UI Controls">
<meta name="author" content="Syncfusion">
<link href="index.css" rel="stylesheet">
<script src="https://cdn.syncfusion.com/ej2/29.2.4/dist/ej2.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>