RGraph (javascript) 工具提示不适用于条形图
RGraph (javascript) tooltips not working on bar chart
我创建了这个函数,它传递一个数字数组作为频率和一个字母数组作为字母表。
function buildGraph(frequencies, alphabet) {
RGraph.Reset(document.getElementById('myCanvas'))
//Bar Graph Creation
var data = frequencies;
tips = [];
data.forEach(makeString);
var bar = new RGraph.Bar({
id: 'myCanvas',
data: data,
options: {
backgroundGridAutofitNumvlines: 0,
textAccessible: true,
strokestyle: 'black',
linewidth: 1,
shadow: false,
hmargin: 0,
colors: ['Gradient(#aaf:blue)'],
labels: alphabet,
clearto: 'white',
gutterBottom: 90,
noaxes: false,
crosshairs: true,
tooltips: tips,
tooltipsEvent: onmousemove,
}
}).wave({frames: 60});
};
这个函数将数据数组变成一个字符串
function makeString(item) {
tips.push(item.toString());
// console.log(tips.toString());
};
但是当这些功能通过工具提示在我的代码中实现时,工具提示不显示在 canvas
您不能同时启用十字准线和工具提示。使用十字准线,每次移动鼠标时都需要重新绘制 canvas - 重新绘制会隐藏工具提示。
我创建了这个函数,它传递一个数字数组作为频率和一个字母数组作为字母表。
function buildGraph(frequencies, alphabet) {
RGraph.Reset(document.getElementById('myCanvas'))
//Bar Graph Creation
var data = frequencies;
tips = [];
data.forEach(makeString);
var bar = new RGraph.Bar({
id: 'myCanvas',
data: data,
options: {
backgroundGridAutofitNumvlines: 0,
textAccessible: true,
strokestyle: 'black',
linewidth: 1,
shadow: false,
hmargin: 0,
colors: ['Gradient(#aaf:blue)'],
labels: alphabet,
clearto: 'white',
gutterBottom: 90,
noaxes: false,
crosshairs: true,
tooltips: tips,
tooltipsEvent: onmousemove,
}
}).wave({frames: 60});
};
这个函数将数据数组变成一个字符串
function makeString(item) {
tips.push(item.toString());
// console.log(tips.toString());
};
但是当这些功能通过工具提示在我的代码中实现时,工具提示不显示在 canvas
您不能同时启用十字准线和工具提示。使用十字准线,每次移动鼠标时都需要重新绘制 canvas - 重新绘制会隐藏工具提示。