简体   繁体   English

使用Chart.js配置雷达图

[英]Configuring a Radar Chart w/Chart.js

Edit: The answer below was answered partially, but it helped me get to the final solution. 编辑:下面的答案部分得到了答复,但这有助于我得到最终的解决方案。 The Fiddle has been updated with what I wanted. 小提琴已经更新了我想要的内容。

Here's a radar chart I'm working on: https://jsfiddle.net/bigtrouble77/02p81jhr/4/ 这是我正在处理的雷达图: https : //jsfiddle.net/bigtrouble77/02p81jhr/4/

Chart.defaults.global.defaultFontColor = "#eee";

var radarData = {
  labels: [ "Passing", "Positioning", "Stickhandling", "Wristship", 
"Determination", "Acceleration", "Speed" ],
  datasets: [
   {
      label: false,
      data: [4, 6, 2, 3, 7, 9, 8],
      backgroundColor: "rgba(220,220,220,0.2)",
      borderColor: "#eee",
      borderWidth: 1
    }
  ]
};

var radarOptions = {
  responsive: true,
  maintainAspectRatio: true,
  title: {
    display: false
  },
  legend: {
    display: false,
  }
};

var ctx5 = document.getElementById("radarChart").getContext("2d");

new Chart(ctx5, { type: 'radar', data: radarData, options: radarOptions });

I have had a very difficult time finding any info on how to configure this chart to do the following: 我很难找到有关如何配置此图表以执行以下操作的任何信息:

  • increase the font size of the text 增加文本的字体大小
  • change the color of the "web" lines 更改“网络”线条的颜色
  • remove the unsightly vertical boxes 删除难看的垂直框
  • change the scale to 1-20, so that 20 is always the highest level in the chart, not the highest number in the data set. 将比例更改为1-20,以便20始终是图表中的最高级别,而不是数据集中的最高数字。

I've not been able to find any info in the docs on how to do any of this. 我无法在文档中找到有关如何执行此操作的任何信息。 I've had some success using older versions of Chart.js, but the api seems to have changed significantly so none of that works with the latest version of Chart.js. 使用较旧版本的Chart.js取得了一些成功,但是api似乎已经发生了很大变化,因此这些都不适用于最新版本的Chart.js。 Any help would be greatly appreciated. 任何帮助将不胜感激。

Simply replace with : 只需替换为:

var radarOptions = {
       scale:{
         pointLabels: {
        fontSize: 20
      },
       },

  responsive: true,
  maintainAspectRatio: true,
  title: {
  display: false
  },
  legend: {
  display: false,
  }
};

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

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