-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
how to use callback function for tooltop.formatter? #9
Comments
The options object gets extracted from the Charts object, so it should work as you described. new Chart({
...
tooltip: {
formatter: function () {
return new Date(this.x).toLocaleString() + '<br><b>内存:</b>' + byte_to_string(this.y)
}
}
...
}); |
@cebor thanks private byteToString(data: any): string {
let kb = data / 1024
if (kb > 1024) {
let mb = kb / 1024
if (mb > 1024) {
return (mb / 1024).toFixed(2) + ' GB'
} else {
return mb.toFixed(2) + ' MB'
}
}
return kb.toFixed(2) + ' KB'
} now browser console print: Uncaught TypeError: this.byteToString is not a function |
I think the Problem is that, the options object and the class where you creating the Chart have different contexts. Maybe making Or use something like: For further help, please show me more code of the class you declaring your chart. |
I think, the problem is solved, so i'm closing this. Feel free to reopen. |
yes, is solved. thanks. |
At javascript:
But typescript this is a class.
The text was updated successfully, but these errors were encountered: