From 6c940e6f744f75530d5f87e8e74eabcab462e2a8 Mon Sep 17 00:00:00 2001 From: HyperCommNet Date: Fri, 4 Mar 2016 11:16:12 -0500 Subject: [PATCH] Custom Label Based on data row This Allows a user you change the value display to a custom label. data: [ {label: "line1", value: 100, label2: "line2"}, ] --- morris.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/morris.js b/morris.js index 35ad2070..ef4a6c6c 100644 --- a/morris.js +++ b/morris.js @@ -1967,10 +1967,10 @@ Licensed under the BSD-2-Clause License. segment = this.segments[idx]; segment.select(); row = this.data[idx]; - return this.setLabels(row.label, this.options.formatter(row.value, row)); + return this.setLabels(row.label, this.options.formatter(row.value, row), row.label2); }; - Donut.prototype.setLabels = function(label1, label2) { + Donut.prototype.setLabels = function(label1, label2, label3) { var inner, maxHeightBottom, maxHeightTop, maxWidth, text1bbox, text1scale, text2bbox, text2scale; inner = (Math.min(this.el.width() / 2, this.el.height() / 2) - 10) * 2 / 3; maxWidth = 1.8 * inner; @@ -1985,6 +1985,9 @@ Licensed under the BSD-2-Clause License. this.text1.attr({ transform: "S" + text1scale + "," + text1scale + "," + (text1bbox.x + text1bbox.width / 2) + "," + (text1bbox.y + text1bbox.height) }); + if (typeof label3 != 'undefined') { + label2 = label3; + } this.text2.attr({ text: label2, transform: ''