|
1 |
| -/* global Vue, countlyCommon, countlyLocation, _merge, CommonConstructor, countlyGlobal, Vue2Leaflet, CV, moment, L, countlyGraphNotesCommon */ |
2 |
| - |
3 |
| -// _merge is Lodash merge - /frontend/express/public/javascripts/utils/lodash.merge.js |
| 1 | +/* global Vue, countlyCommon, countlyLocation, _mergeWith, CommonConstructor, countlyGlobal, Vue2Leaflet, CV, moment, L, countlyGraphNotesCommon */ |
| 2 | +// _mergeWith is Lodash mergeWith - /frontend/express/public/javascripts/utils/lodash.mergeWith.js |
4 | 3 |
|
5 | 4 | (function(countlyVue) {
|
6 | 5 |
|
|
41 | 40 | },
|
42 | 41 | computed: {
|
43 | 42 | legendOptions: function() {
|
44 |
| - var options = _merge({}, this.calculatedLegend, this.legend || {}); |
| 43 | + var options = _mergeWith({}, this.calculatedLegend, this.legend || {}); |
45 | 44 |
|
46 | 45 | delete options.data;
|
47 | 46 |
|
|
313 | 312 | this.getGraphNotes(); // when chart updated (date change etc.)
|
314 | 313 | }
|
315 | 314 | }, 0);
|
316 |
| - return _merge({}, this.internalUpdateOptions, this.updateOptions || {}); |
| 315 | + return _mergeWith({}, this.internalUpdateOptions, this.updateOptions || {}); |
317 | 316 | }
|
318 | 317 | }
|
319 | 318 | };
|
|
335 | 334 |
|
336 | 335 | countlyVue.mixins.zoom = ExternalZoomMixin;
|
337 | 336 |
|
| 337 | + /** |
| 338 | + * Merging default object into array of objects |
| 339 | + * @param {Object|Array} objValue The destination object |
| 340 | + * @param {Object|Array} srcValue The source object |
| 341 | + * @returns {Object|Array} merged object/array |
| 342 | + */ |
| 343 | + function mergeWithCustomizer(objValue, srcValue) { |
| 344 | + if (Array.isArray(srcValue) && typeof objValue === 'object') { |
| 345 | + srcValue.forEach(function(value, index) { |
| 346 | + srcValue[index] = _mergeWith(objValue, value); |
| 347 | + }); |
| 348 | + return srcValue; |
| 349 | + } |
| 350 | + } |
| 351 | + |
338 | 352 | /**
|
339 | 353 | * Calculating width of text
|
340 | 354 | * @param {string} txt Text value to calculate width.
|
|
375 | 389 | h: this.chartHeight
|
376 | 390 | });
|
377 | 391 | if (xAxisOverflowPatch) {
|
378 |
| - opt = _merge(opt, xAxisOverflowPatch); |
| 392 | + opt = _mergeWith(opt, xAxisOverflowPatch); |
379 | 393 | }
|
380 | 394 | return opt;
|
381 | 395 | },
|
|
780 | 794 | return false;
|
781 | 795 | }
|
782 | 796 | var isEmpty = true;
|
783 |
| - var options = _merge({}, this.option); |
| 797 | + var options = _mergeWith({}, this.option); |
784 | 798 |
|
785 | 799 | if (options.series) {
|
786 | 800 | for (var i = 0; i < options.series.length; i++) {
|
|
911 | 925 | },
|
912 | 926 | computed: {
|
913 | 927 | mergedOptions: function() {
|
914 |
| - var opt = _merge({}, this.baseOptions, this.mixinOptions, this.option); |
| 928 | + var opt = _mergeWith({}, this.baseOptions, this.mixinOptions, this.option, mergeWithCustomizer); |
915 | 929 | var series = opt.series || [];
|
916 | 930 | for (var i = 0; i < series.length; i++) {
|
917 |
| - series[i] = _merge({}, this.baseSeriesOptions, this.seriesOptions, series[i]); |
| 931 | + series[i] = _mergeWith({}, this.baseSeriesOptions, this.seriesOptions, series[i]); |
918 | 932 | }
|
919 | 933 | this.setCalculatedLegendData(opt, series);
|
920 | 934 |
|
|
1357 | 1371 | },
|
1358 | 1372 | computed: {
|
1359 | 1373 | mergedOptions: function() {
|
1360 |
| - var opt = _merge({}, this.baseOptions, this.mixinOptions, this.option); |
| 1374 | + var opt = _mergeWith({}, this.baseOptions, this.mixinOptions, this.option); |
1361 | 1375 | var series = opt.series || [];
|
1362 | 1376 |
|
1363 | 1377 | for (var i = 0; i < series.length; i++) {
|
1364 |
| - series[i] = _merge({}, this.baseSeriesOptions, this.seriesOptions, series[i]); |
| 1378 | + series[i] = _mergeWith({}, this.baseSeriesOptions, this.seriesOptions, series[i]); |
1365 | 1379 | }
|
1366 | 1380 |
|
1367 | 1381 | this.setCalculatedLegendData(opt, series);
|
|
1454 | 1468 | return true;
|
1455 | 1469 | },
|
1456 | 1470 | mergedOptions: function() {
|
1457 |
| - var opt = _merge({}, this.baseOptions, this.mixinOptions, this.option); |
| 1471 | + var opt = _mergeWith({}, this.baseOptions, this.mixinOptions, this.option); |
1458 | 1472 | var series = opt.series || [];
|
1459 | 1473 |
|
1460 | 1474 | var sumOfOthers;
|
|
1464 | 1478 | seriesArr = [];
|
1465 | 1479 | sumOfOthers = 0;
|
1466 | 1480 |
|
1467 |
| - series[i] = _merge({}, this.baseSeriesOptions, this.seriesOptions, series[i]); |
| 1481 | + series[i] = _mergeWith({}, this.baseSeriesOptions, this.seriesOptions, series[i]); |
1468 | 1482 |
|
1469 | 1483 | series[i].data = series[i].data.filter(function(el) {
|
1470 | 1484 | return el.value > 0;
|
|
2202 | 2216 | },
|
2203 | 2217 | computed: {
|
2204 | 2218 | chartOptions: function() {
|
2205 |
| - var opt = _merge({}, this.baseOptions, this.option); |
| 2219 | + var opt = _mergeWith({}, this.baseOptions, this.option); |
2206 | 2220 | opt = this.patchChart(opt);
|
2207 | 2221 | return opt;
|
2208 | 2222 | }
|
|
2267 | 2281 | },
|
2268 | 2282 | computed: {
|
2269 | 2283 | chartOptions: function() {
|
2270 |
| - var ops = _merge({}, this.baseOptions, this.option); |
| 2284 | + var ops = _mergeWith({}, this.baseOptions, this.option); |
2271 | 2285 | delete ops.grid;
|
2272 | 2286 | delete ops.xAxis;
|
2273 | 2287 | delete ops.yAxis; //remove not needed to don;t get grey line at bottom
|
|
2334 | 2348 | delete this.mergedOptions.series[index].markPoint;
|
2335 | 2349 | }
|
2336 | 2350 | }
|
2337 |
| - var opt = _merge({}, this.mergedOptions); |
| 2351 | + var opt = _mergeWith({}, this.mergedOptions); |
2338 | 2352 |
|
2339 | 2353 | opt = this.patchChart(opt);
|
2340 | 2354 | opt = this.patchOptionsForXAxis(opt);
|
|
2437 | 2451 | delete this.mergedOptions.series[index].markPoint;
|
2438 | 2452 | }
|
2439 | 2453 | }
|
2440 |
| - var opt = _merge({}, this.mergedOptions); |
| 2454 | + var opt = _mergeWith({}, this.mergedOptions); |
2441 | 2455 |
|
2442 | 2456 | var xAxisData = [];
|
2443 | 2457 | if (!opt.xAxis.data) {
|
|
2562 | 2576 | },
|
2563 | 2577 | computed: {
|
2564 | 2578 | chartOptions: function() {
|
2565 |
| - var opt = _merge({}, this.mergedOptions); |
| 2579 | + var opt = _mergeWith({}, this.mergedOptions); |
2566 | 2580 | opt = this.patchChart(opt);
|
2567 | 2581 | opt = this.patchOptionsForXAxis(opt);
|
2568 | 2582 | return opt;
|
|
2613 | 2627 | },
|
2614 | 2628 | computed: {
|
2615 | 2629 | chartOptions: function() {
|
2616 |
| - var opt = _merge({}, this.mergedOptions); |
| 2630 | + var opt = _mergeWith({}, this.mergedOptions); |
2617 | 2631 | opt = this.patchChart(opt);
|
2618 | 2632 | return opt;
|
2619 | 2633 | },
|
|
2632 | 2646 | return classes;
|
2633 | 2647 | },
|
2634 | 2648 | pieLegendOptions: function() {
|
2635 |
| - var opt = _merge({}, this.legendOptions); |
| 2649 | + var opt = _mergeWith({}, this.legendOptions); |
2636 | 2650 | opt.type = "secondary";
|
2637 | 2651 |
|
2638 | 2652 | if (opt.position === "bottom") {
|
|
0 commit comments