Update morris.js

Add support for valueFormatter to show in Line and Bar mouse hover tooltip the value formated
This commit is contained in:
Alan Schio 2018-06-15 16:57:15 -04:00 committed by GitHub
parent 14530d0733
commit 0a6d0fa44d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -236,7 +236,16 @@ Licensed under the BSD-2-Clause License.
ret.label = new Date(ret.label).toString();
}
} else {
ret.x = index;
if(this.options.valueFormatter) {
ret.src.formated = []
for(var ykey in this.options.ykeys) {
var value = ret.src[this.options.ykeys[ykey]];
ret.src.formated[this.options.ykeys[ykey]] = this.options.valueFormatter(value);
}
}
ret.x = index;
if (this.options.xLabelFormat) {
ret.label = this.options.xLabelFormat(ret);
}
@ -950,7 +959,7 @@ Licensed under the BSD-2-Clause License.
if (this.options.labels[j] === false) {
continue;
}
content += "<div class='morris-hover-point' style='color: " + (this.colorFor(row, j, 'label')) + "'>\n " + this.options.labels[j] + ":\n " + (this.yLabelFormat(y, j)) + "\n</div>";
content += "<div class='morris-hover-point' style='color: " + (this.colorFor(row, j, 'label')) + "'>\n " + this.options.labels[j] + ":\n " + ( this.options.valueFormatter?this.options.valueFormatter (y): this.yLabelFormat(y, j)) + "\n</div>";
}
if (typeof this.options.hoverCallback === 'function') {
content = this.options.hoverCallback(index, this.options, content, row.src);
@ -1806,7 +1815,7 @@ Licensed under the BSD-2-Clause License.
if (this.options.labels[j] === false) {
continue;
}
content += "<div class='morris-hover-point' style='color: " + (this.colorFor(row, j, 'label')) + "'>\n " + this.options.labels[j] + ":\n " + (this.yLabelFormat(y, j)) + "\n</div>";
content += "<div class='morris-hover-point' style='color: " + (this.colorFor(row, j, 'label')) + "'>\n " + this.options.labels[j] + ":\n " + (this.options.valueFormatter?this.options.valueFormatter (y):this.yLabelFormat(y, j)) + "\n</div>";
}
if (typeof this.options.hoverCallback === 'function') {
content = this.options.hoverCallback(index, this.options, content, row.src);