Data label in React Accumulation chart component
20 Jan 202324 minutes to read
Data label can be added to a chart series by enabling the visible
option in the dataLabel property.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { AccumulationChartComponent, AccumulationSeriesCollectionDirective, AccumulationSeriesDirective, Inject, AccumulationDataLabel } from '@syncfusion/ej2-react-charts';
import { accData } from 'datasource.ts';
function App() {
const datalabel = { visible: true };
return <AccumulationChartComponent id='charts' enableSmartLabels='true'>
<Inject services={[AccumulationDataLabel]}/>
<AccumulationSeriesCollectionDirective>
<AccumulationSeriesDirective dataSource={accData} xName='x' yName='y' dataLabel={datalabel}></AccumulationSeriesDirective>
</AccumulationSeriesCollectionDirective>
</AccumulationChartComponent>;
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
import * as React from "react";
import * as ReactDOM from "react-dom";
import { AccumulationChartComponent, AccumulationSeriesCollectionDirective, AccumulationSeriesDirective,
Inject, AccumulationDataLabel,AccumulationDataLabelSettingsModel} from'@syncfusion/ej2-react-charts';
import { accData } from 'datasource.ts';
function App() {
const datalabel: AccumulationDataLabelSettingsModel = { visible: true }
return <AccumulationChartComponent id='charts' enableSmartLabels='true'>
<Inject services={[AccumulationDataLabel]} />
<AccumulationSeriesCollectionDirective>
<AccumulationSeriesDirective dataSource={accData} xName='x' yName='y'
dataLabel={datalabel}></AccumulationSeriesDirective>
</AccumulationSeriesCollectionDirective>
</AccumulationChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
Note: To use the data label feature, inject the
DataLabel
module into theservices
.
Positioning
Accumulation chart provides support for placing the data label either inside
or outside
the chart.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { AccumulationChartComponent, AccumulationSeriesCollectionDirective, AccumulationSeriesDirective, Inject, AccumulationDataLabel } from '@syncfusion/ej2-react-charts';
import { accData } from 'datasource.ts';
function App() {
const datalabel = { visible: true, position: 'Outside' };
return <AccumulationChartComponent id='charts' enableSmartLabels='true'>
<Inject services={[AccumulationDataLabel]}/>
<AccumulationSeriesCollectionDirective>
<AccumulationSeriesDirective dataSource={accData} xName='x' yName='y' dataLabel={datalabel}></AccumulationSeriesDirective>
</AccumulationSeriesCollectionDirective>
</AccumulationChartComponent>;
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
import * as React from "react";
import * as ReactDOM from "react-dom";
import { AccumulationChartComponent, AccumulationSeriesCollectionDirective, AccumulationSeriesDirective,
Inject, AccumulationDataLabel,AccumulationDataLabelSettingsModel}
from'@syncfusion/ej2-react-charts';
import { accData } from 'datasource.ts';
function App() {
const datalabel: AccumulationDataLabelSettingsModel = { visible: true, position: 'Outside' };
return <AccumulationChartComponent id='charts' enableSmartLabels='true'>
<Inject services={[AccumulationDataLabel]} />
<AccumulationSeriesCollectionDirective>
<AccumulationSeriesDirective dataSource={accData} xName='x' yName='y'
dataLabel={datalabel}></AccumulationSeriesDirective>
</AccumulationSeriesCollectionDirective>
</AccumulationChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
DataLabel rotation
Using angle
property, you can rotate the data label by its given angle.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { AccumulationChartComponent, AccumulationSeriesCollectionDirective, AccumulationSeriesDirective, Inject, AccumulationDataLabel } from '@syncfusion/ej2-react-charts';
import { accData } from 'datasource.ts';
function App() {
const datalabel = { visible: true, angle: 90, enableRotation: true };
return <AccumulationChartComponent id='charts' enableSmartLabels='true'>
<Inject services={[AccumulationDataLabel]}/>
<AccumulationSeriesCollectionDirective>
<AccumulationSeriesDirective dataSource={accData} xName='x' yName='y' dataLabel={datalabel}></AccumulationSeriesDirective>
</AccumulationSeriesCollectionDirective>
</AccumulationChartComponent>;
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
import * as React from "react";
import * as ReactDOM from "react-dom";
import { AccumulationChartComponent, AccumulationSeriesCollectionDirective, AccumulationSeriesDirective,
Inject, AccumulationDataLabel,AccumulationDataLabelSettingsModel}
from'@syncfusion/ej2-react-charts';
import { accData } from 'datasource.ts';
function App() {
const datalabel: AccumulationDataLabelSettingsModel = { visible: true, angle: 90, enableRotation: true};
return <AccumulationChartComponent id='charts' enableSmartLabels='true'>
<Inject services={[AccumulationDataLabel]} />
<AccumulationSeriesCollectionDirective>
<AccumulationSeriesDirective dataSource={accData} xName='x' yName='y'
dataLabel={datalabel}></AccumulationSeriesDirective>
</AccumulationSeriesCollectionDirective>
</AccumulationChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
Note: By default, when the
enableRotation
is true, the datalabel is rotated along the slice.
Smart labels
Data labels will be arranged smartly without overlapping with each other. You can enable or disable this feature using the enableSmartLabels
property.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { AccumulationChartComponent, AccumulationSeriesCollectionDirective, AccumulationSeriesDirective, Inject, AccumulationDataLabel } from '@syncfusion/ej2-react-charts';
import { accData } from 'datasource.ts';
function App() {
const datalabel = { visible: true, name: 'text', position: 'Outside' };
return <AccumulationChartComponent id='charts' enableSmartLabels='true'>
<Inject services={[AccumulationDataLabel]}/>
<AccumulationSeriesCollectionDirective>
<AccumulationSeriesDirective dataSource={accData} xName='x' yName='y' dataLabel={datalabel}></AccumulationSeriesDirective>
</AccumulationSeriesCollectionDirective>
</AccumulationChartComponent>;
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
import * as React from "react";
import * as ReactDOM from "react-dom";
import { AccumulationChartComponent, AccumulationSeriesCollectionDirective, AccumulationSeriesDirective,
Inject, AccumulationDataLabel,AccumulationDataLabelSettingsModel} from'@syncfusion/ej2-react-charts';
import { accData } from 'datasource.ts';
function App() {
const datalabel: AccumulationDataLabelSettingsModel = { visible: true, name: 'text', position: 'Outside' };
return <AccumulationChartComponent id='charts' enableSmartLabels='true'>
<Inject services={[AccumulationDataLabel]} />
<AccumulationSeriesCollectionDirective>
<AccumulationSeriesDirective dataSource={accData} xName='x' yName='y'
dataLabel={datalabel}></AccumulationSeriesDirective>
</AccumulationSeriesCollectionDirective>
</AccumulationChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
Format
Data label for the accumulation chart can be formatted using format
property. You can use the global formatting options, such as ‘n’, ‘p’, and ‘c’.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { AccumulationChartComponent, AccumulationSeriesCollectionDirective, AccumulationSeriesDirective, Inject, AccumulationDataLabel } from '@syncfusion/ej2-react-charts';
import { accData } from 'datasource.ts';
function App() {
const datalabel = { visible: true, format: 'n2' };
return <AccumulationChartComponent id='charts' enableSmartLabels='true'>
<Inject services={[AccumulationDataLabel]}/>
<AccumulationSeriesCollectionDirective>
<AccumulationSeriesDirective dataSource={accData} xName='x' yName='y' dataLabel={datalabel}></AccumulationSeriesDirective>
</AccumulationSeriesCollectionDirective>
</AccumulationChartComponent>;
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
import * as React from "react";
import * as ReactDOM from "react-dom";
import { AccumulationChartComponent, AccumulationSeriesCollectionDirective, AccumulationSeriesDirective,
Inject, AccumulationDataLabel,AccumulationDataLabelSettingsModel} from'@syncfusion/ej2-react-charts';
import { accData } from 'datasource.ts';
function App() {
const datalabel: AccumulationDataLabelSettingsModel = { visible: true, format: 'n2' };
return <AccumulationChartComponent id='charts' enableSmartLabels='true'>
<Inject services={[AccumulationDataLabel]} />
<AccumulationSeriesCollectionDirective>
<AccumulationSeriesDirective dataSource={accData} xName='x' yName='y'
dataLabel={datalabel}></AccumulationSeriesDirective>
</AccumulationSeriesCollectionDirective>
</AccumulationChartComponent>
};
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. |
Datalabel template
Label content can be formatted by using the template option. Inside the template, you can add the placeholder text ${point.x}
and ${point.y}
to display corresponding data points x & y value. Using template
property, you can set data label template in chart.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { AccumulationChartComponent, AccumulationSeriesCollectionDirective, AccumulationSeriesDirective, Inject, AccumulationDataLabel } from '@syncfusion/ej2-react-charts';
import { accData } from 'datasource.ts';
function App() {
const template = chartTemplate;
const datalabel = { visible: true, name: 'text', position: 'Outside', template: template };
function chartTemplate(args) {
return (<div id="templateWrap">
<div>{args.point.x}</div>
<div>{args.point.y}</div>
</div>);
}
return <AccumulationChartComponent id='charts'>
<Inject services={[AccumulationDataLabel]}/>
<AccumulationSeriesCollectionDirective>
<AccumulationSeriesDirective dataSource={accData} xName='x' yName='y' dataLabel={datalabel}>
</AccumulationSeriesDirective>
</AccumulationSeriesCollectionDirective>
</AccumulationChartComponent>;
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
import * as React from "react";
import * as ReactDOM from "react-dom";
import { AccumulationChartComponent, AccumulationSeriesCollectionDirective, AccumulationSeriesDirective,
Inject, AccumulationDataLabel,AccumulationDataLabelSettingsModel} from'@syncfusion/ej2-react-charts';
import { accData } from 'datasource.ts';
function App() {
const template:any = chartTemplate;
const datalabel: AccumulationDataLabelSettingsModel = { visible: true, name: 'text', position: 'Outside', template: template };
function chartTemplate(args:any){
return (<div id="templateWrap">
<div>{args.point.x}</div>
<div>{args.point.y}</div>
</div>);
}
return <AccumulationChartComponent id='charts'>
<Inject services={[AccumulationDataLabel]} />
<AccumulationSeriesCollectionDirective>
<AccumulationSeriesDirective dataSource={accData} xName='x' yName='y' dataLabel={datalabel}>
</AccumulationSeriesDirective>
</AccumulationSeriesCollectionDirective>
</AccumulationChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
Connector Line
Connector line will be visible when the data label is placed outside
the chart.
The connector line can be customized using the type
, color
, width
, length
and dashArray
properties
import * as React from "react";
import * as ReactDOM from "react-dom";
import { AccumulationChartComponent, AccumulationSeriesCollectionDirective, AccumulationSeriesDirective, Inject, AccumulationDataLabel } from '@syncfusion/ej2-react-charts';
import { accData } from 'datasource.ts';
function App() {
const datalabel = {
visible: true, name: 'text', position: 'Outside',
connectorStyle: {
//Length of the connector line in pixels
length: '50px',
//Width of the connector line in pixels
width: 2,
//dashArray of the connector line
dashArray: '5,3',
//Color of the connector line
color: '#f4429e',
//Specifies the type of the connector line either Line or Curve
type: 'Curve'
}
};
return <AccumulationChartComponent id='charts' enableSmartLabels='true'>
<Inject services={[AccumulationDataLabel]}/>
<AccumulationSeriesCollectionDirective>
<AccumulationSeriesDirective dataSource={accData} xName='x' yName='y' dataLabel={datalabel}>
</AccumulationSeriesDirective>
</AccumulationSeriesCollectionDirective>
</AccumulationChartComponent>;
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
import * as React from "react";
import * as ReactDOM from "react-dom";
import { AccumulationChartComponent, AccumulationSeriesCollectionDirective, AccumulationSeriesDirective,
Inject, AccumulationDataLabel,AccumulationDataLabelSettingsModel} from'@syncfusion/ej2-react-charts';
import { accData } from 'datasource.ts';
function App() {
const datalabel: AccumulationDataLabelSettingsModel = {
visible: true, name: 'text', position: 'Outside',
connectorStyle: {
//Length of the connector line in pixels
length: '50px',
//Width of the connector line in pixels
width: 2,
//dashArray of the connector line
dashArray: '5,3',
//Color of the connector line
color: '#f4429e',
//Specifies the type of the connector line either Line or Curve
type: 'Curve'
}
};
return <AccumulationChartComponent id='charts' enableSmartLabels='true'>
<Inject services={[AccumulationDataLabel]} />
<AccumulationSeriesCollectionDirective>
<AccumulationSeriesDirective dataSource={accData} xName='x' yName='y' dataLabel={datalabel}>
</AccumulationSeriesDirective>
</AccumulationSeriesCollectionDirective>
</AccumulationChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
Text Mapping
The fill color and the text in the data source can be mapped to the chart using pointColorMapping
and name
properties, respectively.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { AccumulationChartComponent, AccumulationSeriesCollectionDirective, AccumulationSeriesDirective, Inject, AccumulationDataLabel } from '@syncfusion/ej2-react-charts';
import { dataMapping } from 'datasource.ts';
function App() {
const datalabel = { visible: true, name: 'text', position: 'Outside' };
return <AccumulationChartComponent id='charts'>
<Inject services={[AccumulationDataLabel]}/>
<AccumulationSeriesCollectionDirective>
<AccumulationSeriesDirective dataSource={dataMapping} xName='x' yName='y' dataLabel={datalabel}>
</AccumulationSeriesDirective>
</AccumulationSeriesCollectionDirective>
</AccumulationChartComponent>;
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
import * as React from "react";
import * as ReactDOM from "react-dom";
import { AccumulationChartComponent, AccumulationSeriesCollectionDirective, AccumulationSeriesDirective,
Inject, AccumulationDataLabel,AccumulationDataLabelSettingsModel} from'@syncfusion/ej2-react-charts';
import { dataMapping } from 'datasource.ts';
function App() {
const datalabel: AccumulationDataLabelSettingsModel = { visible: true, name: 'text', position: 'Outside' };
return <AccumulationChartComponent id='charts'>
<Inject services={[AccumulationDataLabel]} />
<AccumulationSeriesCollectionDirective>
<AccumulationSeriesDirective dataSource={dataMapping} xName='x' yName='y' dataLabel={datalabel}>
</AccumulationSeriesDirective>
</AccumulationSeriesCollectionDirective>
</AccumulationChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
Customization
Individual text can be customized using the textRender
event.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { AccumulationChartComponent, AccumulationSeriesCollectionDirective, AccumulationSeriesDirective, Inject, AccumulationDataLabel } from '@syncfusion/ej2-react-charts';
import { accData } from 'datasource.ts';
function App() {
const textRender = (args) => {
if (args.text === '7') {
args.color = 'red';
args.border.width = 1;
}
};
const datalabel = { visible: true };
return <AccumulationChartComponent id='charts' enableSmartLabels='true' textRender={textRender}>
<Inject services={[AccumulationDataLabel]}/>
<AccumulationSeriesCollectionDirective>
<AccumulationSeriesDirective dataSource={accData} xName='x' yName='y' dataLabel={datalabel}>
</AccumulationSeriesDirective>
</AccumulationSeriesCollectionDirective>
</AccumulationChartComponent>;
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
import * as React from "react";
import * as ReactDOM from "react-dom";
import { AccumulationChartComponent, AccumulationSeriesCollectionDirective,AccumulationDataLabelSettingsModel,
IAccTextRenderEventArgs, AccumulationSeriesDirective, Inject, AccumulationDataLabel} from'@syncfusion/ej2-react-charts';
import { accData } from 'datasource.ts';
function App() {
const textRender = (args: IAccTextRenderEventArgs): void => {
if (args.text === '7') {
args.color = 'red';
args.border.width = 1;
}
};
const datalabel: AccumulationDataLabelSettingsModel = { visible: true };
return <AccumulationChartComponent id='charts' enableSmartLabels='true' textRender={textRender}>
<Inject services={[AccumulationDataLabel]} />
<AccumulationSeriesCollectionDirective>
<AccumulationSeriesDirective dataSource={accData} xName='x' yName='y' dataLabel={datalabel}>
</AccumulationSeriesDirective>
</AccumulationSeriesCollectionDirective>
</AccumulationChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
Text wrap
When the data label text exceeds the container, the text can be wrapped by using textWrap
property. End user can also wrap the data label text based on maxWidth
property.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { AccumulationChartComponent, AccumulationSeriesCollectionDirective, PieSeries, AccumulationSeriesDirective, Inject, AccumulationDataLabel } from '@syncfusion/ej2-react-charts';
function App() {
const datalabel = {
visible: true, osition: 'Inside', maxWidth: 100, textWrap: 'Wrap',
name: 'text', enableRotation: true
};
const data = [
{ x: 'Chrome', y: 100, text: 'Chrome (100M)<br>40%', tooltipMappingName: '40%' },
{ x: 'UC Browser', y: 40, text: 'UC Browser (40M)<br>16%', tooltipMappingName: '16%' },
{ x: 'Opera', y: 30, text: 'Opera (30M)<br>12%', tooltipMappingName: '12%' },
{ x: 'Safari', y: 30, text: 'Safari (30M)<br>12%', tooltipMappingName: '12%' },
{ x: 'Firefox', y: 25, text: 'Firefox (25M)<br>10%', tooltipMappingName: '10%' },
{ x: 'Others', y: 25, text: 'Others (25M)<br>10%', tooltipMappingName: '10%' }
];
return <AccumulationChartComponent id='charts' enableSmartLabels='true'>
<Inject services={[AccumulationDataLabel, PieSeries]}/>
<AccumulationSeriesCollectionDirective>
<AccumulationSeriesDirective dataSource={data} xName='x' yName='y' startAngle={270} endAngle={90} dataLabel={datalabel} innerRadius='40%' radius='100%'>
</AccumulationSeriesDirective>
</AccumulationSeriesCollectionDirective>
</AccumulationChartComponent>;
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
import * as React from "react";
import * as ReactDOM from "react-dom";
import { AccumulationChartComponent, AccumulationSeriesCollectionDirective,AccumulationDataLabelSettingsModel,PieSeries, IAccTextRenderEventArgs, AccumulationSeriesDirective, Inject, AccumulationDataLabel}from'@syncfusion/ej2-react-charts';
function App() {
const datalabel: AccumulationDataLabelSettingsModel = {
visible: true, osition:'Inside', maxWidth:100, textWrap:'Wrap',
name: 'text', enableRotation:true
};
const data: any[] = [
{ x: 'Chrome', y: 100, text: 'Chrome (100M)<br>40%', tooltipMappingName: '40%' },
{ x: 'UC Browser', y: 40, text: 'UC Browser (40M)<br>16%', tooltipMappingName: '16%' },
{ x: 'Opera', y: 30, text: 'Opera (30M)<br>12%', tooltipMappingName: '12%' },
{ x: 'Safari', y: 30, text: 'Safari (30M)<br>12%', tooltipMappingName: '12%' },
{ x: 'Firefox', y: 25, text: 'Firefox (25M)<br>10%', tooltipMappingName: '10%' },
{ x: 'Others', y: 25, text: 'Others (25M)<br>10%', tooltipMappingName: '10%' }];
return <AccumulationChartComponent id='charts' enableSmartLabels='true' >
<Inject services={[AccumulationDataLabel, PieSeries]} />
<AccumulationSeriesCollectionDirective>
<AccumulationSeriesDirective dataSource={data} xName='x' yName='y' startAngle={270} endAngle={90} dataLabel={datalabel} innerRadius='40%' radius='100%'>
</AccumulationSeriesDirective>
</AccumulationSeriesCollectionDirective>
</AccumulationChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
Show percentages in data labels of pie chart
You can show the percentages in data labels of pie chart using textRender
event and template
option.
Using textRender event
You can customize the data label of pie chart using textRender event as follows to show percentage.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { AccumulationChartComponent, AccumulationSeriesCollectionDirective, AccumulationSeriesDirective, Inject, AccumulationDataLabel } from '@syncfusion/ej2-react-charts';
import { accData } from 'datasource.ts';
function App() {
const textRender = (args) => {
args.text = args.point.percentage + "%";
};
const datalabel = { visible: true };
return <AccumulationChartComponent id='charts' enableSmartLabels='true' textRender={textRender}>
<Inject services={[AccumulationDataLabel]}/>
<AccumulationSeriesCollectionDirective>
<AccumulationSeriesDirective dataSource={accData} xName='x' yName='y' dataLabel={datalabel}>
</AccumulationSeriesDirective>
</AccumulationSeriesCollectionDirective>
</AccumulationChartComponent>;
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
import * as React from "react";
import * as ReactDOM from "react-dom";
import { AccumulationChartComponent, AccumulationSeriesCollectionDirective,AccumulationDataLabelSettingsModel,
IAccTextRenderEventArgs, AccumulationSeriesDirective, Inject, AccumulationDataLabel} from'@syncfusion/ej2-react-charts';
import { accData } from 'datasource.ts';
function App() {
const textRender = (args: IAccTextRenderEventArgs): void => {
args.text = args.point.percentage + "%";
};
const datalabel: AccumulationDataLabelSettingsModel = { visible: true };
return <AccumulationChartComponent id='charts' enableSmartLabels='true' textRender={textRender}>
<Inject services={[AccumulationDataLabel]} />
<AccumulationSeriesCollectionDirective>
<AccumulationSeriesDirective dataSource={accData} xName='x' yName='y' dataLabel={datalabel}>
</AccumulationSeriesDirective>
</AccumulationSeriesCollectionDirective>
</AccumulationChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
Using template
You can display the percentage values in data label of pie chart using template
option.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { AccumulationChartComponent, AccumulationSeriesCollectionDirective, AccumulationSeriesDirective, Inject, AccumulationDataLabel } from '@syncfusion/ej2-react-charts';
import { accData } from 'datasource.ts';
function App() {
const template = chartTemplate;
const datalabel = { visible: true, template: template };
function chartTemplate(args) {
return (<div id="templateWrap">
<div>{args.point.percentage}%</div>
</div>);
}
return <AccumulationChartComponent id='charts'>
<Inject services={[AccumulationDataLabel]}/>
<AccumulationSeriesCollectionDirective>
<AccumulationSeriesDirective dataSource={accData} xName='x' yName='y' dataLabel={datalabel}>
</AccumulationSeriesDirective>
</AccumulationSeriesCollectionDirective>
</AccumulationChartComponent>;
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
import * as React from "react";
import * as ReactDOM from "react-dom";
import { AccumulationChartComponent, AccumulationSeriesCollectionDirective, AccumulationSeriesDirective,
Inject, AccumulationDataLabel,AccumulationDataLabelSettingsModel} from'@syncfusion/ej2-react-charts';
import { accData } from 'datasource.ts';
function App() {
const template:any = chartTemplate;
const datalabel: AccumulationDataLabelSettingsModel = { visible: true, template: template };
function chartTemplate(args:any){
return (<div id="templateWrap">
<div>{args.point.percentage}%</div>
</div>);
}
return <AccumulationChartComponent id='charts'>
<Inject services={[AccumulationDataLabel]} />
<AccumulationSeriesCollectionDirective>
<AccumulationSeriesDirective dataSource={accData} xName='x' yName='y' dataLabel={datalabel}>
</AccumulationSeriesDirective>
</AccumulationSeriesCollectionDirective>
</AccumulationChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));