mirror of
https://github.com/morrisjs/morris.js.git
synced 2024-11-10 21:36:34 +01:00
Update morris.js
Add support for valueFormatter to show in Line and Bar mouse hover tooltip the value formated
This commit is contained in:
parent
14530d0733
commit
0a6d0fa44d
15
morris.js
15
morris.js
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user