This repository was archived by the owner on Jul 30, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdonut.tsx
More file actions
75 lines (75 loc) · 4.1 KB
/
donut.tsx
File metadata and controls
75 lines (75 loc) · 4.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/**
* Sample for Doughnut chart
*/
import * as ReactDOM from 'react-dom';
import * as React from 'react';
import { SampleBase } from '../common/sample-base';
import {
AccumulationChartComponent, AccumulationSeriesCollectionDirective, AccumulationSeriesDirective, AccumulationLegend, PieSeries, IAccLoadedEventArgs,
AccumulationDataLabel, Inject, AccumulationTheme
} from '@syncfusion/ej2-react-charts';
import { Browser } from '@syncfusion/ej2-base';
export let data1: any[] = [{ x: 'Labour', y: 18, text: '18%' }, { x: 'Legal', y: 8, text: '8%' },
{ x: 'Production', y: 15, text: '15%' }, { x: 'License', y: 11, text: '11%' },
{ x: 'Facilities', y: 18, text: '18%' }, { x: 'Taxes', y: 14, text: '14%' },
{ x: 'Insurance', y: 16, text: '16%' }];
export class AccumulationDoughnut extends SampleBase<{}, {}> {
public pie: AccumulationChartComponent;
render() {
return (
<div className='control-pane'>
<div className='control-section'>
<AccumulationChartComponent id="pie-chart"
title='Project Cost Breakdown'
legendSettings={{
visible: true,
position: 'Top'
}}
enableSmartLabels={true}
load={this.load.bind(this)}
tooltip={{ enable: false }}
loaded={this.onChartLoad.bind(this)}
>
<Inject services={[AccumulationLegend, PieSeries, AccumulationDataLabel]} />
<AccumulationSeriesCollectionDirective>
<AccumulationSeriesDirective name='Project' dataSource={data1} xName='x' yName='y' innerRadius='40%' startAngle={0}
endAngle={360} radius='70%' explode={true} explodeOffset='10%' explodeIndex={3}
dataLabel={{
visible: true,
name: 'text',
position: 'Inside',
font: {
fontWeight: '600',
color: '#ffffff'
}
}}
>
</AccumulationSeriesDirective>
</AccumulationSeriesCollectionDirective>
</AccumulationChartComponent>
</div>
<div id="action-description">
<p>
This sample visualizes the project cost breakdown statistics by using doughnut series. Datalabel shows the Information about the points.
</p>
</div>
<div id="description">
<p> In this example, you can see how to render doughnut chart. You can use <code>radius</code> and <code>innerRadius</code> properties to render the doughnut and also use <code>border</code>, <code>fill</code> properties to customize the point. <code>dataLabel</code> is used to represent individual data and its value.</p>
<p> <code>Tooltip</code> is enabled in this example, to see the tooltip in action, hover a point or tap on a point in touch enabled devices.</p>
<p><b>Injecting Module</b></p>
<p>
Accumulation Chart component features are segregated into individual feature-wise modules.To use pie chart, you need to inject <code>PieSeries</code> into <code>services</code>.
</p>
</div>
</div>
)
}
public onChartLoad(args: IAccLoadedEventArgs): void {
document.getElementById('pie-chart').setAttribute('title', '');
};
public load(args: IAccLoadedEventArgs): void {
let selectedTheme: string = location.hash.split('/')[1];
selectedTheme = selectedTheme ? selectedTheme : 'Material';
args.accumulation.theme = (selectedTheme.charAt(0).toUpperCase() + selectedTheme.slice(1)) as AccumulationTheme;
};
}