- Positioning
- Data label template
- Connector line
- Text mapping
- Format
- Customization
- Using textRender event
- Using template
Contact Support
Data Label in React 3D Circular Chart component
19 Mar 202424 minutes to read
A data label refers to a label associated with specific data points. It can be added to a 3D Circular Chart series by enabling the visible
option in the dataLabel
property. By default, the labels will arrange themselves smartly to avoid overlapping.
import {
CircularChart3DComponent,
CircularChart3DSeriesCollectionDirective,
CircularChart3DSeriesDirective,
PieSeries3D,
CircularChartDataLabel3D,
Inject,
} from '@syncfusion/ej2-react-charts';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
function App() {
const circularData = [
{ x: 'Chrome', y: 62.92 },
{ x: 'Internet Explorer', y: 6.12 },
{ x: 'Opera', y: 3.15 },
{ x: 'Edge', y: 5.5 },
{ x: 'Safari', y: 19.97 },
{ x: 'Others', y: 2.34 },
];
return (
<CircularChart3DComponent
id="charts"
title="Browser Market Shares in November 2023"
tilt={-45}
legendSettings={{ visible: true, position: 'Right' }}
>
<Inject
services={[
PieSeries3D,
CircularChartDataLabel3D,
]}
/>
<CircularChart3DSeriesCollectionDirective>
<CircularChart3DSeriesDirective
dataSource={circularData}
xName="x"
yName="y"
dataLabel={{
visible: true
}}
></CircularChart3DSeriesDirective>
</CircularChart3DSeriesCollectionDirective>
</CircularChart3DComponent>
);
}
export default App;
ReactDOM.render(<App />, document.getElementById('charts'));
import {
CircularChart3DComponent,
CircularChart3DSeriesCollectionDirective,
CircularChart3DSeriesDirective,
PieSeries3D,
CircularChartDataLabel3D,
Inject,
} from '@syncfusion/ej2-react-charts';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
function App() {
const circularData: any[] = [
{ x: 'Chrome', y: 62.92 },
{ x: 'Internet Explorer', y: 6.12 },
{ x: 'Opera', y: 3.15 },
{ x: 'Edge', y: 5.5 },
{ x: 'Safari', y: 19.97 },
{ x: 'Others', y: 2.34 },
];
return (
<CircularChart3DComponent
id="charts"
title="Browser Market Shares in November 2023"
tilt={-45}
legendSettings={{ visible: true, position: 'Right' }}
>
<Inject
services={[
PieSeries3D,
CircularChartDataLabel3D,
]}
/>
<CircularChart3DSeriesCollectionDirective>
<CircularChart3DSeriesDirective
dataSource={circularData}
xName="x"
yName="y"
dataLabel={{
visible: true
}}
></CircularChart3DSeriesDirective>
</CircularChart3DSeriesCollectionDirective>
</CircularChart3DComponent>
);
}
export default App;
ReactDOM.render(<App />, document.getElementById('charts'));
To use the data label feature, inject the
CircularChartDataLabel3D
module into the services.
Positioning
Using the position
property, we can place the data label either inside
or outside
the 3D Circular Chart.
import {
CircularChart3DComponent,
CircularChart3DSeriesCollectionDirective,
CircularChart3DSeriesDirective,
PieSeries3D,
CircularChartDataLabel3D,
Inject,
} from '@syncfusion/ej2-react-charts';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
function App() {
const circularData = [
{ x: 'Chrome', y: 62.92 },
{ x: 'Internet Explorer', y: 6.12 },
{ x: 'Opera', y: 3.15 },
{ x: 'Edge', y: 5.5 },
{ x: 'Safari', y: 19.97 },
{ x: 'Others', y: 2.34 },
];
return (
<CircularChart3DComponent
id="charts"
title="Browser Market Shares in November 2023"
tilt={-45}
legendSettings={{ visible: true, position: 'Right' }}
>
<Inject
services={[
PieSeries3D,
CircularChartDataLabel3D,
]}
/>
<CircularChart3DSeriesCollectionDirective>
<CircularChart3DSeriesDirective
dataSource={circularData}
xName="x"
yName="y"
dataLabel={{
visible: true,
position: 'Outside'
}}
></CircularChart3DSeriesDirective>
</CircularChart3DSeriesCollectionDirective>
</CircularChart3DComponent>
);
}
export default App;
ReactDOM.render(<App />, document.getElementById('charts'));
import {
CircularChart3DComponent,
CircularChart3DSeriesCollectionDirective,
CircularChart3DSeriesDirective,
PieSeries3D,
CircularChartDataLabel3D,
Inject,
} from '@syncfusion/ej2-react-charts';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
function App() {
const circularData: any[] = [
{ x: 'Chrome', y: 62.92 },
{ x: 'Internet Explorer', y: 6.12 },
{ x: 'Opera', y: 3.15 },
{ x: 'Edge', y: 5.5 },
{ x: 'Safari', y: 19.97 },
{ x: 'Others', y: 2.34 },
];
return (
<CircularChart3DComponent
id="charts"
title="Browser Market Shares in November 2023"
tilt={-45}
legendSettings={{ visible: true, position: 'Right' }}
>
<Inject
services={[
PieSeries3D,
CircularChartDataLabel3D,
]}
/>
<CircularChart3DSeriesCollectionDirective>
<CircularChart3DSeriesDirective
dataSource={circularData}
xName="x"
yName="y"
dataLabel={{
visible: true,
position: 'Outside'
}}
></CircularChart3DSeriesDirective>
</CircularChart3DSeriesCollectionDirective>
</CircularChart3DComponent>
);
}
export default App;
ReactDOM.render(<App />, document.getElementById('charts'));
Data label template
The label content can be formatted using the template option. Inside the template, placeholder text ${point.x}
and ${point.y
can be added to display the corresponding data point’s x & y value. The data label template can be set using the template
property.
import {
CircularChart3DComponent,
CircularChart3DSeriesCollectionDirective,
CircularChart3DSeriesDirective,
PieSeries3D,
CircularChartDataLabel3D,
Inject,
} from '@syncfusion/ej2-react-charts';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
function App() {
const circularData = [
{ x: 'Chrome', y: 62.92, text: 'Chrome: 40%' },
{ x: 'Internet Explorer', y: 6.12, text: 'Chrome: 15%' },
{ x: 'Opera', y: 3.15, text: 'Chrome: 8%' },
{ x: 'Edge', y: 5.5, text: 'Chrome: 15%' },
{ x: 'Safari', y: 19.97, text: 'Chrome: 20%' },
{ x: 'Others', y: 2.34, text: 'Chrome: 2%' },
];
return (
<CircularChart3DComponent
id="charts"
title="Browser Market Shares in November 2023"
tilt={-45}
legendSettings={{ visible: true, position: 'Right' }}
>
<Inject
services={[
PieSeries3D,
CircularChartDataLabel3D,
]}
/>
<CircularChart3DSeriesCollectionDirective>
<CircularChart3DSeriesDirective
dataSource={circularData}
xName="x"
yName="y"
dataLabel={{
visible: true,
position: 'Outside',
template: '${point.x}: ${point.y}'
}}
></CircularChart3DSeriesDirective>
</CircularChart3DSeriesCollectionDirective>
</CircularChart3DComponent>
);
}
export default App;
ReactDOM.render(<App />, document.getElementById('charts'));
import {
CircularChart3DComponent,
CircularChart3DSeriesCollectionDirective,
CircularChart3DSeriesDirective,
PieSeries3D,
CircularChartDataLabel3D,
Inject,
} from '@syncfusion/ej2-react-charts';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
function App() {
const circularData: any[] = [
{ x: 'Chrome', y: 62.92, text: 'Chrome: 40%' },
{ x: 'Internet Explorer', y: 6.12, text: 'Chrome: 15%' },
{ x: 'Opera', y: 3.15, text: 'Chrome: 8%' },
{ x: 'Edge', y: 5.5, text: 'Chrome: 15%' },
{ x: 'Safari', y: 19.97, text: 'Chrome: 20%' },
{ x: 'Others', y: 2.34, text: 'Chrome: 2%' },
];
return (
<CircularChart3DComponent
id="charts"
title="Browser Market Shares in November 2023"
tilt={-45}
legendSettings={{ visible: true, position: 'Right' }}
>
<Inject
services={[
PieSeries3D,
CircularChartDataLabel3D,
]}
/>
<CircularChart3DSeriesCollectionDirective>
<CircularChart3DSeriesDirective
dataSource={circularData}
xName="x"
yName="y"
dataLabel={{
visible: true,
position: 'Outside',
template: '${point.x}: ${point.y}'
}}
></CircularChart3DSeriesDirective>
</CircularChart3DSeriesCollectionDirective>
</CircularChart3DComponent>
);
}
export default App;
ReactDOM.render(<App />, document.getElementById('charts'));
Connector line
The connector line will be visible when the data label is placed outside
the chart. It can be customized using properties such as color
, width
, length
, and dashArray
within the connectorStyle
property.
import {
CircularChart3DComponent,
CircularChart3DSeriesCollectionDirective,
CircularChart3DSeriesDirective,
PieSeries3D,
CircularChartDataLabel3D,
Inject,
} from '@syncfusion/ej2-react-charts';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
function App() {
const circularData = [
{ x: 'Chrome', y: 62.92, text: 'Chrome: 40%' },
{ x: 'Internet Explorer', y: 6.12, text: 'Chrome: 15%' },
{ x: 'Opera', y: 3.15, text: 'Chrome: 8%' },
{ x: 'Edge', y: 5.5, text: 'Chrome: 15%' },
{ x: 'Safari', y: 19.97, text: 'Chrome: 20%' },
{ x: 'Others', y: 2.34, text: 'Chrome: 2%' },
];
return (
<CircularChart3DComponent
id="charts"
title="Browser Market Shares in November 2023"
tilt={-45}
legendSettings={{ visible: true, position: 'Right' }}
>
<Inject services={[PieSeries3D, CircularChartDataLabel3D]} />
<CircularChart3DSeriesCollectionDirective>
<CircularChart3DSeriesDirective
dataSource={circularData}
xName="x"
yName="y"
dataLabel={{
visible: true,
position: 'Outside',
connectorStyle: { length: '30px', color: 'red', dashArray: '2.45', width: 2 },
}}
></CircularChart3DSeriesDirective>
</CircularChart3DSeriesCollectionDirective>
</CircularChart3DComponent>
);
}
export default App;
ReactDOM.render(<App />, document.getElementById('charts'));
import {
CircularChart3DComponent,
CircularChart3DSeriesCollectionDirective,
CircularChart3DSeriesDirective,
PieSeries3D,
CircularChartDataLabel3D,
Inject,
} from '@syncfusion/ej2-react-charts';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
function App() {
const circularData: any[] = [
{ x: 'Chrome', y: 62.92, text: 'Chrome: 40%' },
{ x: 'Internet Explorer', y: 6.12, text: 'Chrome: 15%' },
{ x: 'Opera', y: 3.15, text: 'Chrome: 8%' },
{ x: 'Edge', y: 5.5, text: 'Chrome: 15%' },
{ x: 'Safari', y: 19.97, text: 'Chrome: 20%' },
{ x: 'Others', y: 2.34, text: 'Chrome: 2%' },
];
return (
<CircularChart3DComponent
id="charts"
title="Browser Market Shares in November 2023"
tilt={-45}
legendSettings={{ visible: true, position: 'Right' }}
>
<Inject services={[PieSeries3D, CircularChartDataLabel3D]} />
<CircularChart3DSeriesCollectionDirective>
<CircularChart3DSeriesDirective
dataSource={circularData}
xName="x"
yName="y"
dataLabel={{
visible: true,
position: 'Outside',
connectorStyle: { length: '30px', color: 'red', dashArray: '2.45', width: 2 },
}}
></CircularChart3DSeriesDirective>
</CircularChart3DSeriesCollectionDirective>
</CircularChart3DComponent>
);
}
export default App;
ReactDOM.render(<App />, document.getElementById('charts'));
Text mapping
Text from the data source can be mapped using the name
property within the data label.
import {
CircularChart3DComponent,
CircularChart3DSeriesCollectionDirective,
CircularChart3DSeriesDirective,
PieSeries3D,
CircularChartDataLabel3D,
Inject,
} from '@syncfusion/ej2-react-charts';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
function App() {
const circularData = [
{ x: 'Chrome', y: 62.92, text: 'Chrome: 40%' },
{ x: 'Internet Explorer', y: 6.12, text: 'Chrome: 15%' },
{ x: 'Opera', y: 3.15, text: 'Chrome: 8%' },
{ x: 'Edge', y: 5.5, text: 'Chrome: 15%' },
{ x: 'Safari', y: 19.97, text: 'Chrome: 20%' },
{ x: 'Others', y: 2.34, text: 'Chrome: 2%' },
];
return (
<CircularChart3DComponent
id="charts"
title="Browser Market Shares in November 2023"
tilt={-45}
legendSettings={{ visible: true, position: 'Right' }}
>
<Inject services={[PieSeries3D, CircularChartDataLabel3D]} />
<CircularChart3DSeriesCollectionDirective>
<CircularChart3DSeriesDirective
dataSource={circularData}
xName="x"
yName="y"
dataLabel={{
visible: true,
position: 'Outside',
name: 'text'
}}
></CircularChart3DSeriesDirective>
</CircularChart3DSeriesCollectionDirective>
</CircularChart3DComponent>
);
}
export default App;
ReactDOM.render(<App />, document.getElementById('charts'));
import {
CircularChart3DComponent,
CircularChart3DSeriesCollectionDirective,
CircularChart3DSeriesDirective,
PieSeries3D,
CircularChartDataLabel3D,
Inject,
} from '@syncfusion/ej2-react-charts';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
function App() {
const circularData: any[] = [
{ x: 'Chrome', y: 62.92, text: 'Chrome: 40%' },
{ x: 'Internet Explorer', y: 6.12, text: 'Chrome: 15%' },
{ x: 'Opera', y: 3.15, text: 'Chrome: 8%' },
{ x: 'Edge', y: 5.5, text: 'Chrome: 15%' },
{ x: 'Safari', y: 19.97, text: 'Chrome: 20%' },
{ x: 'Others', y: 2.34, text: 'Chrome: 2%' },
];
return (
<CircularChart3DComponent
id="charts"
title="Browser Market Shares in November 2023"
tilt={-45}
legendSettings={{ visible: true, position: 'Right' }}
>
<Inject services={[PieSeries3D, CircularChartDataLabel3D]} />
<CircularChart3DSeriesCollectionDirective>
<CircularChart3DSeriesDirective
dataSource={circularData}
xName="x"
yName="y"
dataLabel={{
visible: true,
position: 'Outside',
name: 'text'
}}
></CircularChart3DSeriesDirective>
</CircularChart3DSeriesCollectionDirective>
</CircularChart3DComponent>
);
}
export default App;
ReactDOM.render(<App />, document.getElementById('charts'));
Format
The data label for the 3D Circular Chart can be formatted using the format
property. You can utilize global formatting options such as ‘n’, ‘p’, and ‘c’.
import {
CircularChart3DComponent,
CircularChart3DSeriesCollectionDirective,
CircularChart3DSeriesDirective,
PieSeries3D,
CircularChartDataLabel3D,
Inject,
} from '@syncfusion/ej2-react-charts';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
function App() {
const circularData = [
{ x: 'Chrome', y: 62.92, text: 'Chrome: 40%' },
{ x: 'Internet Explorer', y: 6.12, text: 'Chrome: 15%' },
{ x: 'Opera', y: 3.15, text: 'Chrome: 8%' },
{ x: 'Edge', y: 5.5, text: 'Chrome: 15%' },
{ x: 'Safari', y: 19.97, text: 'Chrome: 20%' },
{ x: 'Others', y: 2.34, text: 'Chrome: 2%' },
];
return (
<CircularChart3DComponent
id="charts"
title="Browser Market Shares in November 2023"
tilt={-45}
legendSettings={{ visible: true, position: 'Right' }}
>
<Inject services={[PieSeries3D, CircularChartDataLabel3D]} />
<CircularChart3DSeriesCollectionDirective>
<CircularChart3DSeriesDirective
dataSource={circularData}
xName="x"
yName="y"
dataLabel={{
visible: true,
position: 'Outside',
format: 'c1'
}}
></CircularChart3DSeriesDirective>
</CircularChart3DSeriesCollectionDirective>
</CircularChart3DComponent>
);
}
export default App;
ReactDOM.render(<App />, document.getElementById('charts'));
import {
CircularChart3DComponent,
CircularChart3DSeriesCollectionDirective,
CircularChart3DSeriesDirective,
PieSeries3D,
CircularChartDataLabel3D,
Inject,
} from '@syncfusion/ej2-react-charts';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
function App() {
const circularData: any[] = [
{ x: 'Chrome', y: 62.92, text: 'Chrome: 40%' },
{ x: 'Internet Explorer', y: 6.12, text: 'Chrome: 15%' },
{ x: 'Opera', y: 3.15, text: 'Chrome: 8%' },
{ x: 'Edge', y: 5.5, text: 'Chrome: 15%' },
{ x: 'Safari', y: 19.97, text: 'Chrome: 20%' },
{ x: 'Others', y: 2.34, text: 'Chrome: 2%' },
];
return (
<CircularChart3DComponent
id="charts"
title="Browser Market Shares in November 2023"
tilt={-45}
legendSettings={{ visible: true, position: 'Right' }}
>
<Inject services={[PieSeries3D, CircularChartDataLabel3D]} />
<CircularChart3DSeriesCollectionDirective>
<CircularChart3DSeriesDirective
dataSource={circularData}
xName="x"
yName="y"
dataLabel={{
visible: true,
position: 'Outside',
format: 'c1'
}}
></CircularChart3DSeriesDirective>
</CircularChart3DSeriesCollectionDirective>
</CircularChart3DComponent>
);
}
export default App;
ReactDOM.render(<App />, document.getElementById('charts'));
Value | Format | Resultant Value | Description |
---|---|---|---|
1000 | n1 | 1000.0 | The number is rounded to 1 decimal place. |
1000 | n2 | 1000.00 | The number is rounded to 2 decimal places. |
1000 | n3 | 1000.000 | The number is rounded to 3 decimal place. |
0.01 | p1 | 1.0% | The number is converted to percentage with 1 decimal place. |
0.01 | p2 | 1.00% | The number is converted to percentage with 2 decimal place. |
0.01 | p3 | 1.000% | The number is converted to percentage with 3 decimal place. |
1000 | c1 | $1000.0 | The currency symbol is appended to number and number is rounded to 1 decimal place. |
1000 | c2 | $1000.00 | The currency symbol is appended to number and number is rounded to 2 decimal place. |
Customization
Individual text for the data points in the 3D Circular Chart can be customized using the textRender
event.
import {
CircularChart3DComponent,
CircularChart3DSeriesCollectionDirective,
CircularChart3DSeriesDirective,
PieSeries3D,
CircularChartDataLabel3D,
Inject,
} from '@syncfusion/ej2-react-charts';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
function App() {
const circularData = [
{ x: 'Chrome', y: 62.92, text: 'Chrome: 40%' },
{ x: 'Internet Explorer', y: 6.12, text: 'Chrome: 15%' },
{ x: 'Opera', y: 3.15, text: 'Chrome: 8%' },
{ x: 'Edge', y: 5.5, text: 'Chrome: 15%' },
{ x: 'Safari', y: 19.97, text: 'Chrome: 20%' },
{ x: 'Others', y: 2.34, text: 'Chrome: 2%' },
];
const textRender = function (args) {
if (args.point.index === 0) {
args.text = 'Custom Datalabel';
}
};
return (
<CircularChart3DComponent
id="charts"
textRender={textRender}
title="Browser Market Shares in November 2023"
tilt={-45}
legendSettings={{ visible: true, position: 'Right' }}
>
<Inject services={[PieSeries3D, CircularChartDataLabel3D]} />
<CircularChart3DSeriesCollectionDirective>
<CircularChart3DSeriesDirective
dataSource={circularData}
xName="x"
yName="y"
dataLabel={{
visible: true,
enableRotation: true,
}}
></CircularChart3DSeriesDirective>
</CircularChart3DSeriesCollectionDirective>
</CircularChart3DComponent>
);
}
export default App;
ReactDOM.render(<App />, document.getElementById('charts'));
import {
CircularChart3DComponent,
CircularChart3DSeriesCollectionDirective,
CircularChart3DSeriesDirective,
PieSeries3D,
CircularChartDataLabel3D,
Inject,
} from '@syncfusion/ej2-react-charts';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
function App() {
const circularData: any[] = [
{ x: 'Chrome', y: 62.92, text: 'Chrome: 40%' },
{ x: 'Internet Explorer', y: 6.12, text: 'Chrome: 15%' },
{ x: 'Opera', y: 3.15, text: 'Chrome: 8%' },
{ x: 'Edge', y: 5.5, text: 'Chrome: 15%' },
{ x: 'Safari', y: 19.97, text: 'Chrome: 20%' },
{ x: 'Others', y: 2.34, text: 'Chrome: 2%' },
];
const textRender = function (args) {
if (args.point.index === 0) {
args.text = 'Custom Datalabel';
}
};
return (
<CircularChart3DComponent
id="charts"
textRender={textRender}
title="Browser Market Shares in November 2023"
tilt={-45}
>
<Inject services={[PieSeries3D, CircularChartDataLabel3D]} />
<CircularChart3DSeriesCollectionDirective>
<CircularChart3DSeriesDirective
dataSource={circularData}
xName="x"
yName="y"
dataLabel={{
visible: true,
enableRotation: true,
}}
></CircularChart3DSeriesDirective>
</CircularChart3DSeriesCollectionDirective>
</CircularChart3DComponent>
);
}
export default App;
ReactDOM.render(<App />, document.getElementById('charts'));
Using textRender event
You can customize the data label of a pie chart using the textRender
event as follows to show the percentage.
import {
CircularChart3DComponent,
CircularChart3DSeriesCollectionDirective,
CircularChart3DSeriesDirective,
PieSeries3D,
CircularChartDataLabel3D,
Inject,
} from '@syncfusion/ej2-react-charts';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
function App() {
const circularData = [
{ x: 'Chrome', y: 62.92, text: 'Chrome: 40%' },
{ x: 'Internet Explorer', y: 6.12, text: 'Chrome: 15%' },
{ x: 'Opera', y: 3.15, text: 'Chrome: 8%' },
{ x: 'Edge', y: 5.5, text: 'Chrome: 15%' },
{ x: 'Safari', y: 19.97, text: 'Chrome: 20%' },
{ x: 'Others', y: 2.34, text: 'Chrome: 2%' },
];
const textRender = function (args) {
args.text = args.text + '%';
};
return (
<CircularChart3DComponent
id="charts"
textRender={textRender}
title="Browser Market Shares in November 2023"
tilt={-45}
legendSettings={{ visible: true, position: 'Right' }}
>
<Inject services={[PieSeries3D, CircularChartDataLabel3D]} />
<CircularChart3DSeriesCollectionDirective>
<CircularChart3DSeriesDirective
dataSource={circularData}
xName="x"
yName="y"
dataLabel={{
visible: true,
enableRotation: true,
}}
></CircularChart3DSeriesDirective>
</CircularChart3DSeriesCollectionDirective>
</CircularChart3DComponent>
);
}
export default App;
ReactDOM.render(<App />, document.getElementById('charts'));
import {
CircularChart3DComponent,
CircularChart3DSeriesCollectionDirective,
CircularChart3DSeriesDirective,
PieSeries3D,
CircularChartDataLabel3D,
Inject,
} from '@syncfusion/ej2-react-charts';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
function App() {
const circularData: any[] = [
{ x: 'Chrome', y: 62.92, text: 'Chrome: 40%' },
{ x: 'Internet Explorer', y: 6.12, text: 'Chrome: 15%' },
{ x: 'Opera', y: 3.15, text: 'Chrome: 8%' },
{ x: 'Edge', y: 5.5, text: 'Chrome: 15%' },
{ x: 'Safari', y: 19.97, text: 'Chrome: 20%' },
{ x: 'Others', y: 2.34, text: 'Chrome: 2%' },
];
const textRender = function (args) {
args.text = args.text + '%';
};
return (
<CircularChart3DComponent
id="charts"
textRender={textRender}
title="Browser Market Shares in November 2023"
tilt={-45}
legendSettings={{ visible: true, position: 'Right' }}
>
<Inject services={[PieSeries3D, CircularChartDataLabel3D]} />
<CircularChart3DSeriesCollectionDirective>
<CircularChart3DSeriesDirective
dataSource={circularData}
xName="x"
yName="y"
dataLabel={{
visible: true,
enableRotation: true,
}}
></CircularChart3DSeriesDirective>
</CircularChart3DSeriesCollectionDirective>
</CircularChart3DComponent>
);
}
export default App;
ReactDOM.render(<App />, document.getElementById('charts'));
Using template
You can display the percentage values in the data label of a pie chart using the template
option.
import {
CircularChart3DComponent,
CircularChart3DSeriesCollectionDirective,
CircularChart3DSeriesDirective,
PieSeries3D,
CircularChartDataLabel3D,
Inject,
} from '@syncfusion/ej2-react-charts';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
function App() {
const circularData = [
{ x: 'Chrome', y: 62.92, text: 'Chrome: 40%' },
{ x: 'Internet Explorer', y: 6.12, text: 'Chrome: 15%' },
{ x: 'Opera', y: 3.15, text: 'Chrome: 8%' },
{ x: 'Edge', y: 5.5, text: 'Chrome: 15%' },
{ x: 'Safari', y: 19.97, text: 'Chrome: 20%' },
{ x: 'Others', y: 2.34, text: 'Chrome: 2%' },
];
return (
<CircularChart3DComponent
id="charts"
title="Browser Market Shares in November 2023"
tilt={-45}
legendSettings={{ visible: true, position: 'Right' }}
>
<Inject services={[PieSeries3D, CircularChartDataLabel3D]} />
<CircularChart3DSeriesCollectionDirective>
<CircularChart3DSeriesDirective
dataSource={circularData}
xName="x"
yName="y"
dataLabel={{
visible: true,
enableRotation: true,
template: '${point.y}%'
}}
></CircularChart3DSeriesDirective>
</CircularChart3DSeriesCollectionDirective>
</CircularChart3DComponent>
);
}
export default App;
ReactDOM.render(<App />, document.getElementById('charts'));
import {
CircularChart3DComponent,
CircularChart3DSeriesCollectionDirective,
CircularChart3DSeriesDirective,
PieSeries3D,
CircularChartDataLabel3D,
Inject,
} from '@syncfusion/ej2-react-charts';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
function App() {
const circularData: any[] = [
{ x: 'Chrome', y: 62.92, text: 'Chrome: 40%' },
{ x: 'Internet Explorer', y: 6.12, text: 'Chrome: 15%' },
{ x: 'Opera', y: 3.15, text: 'Chrome: 8%' },
{ x: 'Edge', y: 5.5, text: 'Chrome: 15%' },
{ x: 'Safari', y: 19.97, text: 'Chrome: 20%' },
{ x: 'Others', y: 2.34, text: 'Chrome: 2%' },
];
return (
<CircularChart3DComponent
id="charts"
title="Browser Market Shares in November 2023"
tilt={-45}
legendSettings={{ visible: true, position: 'Right' }}
>
<Inject services={[PieSeries3D, CircularChartDataLabel3D]} />
<CircularChart3DSeriesCollectionDirective>
<CircularChart3DSeriesDirective
dataSource={circularData}
xName="x"
yName="y"
dataLabel={{
visible: true,
enableRotation: true,
template: '${point.y}%'
}}
></CircularChart3DSeriesDirective>
</CircularChart3DSeriesCollectionDirective>
</CircularChart3DComponent>
);
}
export default App;
ReactDOM.render(<App />, document.getElementById('charts'));