rrr*_*lsz 2 javascript graph chart.js
我正在使用Chart.js创建雷达图。我已经为每个数据集设置了数据点的大小(半径)。但是,当我将鼠标悬停在数据点上时,半径会变小并保持这种状态,如下所示:
这是我生成图表的方式:
new Chart($('#graph'), {
type: 'radar',
data: {
labels: ['a','b','c'],
datasets: [
{
label: 'aaa',
data: [10,15,5],
backgroundColor: 'rgba(247, 151, 35, 0.5)',
borderColor: 'rgba(247, 151, 35, 1)',
pointBackgroundColor: 'rgba(247, 151, 35, 1)',
pointBorderColor: "#fff",
pointRadius: 5,
borderWidth: 1
}
]
},
options: {
scale: {
type: 'radialLinear',
ticks: {
// hide tick labels
display: false,
min: 0,
max: 20,
stepSize: 1
},
gridLines: {
// hide lines
display: false
}
},
legend: {
position: 'bottom'
}
}
});
Run Code Online (Sandbox Code Playgroud)
这是一个小提琴,您可以在其中看到自己的效果:https : //jsfiddle.net/nj4qehLm/
我怎样才能让数据点保持我设置的大小,这样当我悬停时什么都不会改变?为什么会发生这种情况?
由于某些原因,Chart.js
它似乎没有兑现pointRadius
您可能需要将radius
属性集添加到您的相同值的值,pointRadius
这将解决问题。
像这样的东西,
radius: 5,
pointRadius: 5,
Run Code Online (Sandbox Code Playgroud)
工作小提琴:https : //jsfiddle.net/nj4qehLm/2/
HTML代码:
<canvas id='graph' height=200 width=200></canvas>
Run Code Online (Sandbox Code Playgroud)
Javascript代码:
new Chart($('#graph'), {
type: 'radar',
data: {
labels: ['a','b','c'],
datasets: [
{
label: 'aaa',
data: [10,15,5],
backgroundColor: 'rgba(247, 151, 35, 0.5)',
borderColor: 'rgba(247, 151, 35, 1)',
pointBackgroundColor: 'rgba(247, 151, 35, 1)',
pointBorderColor: "#fff",
radius: 5,
pointRadius: 5,
borderWidth: 1
}
]
},
options: {
scale: {
type: 'radialLinear',
ticks: {
// hide tick labels
display: false,
min: 0,
max: 20,
stepSize: 1
},
gridLines: {
// hide lines
display: false
}
},
legend: {
position: 'bottom'
}
}
});
Run Code Online (Sandbox Code Playgroud)
希望这可以帮助!
Chartjs 可以pointHoverRadius
控制悬停时点的半径,因此只需将其设置为与您的相同pointRadius
:
pointRadius: 5,
pointHoverRadius: 5
Run Code Online (Sandbox Code Playgroud)
使用半径属性对我来说不起作用。
归档时间: |
|
查看次数: |
4158 次 |
最近记录: |