首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >需要帮助设计图表JS雷达图

需要帮助设计图表JS雷达图
EN

Stack Overflow用户
提问于 2020-02-23 12:14:41
回答 1查看 1.4K关注 0票数 0

我正试图在下面的链接雷达图中添加背景样式,并希望能够

  • 设置雷达线路的颜色
  • 定厚
  • 将标度从0-100设置为
  • 设置字体大小

我认为这必须通过“选项”来完成(因为这不是关于数据集的),但是我对JS的掌握还不足以让它在几个小时后开始工作。

科德芬 图JS雷达指令

代码语言:javascript
复制
new Chart(document.getElementById("radar-chart"), {
type: 'radar',
data: {
  labels: ["Business", "Brand", "Marketing", "Stakeholders", "Clients"],
  datasets: [
     {
      label: "",
      fill: true,
      backgroundColor: "rgba(255,99,132,0.2)",
      borderColor: "rgba(255,99,132,1)", 
      pointBorderColor: "#fff",
      pointBackgroundColor: "rgba(255,99,132,1)",
      pointBorderColor: "#fff",
      data: [25.48,54.16,7.61,8.06,4.45]
    }
  ]
},  

options: {

legend: {
  display: false    
},
borderWidth: 10,

}

});
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-02-23 12:49:27

为了获得所要求的内容,可以在ticksgridLinespointLabels中定义options.scale

代码语言:javascript
复制
new Chart(document.getElementById("radar-chart"), {
  type: 'radar',
  data: {
    labels: ["Business", "Brand", "Marketing", "Stakeholders", "Clients"],
    datasets: [{
      data: [25.48, 54.16, 7.61, 8.06, 4.45],
      fill: true,
      backgroundColor: "rgba(255,99,132,0.2)",
      borderColor: "rgba(255,99,132,1)",
      pointBorderColor: "#fff",
      pointBackgroundColor: "rgba(255,99,132,1)"
    }]
  },
  options: {
    legend: {
      display: false
    },
    borderWidth: 10,
    scale: {
      ticks: {
        fontSize: 18,
        max: 100
      },
      gridLines: {
        lineWidth: 2,
        color: "lightgreen"
      },
      pointLabels: {
        fontSize: 18,
        fontStyle: "bold"
      }
    }  
  }
});
代码语言:javascript
复制
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.js"></script>
<canvas id="radar-chart" height="200"></canvas>

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60362083

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档