1 /* tslint:disable */ |
1 /* tslint:disable */ |
2 /* eslint-disable */ |
2 /* eslint-disable */ |
3 (function ($) { |
3 (function ($) { |
4 $.extend($.jqx._jqxGrid.prototype, { |
4 if (!Array.prototype.find) { |
5 _getChartDataFields: function(data) { |
5 Object.defineProperty(Array.prototype, 'find', { |
|
6 value: function(predicate) { |
|
7 // 1. Let O be ? ToObject(this value). |
|
8 if (this == null) { |
|
9 throw new TypeError('"this" is null or not defined'); |
|
10 } |
|
11 |
|
12 var o = Object(this); |
|
13 |
|
14 // 2. Let len be ? ToLength(? Get(O, "length")). |
|
15 var len = o.length >>> 0; |
|
16 |
|
17 // 3. If IsCallable(predicate) is false, throw a TypeError exception. |
|
18 if (typeof predicate !== 'function') { |
|
19 throw new TypeError('predicate must be a function'); |
|
20 } |
|
21 |
|
22 // 4. If thisArg was supplied, let T be thisArg; else let T be undefined. |
|
23 var thisArg = arguments[1]; |
|
24 |
|
25 // 5. Let k be 0. |
|
26 var k = 0; |
|
27 |
|
28 // 6. Repeat, while k < len |
|
29 while (k < len) { |
|
30 // a. Let Pk be ! ToString(k). |
|
31 // b. Let kValue be ? Get(O, Pk). |
|
32 // c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). |
|
33 // d. If testResult is true, return kValue. |
|
34 var kValue = o[k]; |
|
35 if (predicate.call(thisArg, kValue, k, o)) { |
|
36 return kValue; |
|
37 } |
|
38 // e. Increase k by 1. |
|
39 k++; |
|
40 } |
|
41 |
|
42 // 7. Return undefined. |
|
43 return undefined; |
|
44 } |
|
45 }); |
|
46 } |
|
47 if (!Array.prototype.findIndex) { |
|
48 Object.defineProperty(Array.prototype, 'findIndex', { |
|
49 value: function(predicate) { |
|
50 // 1. Let O be ? ToObject(this value). |
|
51 if (this == null) { |
|
52 throw new TypeError('"this" is null or not defined'); |
|
53 } |
|
54 |
|
55 var o = Object(this); |
|
56 |
|
57 // 2. Let len be ? ToLength(? Get(O, "length")). |
|
58 var len = o.length >>> 0; |
|
59 |
|
60 // 3. If IsCallable(predicate) is false, throw a TypeError exception. |
|
61 if (typeof predicate !== 'function') { |
|
62 throw new TypeError('predicate must be a function'); |
|
63 } |
|
64 |
|
65 // 4. If thisArg was supplied, let T be thisArg; else let T be undefined. |
|
66 var thisArg = arguments[1]; |
|
67 |
|
68 // 5. Let k be 0. |
|
69 var k = 0; |
|
70 |
|
71 // 6. Repeat, while k < len |
|
72 while (k < len) { |
|
73 // a. Let Pk be ! ToString(k). |
|
74 // b. Let kValue be ? Get(O, Pk). |
|
75 // c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). |
|
76 // d. If testResult is true, return k. |
|
77 var kValue = o[k]; |
|
78 if (predicate.call(thisArg, kValue, k, o)) { |
|
79 return k; |
|
80 } |
|
81 // e. Increase k by 1. |
|
82 k++; |
|
83 } |
|
84 |
|
85 // 7. Return -1. |
|
86 return -1; |
|
87 }, |
|
88 configurable: true, |
|
89 writable: true |
|
90 }); |
|
91 } |
|
92 |
|
93 $.extend($.jqx._jqxGrid.prototype, { |
|
94 _getChartDataFields: function (data) { |
6 var that = this; |
95 var that = this; |
7 var record = data[0]; |
96 var record = data[0]; |
8 var stringOnly = true, |
97 var stringOnly = true, |
9 xAxisDataField, |
98 xAxisDataField, |
10 series = []; |
99 series = []; |
12 for (var dataField in record) { |
101 for (var dataField in record) { |
13 if (dataField === '$' || dataField === 'uid' || dataField === 'boundindex' || dataField === 'uniqueid' || dataField === 'visibleindex') { |
102 if (dataField === '$' || dataField === 'uid' || dataField === 'boundindex' || dataField === 'uniqueid' || dataField === 'visibleindex') { |
14 continue; |
103 continue; |
15 } |
104 } |
16 |
105 |
17 var dataType = that.source._source.dataFields.find(gridField => gridField.name === dataField).type; |
106 var dataType = that.source._source.dataFields.find(function (gridField) { return gridField.name === dataField }).type; |
18 |
107 |
19 if (dataType === 'string') { |
108 if (dataType === 'string') { |
20 var index = that.columns.records.findIndex(col => col.datafield === dataField); |
109 var index = that.columns.records.findIndex(function (col) { return col.datafield === dataField }); |
21 |
110 |
22 if (index === 0) { |
111 if (index === 0) { |
23 xAxisDataField = dataField; |
112 xAxisDataField = dataField; |
24 } |
113 } |
25 } |
114 } |
30 } |
119 } |
31 |
120 |
32 return { xAxisDataField: xAxisDataField, series: series, stringOnly: stringOnly }; |
121 return { xAxisDataField: xAxisDataField, series: series, stringOnly: stringOnly }; |
33 }, |
122 }, |
34 |
123 |
35 createChart: function(type, dataSource) { |
124 createChart: function (type, dataSource) { |
36 var that = this; |
125 var that = this; |
37 var gridSelection = that.getselection(), |
126 var gridSelection = that.getselection(), |
38 selectedRows = gridSelection.rows, |
127 selectedRows = gridSelection.rows, |
39 selectedCells = gridSelection.cells, |
128 selectedCells = gridSelection.cells, |
40 chartElement = document.createElement('div'), |
129 chartElement = document.createElement('div'), |
57 } |
146 } |
58 |
147 |
59 if (selectedRows.length === 0 && selectedCells.length === 0) { |
148 if (selectedRows.length === 0 && selectedCells.length === 0) { |
60 var dataSource = that.source.records; |
149 var dataSource = that.source.records; |
61 } |
150 } |
62 |
151 |
63 if (dataSource) { |
152 if (dataSource) { |
64 chartData = chartData.concat(dataSource); |
153 chartData = chartData.concat(dataSource); |
65 } |
154 } |
66 else { |
155 else { |
67 var dataSource = that.source.records; |
156 var dataSource = that.source.records; |
68 |
157 |
69 for (var i = 0; i < dataSource.length; i++) { |
158 for (var i = 0; i < dataSource.length; i++) { |
70 var record = {}; |
159 var record = {}; |
71 |
160 |
72 if (selectedRows.length > 0) { |
161 if (selectedRows.length > 0) { |
73 if (selectedRows.indexOf(i) === -1) { |
162 if (selectedRows.indexOf(i) === -1) { |
74 continue; |
163 continue; |
75 } |
164 } |
76 } |
165 } |
77 else if (selectedCells.length > 0) { |
166 else if (selectedCells.length > 0) { |
78 if (selectedCells.length > 1) { |
167 if (selectedCells.length > 1) { |
79 if (rowsToPlot.indexOf(i) === -1) { |
168 if (rowsToPlot.indexOf(i) === -1) { |
80 continue; |
169 continue; |
81 } |
170 } |
82 |
171 |
83 columnsToPlot.forEach(dataField => { |
172 columnsToPlot.forEach(function (dataField) { |
84 record[dataField] = dataSource[i][dataField]; |
173 record[dataField] = dataSource[i][dataField]; |
85 }); |
174 }); |
86 chartData.push(record); |
175 chartData.push(record); |
87 continue; |
176 continue; |
88 } |
177 } |
89 } |
178 } |
90 |
179 |
91 that.columns.records.forEach(col => record[col.datafield] = dataSource[i][col.datafield]); |
180 that.columns.records.forEach(function (col) { record[col.datafield] = dataSource[i][col.datafield] }); |
92 chartData.push(record); |
181 chartData.push(record); |
93 } |
182 } |
94 } |
183 } |
95 |
184 |
96 var chartDataFields = that._getChartDataFields(chartData); |
185 var chartDataFields = that._getChartDataFields(chartData); |
116 |
205 |
117 return; |
206 return; |
118 } |
207 } |
119 |
208 |
120 series = chartDataFields.series; |
209 series = chartDataFields.series; |
121 |
210 |
122 var chart = {}; |
211 var chart = {}; |
123 |
212 |
124 chart.title = ''; |
213 chart.title = ''; |
125 chart.description = ''; |
214 chart.description = ''; |
126 chart.showLegend = true; |
215 chart.showLegend = true; |
127 chart.showBorderLine = false; |
216 chart.showBorderLine = false; |
128 chart.padding = { left: 5, top: 10, right: 5, bottom: 5 }; |
217 chart.padding = { left: 5, top: 10, right: 5, bottom: 5 }; |
129 chart.source = chartData; |
218 chart.source = chartData; |
130 chart.xAxis = |
219 chart.xAxis = |
131 { |
220 { |
132 dataField: chartDataFields.xAxisDataField, |
221 dataField: chartDataFields.xAxisDataField, |
133 gridLines: { |
222 gridLines: { |
134 visible: true |
223 visible: true |
135 } |
224 } |
136 }; |
225 }; |
137 chart.valueAxis = |
226 chart.valueAxis = |
138 { |
227 { |
139 displayValueAxis: true, |
228 displayValueAxis: true, |
140 description: that.charting.description, |
229 description: that.charting.description, |
141 axisSize: 'auto', |
230 axisSize: 'auto', |
142 formatSettings: that.charting.formatSettings |
231 formatSettings: that.charting.formatSettings |
143 }; |
232 }; |
144 chart.colorScheme = that.charting.colorScheme; |
233 chart.colorScheme = that.charting.colorScheme; |
145 chart.seriesGroups = [seriesGroup]; |
234 chart.seriesGroups = [seriesGroup]; |
146 |
235 |
147 seriesGroup.formatSettings = that.charting.formatSettings; |
236 seriesGroup.formatSettings = that.charting.formatSettings; |
148 seriesGroup.series = series; |
237 seriesGroup.series = series; |
201 |
290 |
202 if (that.charting.appendTo) { |
291 if (that.charting.appendTo) { |
203 var container = that.charting.appendTo === 'string' ? document.querySelector(that.charting.appendTo) : that.charting.appendTo; |
292 var container = that.charting.appendTo === 'string' ? document.querySelector(that.charting.appendTo) : that.charting.appendTo; |
204 |
293 |
205 if (container) { |
294 if (container) { |
206 var chartInstance = new jqxChart(chartElement, chart); |
295 var chartInstance = new jqxChart(chartElement, chart); |
207 container.appendChild(chartElement); |
296 container.appendChild(chartElement); |
208 } |
297 } |
209 } |
298 } |
210 else { |
299 else { |
211 that._openChartDialog(chartElement, type, chart); |
300 that._openChartDialog(chartElement, type, chart); |
212 } |
301 } |
213 }, |
302 }, |
214 |
303 |
215 _openChartDialog: function(chart, chartType, settings) { |
304 _openChartDialog: function (chart, chartType, settings) { |
216 var that = this; |
305 var that = this; |
217 |
306 |
218 if (!that.charting.dialog.enabled) { |
307 if (!that.charting.dialog.enabled) { |
219 return false; |
308 return false; |
220 } |
309 } |
221 |
310 |
222 var dialogElement = document.createElement('div'); |
311 var dialogElement = document.createElement('div'); |
223 |
312 |
224 dialogElement.innerHTML = '<div>' + that.charting.dialog.header + '</div><div style="overflow:hidden;"></div>'; |
313 dialogElement.innerHTML = '<div>' + that.charting.dialog.header + '</div><div style="overflow:hidden;"></div>'; |
225 |
314 |
226 var chartLabel = chartType.substring(0, 1).toUpperCase() + chartType.substring(1); |
315 var chartLabel = chartType.substring(0, 1).toUpperCase() + chartType.substring(1); |
227 |
316 |
228 chart.style.width = '100%'; |
317 chart.style.width = '100%'; |
229 chart.style.height = '100%'; |
318 chart.style.height = '100%'; |
230 |
319 |
231 var dialog = new jqxWindow(dialogElement, { |
320 var dialog = new jqxWindow(dialogElement, { |
232 width: that.charting.dialog.width, |
321 width: that.charting.dialog.width, |