Skip to content

Commit 93bf566

Browse files
Merge pull request #3754 from Countly/SER-440
[SER-440] default-properties-are-not-being-applied-on-dual-axis-charts
2 parents 57b5f42 + 73284ee commit 93bf566

File tree

3 files changed

+2022
-21
lines changed

3 files changed

+2022
-21
lines changed

frontend/express/public/javascripts/countly/vue/components/vis.js

+34-20
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
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
43

54
(function(countlyVue) {
65

@@ -41,7 +40,7 @@
4140
},
4241
computed: {
4342
legendOptions: function() {
44-
var options = _merge({}, this.calculatedLegend, this.legend || {});
43+
var options = _mergeWith({}, this.calculatedLegend, this.legend || {});
4544

4645
delete options.data;
4746

@@ -313,7 +312,7 @@
313312
this.getGraphNotes(); // when chart updated (date change etc.)
314313
}
315314
}, 0);
316-
return _merge({}, this.internalUpdateOptions, this.updateOptions || {});
315+
return _mergeWith({}, this.internalUpdateOptions, this.updateOptions || {});
317316
}
318317
}
319318
};
@@ -335,6 +334,21 @@
335334

336335
countlyVue.mixins.zoom = ExternalZoomMixin;
337336

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+
338352
/**
339353
* Calculating width of text
340354
* @param {string} txt Text value to calculate width.
@@ -375,7 +389,7 @@
375389
h: this.chartHeight
376390
});
377391
if (xAxisOverflowPatch) {
378-
opt = _merge(opt, xAxisOverflowPatch);
392+
opt = _mergeWith(opt, xAxisOverflowPatch);
379393
}
380394
return opt;
381395
},
@@ -780,7 +794,7 @@
780794
return false;
781795
}
782796
var isEmpty = true;
783-
var options = _merge({}, this.option);
797+
var options = _mergeWith({}, this.option);
784798

785799
if (options.series) {
786800
for (var i = 0; i < options.series.length; i++) {
@@ -911,10 +925,10 @@
911925
},
912926
computed: {
913927
mergedOptions: function() {
914-
var opt = _merge({}, this.baseOptions, this.mixinOptions, this.option);
928+
var opt = _mergeWith({}, this.baseOptions, this.mixinOptions, this.option, mergeWithCustomizer);
915929
var series = opt.series || [];
916930
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]);
918932
}
919933
this.setCalculatedLegendData(opt, series);
920934

@@ -1357,11 +1371,11 @@
13571371
},
13581372
computed: {
13591373
mergedOptions: function() {
1360-
var opt = _merge({}, this.baseOptions, this.mixinOptions, this.option);
1374+
var opt = _mergeWith({}, this.baseOptions, this.mixinOptions, this.option);
13611375
var series = opt.series || [];
13621376

13631377
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]);
13651379
}
13661380

13671381
this.setCalculatedLegendData(opt, series);
@@ -1454,7 +1468,7 @@
14541468
return true;
14551469
},
14561470
mergedOptions: function() {
1457-
var opt = _merge({}, this.baseOptions, this.mixinOptions, this.option);
1471+
var opt = _mergeWith({}, this.baseOptions, this.mixinOptions, this.option);
14581472
var series = opt.series || [];
14591473

14601474
var sumOfOthers;
@@ -1464,7 +1478,7 @@
14641478
seriesArr = [];
14651479
sumOfOthers = 0;
14661480

1467-
series[i] = _merge({}, this.baseSeriesOptions, this.seriesOptions, series[i]);
1481+
series[i] = _mergeWith({}, this.baseSeriesOptions, this.seriesOptions, series[i]);
14681482

14691483
series[i].data = series[i].data.filter(function(el) {
14701484
return el.value > 0;
@@ -2202,7 +2216,7 @@
22022216
},
22032217
computed: {
22042218
chartOptions: function() {
2205-
var opt = _merge({}, this.baseOptions, this.option);
2219+
var opt = _mergeWith({}, this.baseOptions, this.option);
22062220
opt = this.patchChart(opt);
22072221
return opt;
22082222
}
@@ -2267,7 +2281,7 @@
22672281
},
22682282
computed: {
22692283
chartOptions: function() {
2270-
var ops = _merge({}, this.baseOptions, this.option);
2284+
var ops = _mergeWith({}, this.baseOptions, this.option);
22712285
delete ops.grid;
22722286
delete ops.xAxis;
22732287
delete ops.yAxis; //remove not needed to don;t get grey line at bottom
@@ -2334,7 +2348,7 @@
23342348
delete this.mergedOptions.series[index].markPoint;
23352349
}
23362350
}
2337-
var opt = _merge({}, this.mergedOptions);
2351+
var opt = _mergeWith({}, this.mergedOptions);
23382352

23392353
opt = this.patchChart(opt);
23402354
opt = this.patchOptionsForXAxis(opt);
@@ -2437,7 +2451,7 @@
24372451
delete this.mergedOptions.series[index].markPoint;
24382452
}
24392453
}
2440-
var opt = _merge({}, this.mergedOptions);
2454+
var opt = _mergeWith({}, this.mergedOptions);
24412455

24422456
var xAxisData = [];
24432457
if (!opt.xAxis.data) {
@@ -2562,7 +2576,7 @@
25622576
},
25632577
computed: {
25642578
chartOptions: function() {
2565-
var opt = _merge({}, this.mergedOptions);
2579+
var opt = _mergeWith({}, this.mergedOptions);
25662580
opt = this.patchChart(opt);
25672581
opt = this.patchOptionsForXAxis(opt);
25682582
return opt;
@@ -2613,7 +2627,7 @@
26132627
},
26142628
computed: {
26152629
chartOptions: function() {
2616-
var opt = _merge({}, this.mergedOptions);
2630+
var opt = _mergeWith({}, this.mergedOptions);
26172631
opt = this.patchChart(opt);
26182632
return opt;
26192633
},
@@ -2632,7 +2646,7 @@
26322646
return classes;
26332647
},
26342648
pieLegendOptions: function() {
2635-
var opt = _merge({}, this.legendOptions);
2649+
var opt = _mergeWith({}, this.legendOptions);
26362650
opt.type = "secondary";
26372651

26382652
if (opt.position === "bottom") {

0 commit comments

Comments
 (0)