-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathapp.jsx
More file actions
59 lines (50 loc) · 2.18 KB
/
app.jsx
File metadata and controls
59 lines (50 loc) · 2.18 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
import * as React from 'react';
import { createRoot } from 'react-dom/client';
import { SpreadsheetComponent, SheetsDirective, SheetDirective, RangesDirective, RangeDirective, ColumnsDirective, ColumnDirective} from '@syncfusion/ej2-react-spreadsheet';
import { chartData } from './datasource';
function App() {
const spreadsheetRef = React.useRef(null);
const handleCreated = () => {
const spreadsheet = spreadsheetRef.current;
// Insert a Column chart based on A1:B6
spreadsheet.insertChart([{
type: 'Column', // Column | Bar | Line | Pie | Doughnut | Area | Scatter ...
range: 'A1:B6',
top: 120, left: 20, height: 300, width: 500
}]);
};
const removeById = () => {
const spreadsheet = spreadsheetRef.current;
spreadsheet.deleteChart('e_spreadsheet_chart_5'); // removes the chart with id "salesChart"
};
const removeActive = () => {
const spreadsheet = spreadsheetRef.current;
spreadsheet.deleteChart(); // no id → removes the currently selected chart
};
return (
<div>
<button onClick={removeById} style={{ marginRight: 8 }}>Remove by Id</button>
<button onClick={removeActive}>Remove Active Chart</button>
<SpreadsheetComponent ref={spreadsheetRef} created={handleCreated}>
<SheetsDirective>
<SheetDirective>
<RangesDirective>
<RangeDirective dataSource={chartData}></RangeDirective>
</RangesDirective>
<ColumnsDirective>
<ColumnDirective width={180}></ColumnDirective>
<ColumnDirective width={130}></ColumnDirective>
<ColumnDirective width={130}></ColumnDirective>
<ColumnDirective width={180}></ColumnDirective>
<ColumnDirective width={130}></ColumnDirective>
<ColumnDirective width={120}></ColumnDirective>
</ColumnsDirective>
</SheetDirective>
</SheetsDirective>
</SpreadsheetComponent>
</div>
);
}
export default App;
const root = createRoot(document.getElementById('root'));
root.render(<App />);