Updating text
#12091
Replies: 1 comment 3 replies
-
Do you mean something like this? Where the text changes based on an event: https://youtu.be/TnGF5XFdMuI |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am using a text plugin to write some text in the top-left corner of a plot:
<
// Custom plugin to add dynamic text
const textParameter1 = {
id: 'textParameter1',
beforeDatasetsDraw(chart, args, plugins) {
const {ctx, chartArea: {top, bottom, left, right, width, height}} = chart;
ctx.save();
ctx.font = 'bold 15px sans-serif';
ctx.fillStyle = 'black';
ctx.fillText('T
5000 S0.00043', left+2, top);}
};
This works well. However, I need to dynamically update the numbers shown in the fillText command, something like:
<
ctx.fillText('T~' + tValue + 'S~' + sValue, left+2, top);
Where in the script do I put those two strings, and what Chartjs function would I use in the javascript to update them?
Many thanks.
Beta Was this translation helpful? Give feedback.
All reactions