最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - ChartJS Radar Chart radar lines color? - Stack Overflow

programmeradmin1浏览0评论

So i have been researching a lot about this and haven't found a solution, i want to change the colors of the radar lines as seen below:

Is there a way to do that?

Here is my current code:

new Chart(document.getElementById("result_chart"), {
    "type": "radar",
    "data": {
        "labels": ["Idea", "Timing", "Skills", "Concept", "Market Plan", "MVP", "Revenue Potential", "Competition", "Team", "BMC", "Financial Model"],
        "datasets": [{
            "label": "Your Results",
            "data": [
              10,
              20,
              30,
              40,
              50,
              60,
              70,
              80,
              90,
              100,
              110
            ],
            "fill": true,
            "backgroundColor": "rgba(165, 211, 164, 0.2)",
            "borderColor": "rgb(165, 211, 164)",
            "pointBackgroundColor": "rgb(165, 211, 164)",
            "pointBorderColor": "#fff",
            "pointHoverBackgroundColor": "#fff",
            "pointHoverBorderColor": "rgb(255, 99, 132)"
        }]
    },
    "options": {
        "elements": {
            "line": {
                "tension": 0,
                "borderWidth": 3
            }
        }
    }
});

So i have been researching a lot about this and haven't found a solution, i want to change the colors of the radar lines as seen below:

Is there a way to do that?

Here is my current code:

new Chart(document.getElementById("result_chart"), {
    "type": "radar",
    "data": {
        "labels": ["Idea", "Timing", "Skills", "Concept", "Market Plan", "MVP", "Revenue Potential", "Competition", "Team", "BMC", "Financial Model"],
        "datasets": [{
            "label": "Your Results",
            "data": [
              10,
              20,
              30,
              40,
              50,
              60,
              70,
              80,
              90,
              100,
              110
            ],
            "fill": true,
            "backgroundColor": "rgba(165, 211, 164, 0.2)",
            "borderColor": "rgb(165, 211, 164)",
            "pointBackgroundColor": "rgb(165, 211, 164)",
            "pointBorderColor": "#fff",
            "pointHoverBackgroundColor": "#fff",
            "pointHoverBorderColor": "rgb(255, 99, 132)"
        }]
    },
    "options": {
        "elements": {
            "line": {
                "tension": 0,
                "borderWidth": 3
            }
        }
    }
});
Share Improve this question edited Mar 23, 2020 at 11:26 E_net4 30k13 gold badges111 silver badges151 bronze badges asked Mar 21, 2020 at 14:48 Fadi ObajiFadi Obaji 1,4944 gold badges28 silver badges59 bronze badges
Add a comment  | 

3 Answers 3

Reset to default 8

You can do it easily by adding these props into your chart's scale specification:

scale: {
      gridLines: {
        color: 'red'
      },
      angleLines: {
        color: 'red'
      }
    },

The visual output will be your requested one

Hope this helps! :)

It appears the config has changed for the library and it should look like this now:

...
scales: {
          r: {
            grid: {
              color: "lightgreen",
            },
          }
}        
options: {
        scales: {
            r: {
                max: 100,
                min: 0,
                ticks: {
                    stepSize: 20,
                    textStrokeColor: 'rgb(54, 162, 235)',
                    color: 'rgba(240, 240, 240, 0.5)',
                    backdropColor: 'rgb(47, 56, 62)'
                },
                angleLines: {
                    color: 'rgba(240, 240, 240,0.5)',
                },

                grid: {
                    color: "lightgreen",
                },

            },
            
        
        },

发布评论

评论列表(0)

  1. 暂无评论