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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169 | 1×
1×
1×
1×
882×
882×
1×
882×
882×
882×
882×
1×
881×
13×
13×
13×
13×
1×
118×
118×
118×
118×
118×
118×
118×
118×
118×
126×
5×
4×
126×
6×
120×
120×
120×
120×
120×
120×
120×
120×
36×
84×
120×
80×
120×
11×
6×
11×
7×
120×
120×
120×
120×
120×
83×
83×
83×
83×
83×
83×
83×
83×
82×
28×
54×
37×
37×
37×
37×
37×
37×
37×
6×
6×
6×
120×
1×
7×
7×
7×
7×
7×
7×
7×
6×
6×
6×
6×
6×
6×
6×
6×
7×
1×
12×
17×
17×
17×
12×
1×
39×
42×
41×
1×
881×
881×
1×
126650×
1×
1×
| define(["require", "exports", "../common/index", "../base/index", "../common/event", "@syncfusion/ej2-base"], function (require, exports, index_1, index_2, event_1, ej2_base_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var WorkbookChart = (function () {
function WorkbookChart(parent) {
this.parent = parent;
this.addEventListener();
}
WorkbookChart.prototype.addEventListener = function () {
this.parent.on(event_1.setChart, this.setChartHandler, this);
this.parent.on(event_1.deleteChartColl, this.deleteChartColl, this);
this.parent.on(event_1.refreshChartSize, this.refreshChartSize, this);
this.parent.on(event_1.focusChartBorder, this.focusChartBorder, this);
};
WorkbookChart.prototype.removeEventListener = function () {
if (!this.parent.isDestroyed) {
this.parent.off(event_1.setChart, this.setChartHandler);
this.parent.off(event_1.deleteChartColl, this.deleteChartColl);
this.parent.off(event_1.refreshChartSize, this.refreshChartSize);
this.parent.off(event_1.focusChartBorder, this.focusChartBorder);
}
};
WorkbookChart.prototype.setChartHandler = function (args) {
var i = 0;
args.isInitCell = ej2_base_1.isNullOrUndefined(args.isInitCell) ? false : args.isInitCell;
args.isUndoRedo = ej2_base_1.isNullOrUndefined(args.isUndoRedo) ? true : args.isUndoRedo;
args.isPaste = ej2_base_1.isNullOrUndefined(args.isPaste) ? false : args.isPaste;
var chart = args.chart;
var chartModel;
var chartLength;
Eif (chart.length > 0) {
while (i < chart.length) {
if (args.isCut === false) {
if (document.getElementById(args.chart[i].id)) {
chart[i] = {
range: chart[i].range, id: ej2_base_1.getUniqueID('e_spreadsheet_chart'), theme: chart[i].theme,
isSeriesInRows: chart[i].isSeriesInRows, type: chart[i].type,
markerSettings: chart[i].markerSettings
};
}
}
if (document.getElementById(args.chart[i].id)) {
return;
}
chartModel = chart[i];
chartModel.theme = chartModel.theme || 'Material';
chartModel.type = chartModel.type || 'Line';
chartModel.isSeriesInRows = chartModel.isSeriesInRows || false;
chartModel.range = chartModel.range || this.parent.getActiveSheet().selectedRange;
var rangeIdx = index_1.getSwapRange(index_1.getRangeIndexes(chartModel.range));
var rangeAddress = index_1.getRangeAddress(rangeIdx);
if (chartModel.range.indexOf('!') > 0) {
chartModel.range = chartModel.range.substring(0, chartModel.range.lastIndexOf('!')) + '!' + rangeAddress;
}
else {
chartModel.range = this.parent.getActiveSheet().name + '!' + rangeAddress;
}
if (ej2_base_1.isNullOrUndefined(chartModel.id)) {
chartModel.id = ej2_base_1.getUniqueID('e_spreadsheet_chart');
}
if (chartModel.markerSettings && chartModel.markerSettings.visible) {
if (chartModel.markerSettings.isFilled === undefined) {
chartModel.markerSettings.isFilled = true;
}
if (chartModel.markerSettings.shape === undefined) {
chartModel.markerSettings.shape = 'Circle';
}
}
chartModel.height = chartModel.height || 290;
chartModel.width = chartModel.width || 480;
this.parent.notify(event_1.initiateChart, {
option: chartModel, isInitCell: args.isInitCell, triggerEvent: args.isUndoRedo,
dataSheetIdx: args.dataSheetIdx, range: args.range, isPaste: args.isPaste
});
this.parent.chartColl.push(chartModel);
if (!args.isInitCell || args.isPaste) {
var sheetIdx = args.sheetId === undefined ? ((chartModel.range && chartModel.range.lastIndexOf('!') > 0) ?
index_2.getSheetIndex(this.parent, chartModel.range.substring(0, chartModel.range.lastIndexOf('!'))) : this.parent.activeSheetIndex) :
index_2.getSheetIndexFromId(this.parent, args.sheetId);
var chartRowIdx = { clientY: chartModel.top, isImage: true };
var chartColIdx = { clientX: chartModel.left, isImage: true };
this.parent.notify(event_1.getChartRowIdxFromClientY, chartRowIdx);
this.parent.notify(event_1.getChartColIdxFromClientX, chartColIdx);
var sheet = ej2_base_1.isUndefined(sheetIdx) ? this.parent.getActiveSheet() : this.parent.sheets[sheetIdx];
var cell = index_2.getCell(chartRowIdx.clientY, chartColIdx.clientX, sheet);
if (!this.parent.isPrintingProcessing) {
if (cell && cell.chart) {
cell.chart.push(chartModel);
}
else {
index_2.setCell(chartRowIdx.clientY, chartColIdx.clientX, sheet, { chart: [chartModel] }, true);
}
}
}
else {
var indexes = index_1.getRangeIndexes(args.range);
var chartRowIdx = { clientY: chartModel.top, isImage: true };
var chartColIdx = { clientX: chartModel.left, isImage: true };
this.parent.notify(event_1.getChartRowIdxFromClientY, chartRowIdx);
this.parent.notify(event_1.getChartColIdxFromClientX, chartColIdx);
var eventArgs = {
prevTop: chartModel.top, prevLeft: chartModel.left, prevRowIdx: indexes[0], prevColIdx: indexes[1],
prevHeight: chartModel.height, prevWidth: chartModel.width, currentTop: chartModel.top,
currentLeft: chartModel.left, currentRowIdx: chartRowIdx.clientY, currentColIdx: chartColIdx.clientX,
currentHeight: chartModel.height, currentWidth: chartModel.width, id: chartModel.id, requestType: 'chartRefreshOnInit'
};
if (indexes[0] !== chartRowIdx.clientY || indexes[1] !== chartColIdx.clientX) {
chartLength = chart.length;
this.parent.notify(event_1.refreshChartCellOnInit, eventArgs);
i -= chartLength - chart.length;
}
}
i++;
}
}
};
WorkbookChart.prototype.refreshChartSize = function (args) {
var chartCnt;
var j = 1;
var sheetCnt = this.parent.sheets.length + 1;
while (j < sheetCnt) {
var charts = this.parent.chartColl;
chartCnt = charts ? charts.length : 0;
if (chartCnt) {
while (chartCnt--) {
var chart = this.parent.chartColl[chartCnt];
Eif (!ej2_base_1.isNullOrUndefined(args.overlayEle.querySelector('#' + chart.id))) {
var chartObj = this.parent.element.querySelector('.' + chart.id);
var excelFilter = ej2_base_1.getComponent(chartObj, 'chart') || ej2_base_1.getComponent(chartObj, 'accumulationchart');
Eif (excelFilter) {
excelFilter.height = args.height;
excelFilter.width = args.width;
}
}
}
}
j++;
}
};
WorkbookChart.prototype.focusChartBorder = function (args) {
for (var idx = 0; idx < this.parent.chartColl.length; idx++) {
var overlayEle = document.getElementById(args.id);
var chartEle = document.getElementById(this.parent.chartColl[idx].id);
if (overlayEle && chartEle && ej2_base_1.closest(chartEle, '.' + overlayEle.classList[1]) === overlayEle) {
this.parent.notify(event_1.initiateChart, {
option: this.parent.chartColl[idx], isRefresh: true
});
}
}
};
WorkbookChart.prototype.deleteChartColl = function (args) {
for (var idx = 0; idx < this.parent.chartColl.length; idx++) {
if (this.parent.chartColl[idx].id + '_overlay' === args.id) {
this.parent.chartColl.splice(idx, 1);
}
}
};
WorkbookChart.prototype.destroy = function () {
this.removeEventListener();
this.parent = null;
};
WorkbookChart.prototype.getModuleName = function () {
return 'workbookChart';
};
return WorkbookChart;
}());
exports.WorkbookChart = WorkbookChart;
});
|