简体   繁体   English

如何从雷达图中的鼠标悬停结果中删除数据值?

[英]How do you remove the data value from the mouse-over result in radar chart?

Currently I am working with a dynamic set of data and Chart.js. 目前,我正在处理一组动态数据和Chart.js。 There is no standardised scale within the data I am using, so I have created a simple algorithm, for example: 我正在使用的数据中没有标准化的比例尺,因此我创建了一个简单的算法,例如:

3 out of 7 for question 1 [3 * (12 / 7)]
2 out of 9 for question 2 [2 * (12 / 9)]
6 out of 7 for question 3 [6 * (12 / 7)]
So that all the results for the Radar Graph are measured equally at 12.

By doing this the value is not going to be correct, even though the position of the point in respect to the rest of the graph will be. 这样,即使该点相对于图形其余部分的位置正确,该值也将不正确。

[Label]Question 1 (3/7) : [Value]5.14

I have already included the true value in the label by combining the label with the data in the label array. 通过将标签与标签数组中的数据结合起来,我已经在标签中包含了真值。

So I would like to show just the label when the mouse hovers over the spoke or dot on the chart. 因此,当鼠标悬停在图表上的辐条或圆点上时,我只想显示标签。

Question 1 (3/7)

Is there a way of doing this without messing around with the Chart.js file? 有没有办法做到这一点而又不会弄乱Chart.js文件呢?

Use the tooltipTemplate option 使用tooltipTemplate选项

new Chart(ctx).Radar(data, {
    tooltipTemplate: "<%=label%>",
});

Fiddle - http://jsfiddle.net/dz6mt4dy/ 小提琴-http: //jsfiddle.net/dz6mt4dy/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM