javascript - Chart.js change the label for each data point on a chart - Stack Overflow

I am using Chart.js and am struggling to figure out how to overwrite the defaults when the user hovers

I am using Chart.js and am struggling to figure out how to overwrite the defaults when the user hovers over a data point on the graph. Currently when I hover the mouse over a data point the X and Y coordinates appear. Is there a way to change what is displayed.

Here is the for loop I am using for to give each data point its value.

 for (var j = 0; j < sub_array_scores.length; j++) {
                var data = {
                    x: new Date(sub_array_dates[j]),
                    y: sub_array_scores[j],
                    r: 5
                };
                coordinates.push(data);
            }

and here is an image of what appears when I hover over a point in the graph How would I change that to say instead your score is: Y

I am using Chart.js and am struggling to figure out how to overwrite the defaults when the user hovers over a data point on the graph. Currently when I hover the mouse over a data point the X and Y coordinates appear. Is there a way to change what is displayed.

Here is the for loop I am using for to give each data point its value.

 for (var j = 0; j < sub_array_scores.length; j++) {
                var data = {
                    x: new Date(sub_array_dates[j]),
                    y: sub_array_scores[j],
                    r: 5
                };
                coordinates.push(data);
            }

and here is an image of what appears when I hover over a point in the graph How would I change that to say instead your score is: Y

Share asked Feb 16, 2018 at 22:20 AaronAaron 4,50021 gold badges92 silver badges151 bronze badges 1
  • Would it be possible for you to post a minimal example via JSFiddle? – NickyTheWrench Commented Feb 16, 2018 at 22:33
Add a ment  | 

1 Answer 1

Reset to default 6

are custom Tooltips what you're looking for?

http://www.chartjs/docs/latest/configuration/tooltip.html

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742404172a4437507.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信