admin管理员组文章数量:1327665
I have been trying all day to remove the scale of a radar chart in chart js. Although the chart works just fine, nothing seems to be working to remove the scale. Unfortunately the documentation is not that helpful for that issue. here is what the graph looks like. The scale looks the same everytime. Clearing cache from browser does not help either. here is the code for the chart:
function setChart(){
var ctx = document.getElementById('myChart').getContext('2d');
var myChart = new Chart(ctx, {
type: 'radar',
data: {
labels: ['classA','classB','classC','classD'],
datasets: [{
label: 'revenue proportion per class',
data: [0.25, 0.3, 0.15, 0.3],
backgroundColor: [
'rgba(255, 99, 132, 0.2)',
],
borderColor: ['rgba(255, 99, 132, 0.2)'],
borderWidth: 5
},
{
label: 'proportion of item quantity per class',
data: [0.25, 0.3, 0.15, 0.3],
backgroundColor: [
'rgba(54, 162, 235, 0.2)',
],
borderColor: ['rgba(54, 162, 235, 0.2)'],
borderWidth: 5
}
],
and the options:
options: {
scale: {
ticks:{
label: false,
min: 0,
max: 1,
fixedStepSize: 4,
showLabelBackdrop: false,
fontSize: 0,
color: "#eee"
}
}
options: {
scale: {
ticks:{
display: false
}
}
I am doing something stupid? Any help on that would be weled!
I have been trying all day to remove the scale of a radar chart in chart js. Although the chart works just fine, nothing seems to be working to remove the scale. Unfortunately the documentation is not that helpful for that issue. here is what the graph looks like. The scale looks the same everytime. Clearing cache from browser does not help either. here is the code for the chart:
function setChart(){
var ctx = document.getElementById('myChart').getContext('2d');
var myChart = new Chart(ctx, {
type: 'radar',
data: {
labels: ['classA','classB','classC','classD'],
datasets: [{
label: 'revenue proportion per class',
data: [0.25, 0.3, 0.15, 0.3],
backgroundColor: [
'rgba(255, 99, 132, 0.2)',
],
borderColor: ['rgba(255, 99, 132, 0.2)'],
borderWidth: 5
},
{
label: 'proportion of item quantity per class',
data: [0.25, 0.3, 0.15, 0.3],
backgroundColor: [
'rgba(54, 162, 235, 0.2)',
],
borderColor: ['rgba(54, 162, 235, 0.2)'],
borderWidth: 5
}
],
and the options:
options: {
scale: {
ticks:{
label: false,
min: 0,
max: 1,
fixedStepSize: 4,
showLabelBackdrop: false,
fontSize: 0,
color: "#eee"
}
}
options: {
scale: {
ticks:{
display: false
}
}
I am doing something stupid? Any help on that would be weled!
Share Improve this question edited May 12, 2020 at 21:43 Murcielago asked May 12, 2020 at 20:47 MurcielagoMurcielago 1,0051 gold badge14 silver badges36 bronze badges 5- that won't help much, would be better if you posted a online demo – EugenSunic Commented May 12, 2020 at 20:48
- I can do it for sure, how would i do that? – Murcielago Commented May 12, 2020 at 20:49
- you ve got plenty of options: stakcblitz, codepen, fiddle.js.... – EugenSunic Commented May 12, 2020 at 20:50
- okok I take a look, in the meantime I add a pic of the graph – Murcielago Commented May 12, 2020 at 20:51
- @EugenSunic sorry shame on me, I am struggling to the render the graph properly on fiddle.js, I have added, data in the fields on my example to help a bit.. – Murcielago Commented May 12, 2020 at 21:44
2 Answers
Reset to default 6options: {
scales: {
r: {
pointLabels: {
display: false // Hides the labels around the radar chart
},
ticks: {
display: false // Hides the labels in the middel (numbers)
}
}
}
}
The linear radial axis documentation lists four configuration options (as of v2.9.3):
- angleLines
- gridLines
- pointLabels
- ticks
Each of these is an object that supports the display
property. Specifying display: false
in all four objects removes the scale.
options: {
scale: {
angleLines: {
display: false
},
gridLines: {
display: false
},
pointLabels: {
display: false
},
ticks: {
display: false
},
}
}
Here's a working example:
new Chart('myChart', {
type: 'radar',
data: {
labels: ['A', 'B', 'C', 'D'],
datasets: [{
label: 'Series 1',
data: [0.25, 0.3, 0.15, 0.3],
}]
},
options: {
scale: {
angleLines: {
display: false
},
gridLines: {
display: false
},
pointLabels: {
display: false
},
ticks: {
display: false
},
}
}
});
<script src="https://cdn.jsdelivr/npm/[email protected]/dist/Chart.min.js"></script>
<canvas id="myChart"></canvas>
本文标签: javascriptimpossible to remove scale from radar chart (chartjs)Stack Overflow
版权声明:本文标题:javascript - impossible to remove scale from radar chart (chart.js) - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742216781a2434712.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论