- Position and alignment
- Legend reverse
- Legend shape
- Legend size
- Legend item size
- Legend paging
- Legend text wrap
- Legend title
- Arrow page navigation
- Legend item padding
Contact Support
Legend in EJ2 TypeScript 3D Circular Chart control
19 Mar 202424 minutes to read
The legend provides information about the data points rendered in the 3D Circular Chart. It can be added by enabling the visible
option in the legendSettings
property.
import { CircularChart3D, PieSeries3D, CircularChartLegend3D } from '@syncfusion/ej2-charts';
CircularChart3D.Inject(PieSeries3D, CircularChartLegend3D);
let circularchart: CircularChart3D = new 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,
legendSettings: { visible: true }
}, '#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://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container'>
<div id='element'></div>
</div>
</body>
</html>
To use the legends feature, inject the
CircularChartLegend3D
using theCircularChart3D.Inject(CircularChartLegend3D)
method.
Position and alignment
By using the position
property, the legend can be positioned at the left
, right
, top
or bottom
of the 3D Circular Chart. By default, the legend will be positioned to the right of the 3D Circular Chart. Additionally, you can align the legend to the center
, far
or near
of the chart using the alignment
property.
import { CircularChart3D, PieSeries3D, CircularChartLegend3D } from '@syncfusion/ej2-charts';
CircularChart3D.Inject(PieSeries3D, CircularChartLegend3D);
let circularchart: CircularChart3D = new 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,
legendSettings: { position: 'Top', alignment: 'Near' }
}, '#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://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container'>
<div id='element'></div>
</div>
</body>
</html>
Legend reverse
You can reverse the order of the legend items by using the reverse
property in legendSettings
. By default, the legend for the first series in the collection will be placed first.
import { CircularChart3D, PieSeries3D, CircularChartLegend3D } from '@syncfusion/ej2-charts';
CircularChart3D.Inject(PieSeries3D, CircularChartLegend3D);
let circularchart: CircularChart3D = new CircularChart3D({
series: [
{
dataSource: [
{ x: 'Jan', y: 13 },
{ x: 'Feb', y: 13 },
{ x: 'Mar', y: 17 },
{ x: 'Apr', y: 13.5 }
],
xName: 'x',
yName: 'y',
legendShape: 'Rectangle'
}
],
tilt: -45,
legendSettings: { visible: true, reverse: true }
}, '#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://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container'>
<div id='element'></div>
</div>
</body>
</html>
Legend shape
To change the legend shape, use the legendShape
property in the series
. By default, the legend shape is set to seriesType
.
import { CircularChart3D, PieSeries3D, CircularChartLegend3D } from '@syncfusion/ej2-charts';
CircularChart3D.Inject(PieSeries3D, CircularChartLegend3D);
let circularchart: CircularChart3D = new CircularChart3D({
series: [
{
dataSource: [
{ x: 'Jan', y: 13 },
{ x: 'Feb', y: 13 },
{ x: 'Mar', y: 17 },
{ x: 'Apr', y: 13.5 }
],
xName: 'x',
yName: 'y',
legendShape: 'Rectangle'
}
],
tilt: -45,
legendSettings: { visible: true }
}, '#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://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container'>
<div id='element'></div>
</div>
</body>
</html>
Legend size
The legend size can be changed by using the width
and height
properties in legendSettings
.
import { CircularChart3D, PieSeries3D, CircularChartLegend3D } from '@syncfusion/ej2-charts';
CircularChart3D.Inject(PieSeries3D, CircularChartLegend3D);
let circularchart: CircularChart3D = new 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,
legendSettings: { width: '150', height: '100', border: { width: 1, color: 'pink'} }
}, '#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://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container'>
<div id='element'></div>
</div>
</body>
</html>
Legend item size
The size of the legend items can be customized by using the shapeHeight
and shapeWidth
properties in legendSettings
.
import { CircularChart3D, PieSeries3D, CircularChartLegend3D } from '@syncfusion/ej2-charts';
CircularChart3D.Inject(PieSeries3D, CircularChartLegend3D);
let circularchart: CircularChart3D = new 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,
legendSettings: { shapeHeight: 15, shapeWidth: 15 }
}, '#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://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container'>
<div id='element'></div>
</div>
</body>
</html>
Legend paging
Paging will be enabled by default when the legend items exceed the legend bounds. Each legend item can be viewed by navigating between the pages using navigation buttons.
import { CircularChart3D, PieSeries3D, CircularChartLegend3D } from '@syncfusion/ej2-charts';
CircularChart3D.Inject(PieSeries3D, CircularChartLegend3D);
let circularchart: CircularChart3D = new CircularChart3D({
series: [
{
dataSource: [
{ x: 'Jan', y: 3 }, { x: 'Feb', y: 3.5 },
{ x: 'Mar', y: 7 }, { x: 'Apr', y: 13.5 },
{ x: 'May', y: 19 }, { x: 'Jun', y: 23.5 },
{ x: 'Jul', y: 26 }, { x: 'Aug', y: 25 },
{ x: 'Sep', y: 21 }, { x: 'Oct', y: 15 },
{ x: 'Nov', y: 15 }, { x: 'Dec', y: 15 }
],
xName: 'x',
yName: 'y'
}
],
tilt: -45,
legendSettings: { height: '150', width: '80' }
}, '#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://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container'>
<div id='element'></div>
</div>
</body>
</html>
Legend text wrap
When the legend text exceeds the container, the text can be wrapped using the textWrap
property in legendSettings
. End users can also wrap the legend text based on the maximumLabelWidth
property in legendSettings
.
import { CircularChart3D, PieSeries3D, CircularChartLegend3D } from '@syncfusion/ej2-charts';
CircularChart3D.Inject(PieSeries3D, CircularChartLegend3D);
let circularchart: CircularChart3D = new CircularChart3D({
series: [
{
dataSource: [
{ x: 'Net-tution', y: 21 },
{ x: 'Private Gifts', y: 8 },
{ x: 'All Other', y: 9 },
{ x: 'Local Revenue', y: 4 },
{ x: 'State Revenue', y: 21 },
{ x: 'Federal Revenue', y: 16 },
{ x: 'Self-supporting Operations', y: 21 }
],
xName: 'x',
yName: 'y',
innerRadius: '40%'
}
],
tilt: -45,
legendSettings: {
visible: true,
position: 'Right',
textWrap: 'Wrap',
maximumLabelWidth: 60
}
}, '#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://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container'>
<div id='element'></div>
</div>
</body>
</html>
Legend title
You can set a title for the legend using the title
property in legendSettings
. The size
, color
, opacity
, fontStyle
, fontWeight
, fontFamily
, textAlignment
, and textOverflow
of the legend title can be customized using the titleStyle
property in legendSettings
.
import { CircularChart3D, PieSeries3D, CircularChartLegend3D } from '@syncfusion/ej2-charts';
CircularChart3D.Inject(PieSeries3D, CircularChartLegend3D);
let circularchart: CircularChart3D = new 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,
legendSettings: { visible: true, title: 'Months', position: 'Bottom' }
}, '#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://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container'>
<div id='element'></div>
</div>
</body>
</html>
Arrow page navigation
The page number will always be visible when using legend paging. However, it is now possible to disable the page number and enable page navigation with the left and right arrows. To render the arrow page navigation, set the enablePages
property to false.
import { CircularChart3D, PieSeries3D, CircularChartLegend3D } from '@syncfusion/ej2-charts';
CircularChart3D.Inject(PieSeries3D, CircularChartLegend3D);
let circularchart: CircularChart3D = new CircularChart3D({
series: [
{
dataSource: [
{ x: 'Jan', y: 3 }, { x: 'Feb', y: 3.5 },
{ x: 'Mar', y: 7 }, { x: 'Apr', y: 13.5 },
{ x: 'May', y: 19 }, { x: 'Jun', y: 23.5 },
{ x: 'Jul', y: 26 }, { x: 'Aug', y: 25 },
{ x: 'Sep', y: 21 }, { x: 'Oct', y: 15 },
{ x: 'Nov', y: 15 }, { x: 'Dec', y: 15 }
],
xName: 'x',
yName: 'y'
}
],
tilt: -45,
legendSettings: { width: '260px', height: '50px', enablePages: false, position: 'Bottom' }
}, '#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://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container'>
<div id='element'></div>
</div>
</body>
</html>
Legend item padding
The itemPadding
property can be used to adjust the space between the legend items.
import { CircularChart3D, PieSeries3D, CircularChartLegend3D } from '@syncfusion/ej2-charts';
CircularChart3D.Inject(PieSeries3D, CircularChartLegend3D);
let circularchart: CircularChart3D = new CircularChart3D({
series: [
{
dataSource: [
{ x: 'Jan', y: 3 }, { x: 'Feb', y: 3.5 },
{ x: 'Mar', y: 7 }, { x: 'Apr', y: 13.5 },
{ x: 'May', y: 19 }, { x: 'Jun', y: 23.5 },
{ x: 'Jul', y: 26 }, { x: 'Aug', y: 25 },
{ x: 'Sep', y: 21 }, { x: 'Oct', y: 15 },
{ x: 'Nov', y: 15 }, { x: 'Dec', y: 15 }
],
xName: 'x',
yName: 'y'
}
],
tilt: -45,
legendSettings: { width: '260px', height: '50px', position: 'Bottom', itemPadding: 30 }
}, '#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://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container'>
<div id='element'></div>
</div>
</body>
</html>