webster
webster

Reputation: 4032

Change line color in Anychart radar chart

Is it possible to add color to the lines in the following radar chart? enter image description here

anychart.onDocumentReady(function() {

  // chart type
  var chart = anychart.radar();

  // chart title
  chart.title().text('Spending');

  // series type and data set
  chart.line([
    {x: "Administration", value:"22"},
    {x: "Sales", value:"34"},
    {x: "Marketing", value:"16"},
    {x: "Research", value:"12"},
    {x: "Support", value:"38"},
    {x: "Development", value:"47"}
  ]);

  // draw chart
  chart.container('container').draw();
});

I have tried adding fill, but it doesn't seem to be working

chart.line([
  {x: "Administration", value:"22", fill: "#color-code"},
  {x: "Sales", value:"34", fill: "#color-code"},
  {x: "Marketing", value:"16", fill: "#color-code"},
  {x: "Research", value:"12", fill: "#color-code"},
  {x: "Support", value:"38", fill: "#color-code"},
  {x: "Development", value:"47", fill: "#color-code"}
]);

Upvotes: 1

Views: 1054

Answers (1)

AnyChart Support
AnyChart Support

Reputation: 3905

This is a line series on a radar plot as Radar Plot: Line says. So it follows Line Chart series settings: and you need to set Stroke, not fill, for example:

  line = chart.line([
    {x: "Administration", value:"22"},
    {x: "Sales", value:"34"},
    {x: "Marketing", value:"16"},
    {x: "Research", value:"12"},
    {x: "Support", value:"38"},
    {x: "Development", value:"47"}
  ]);

  line.stroke('red 3', 2, 2);

As it is shown in this Radar Line Chart with Stroke Settings Sample:

  chart.palette(["Black", "Green"]);

Alternatively, you can use AnyChart Palette if you need several different lines: AnyChart Palette Multiple Lines Radar Chart

And here is a snippet of the basic sample as well:

anychart.onDocumentReady(function() {

  // chart type
  var chart = anychart.radar();

  // chart title
  chart.title().text('Spending');
  
  // set palette
  chart.palette(["Black", "Green"]);

  // series type and data set
  chart.line([
    {x: "Administration", value:"22"},
    {x: "Sales", value:"34"},
    {x: "Marketing", value:"16"},
    {x: "Research", value:"12"},
    {x: "Support", value:"38"},
    {x: "Development", value:"47"}
  ]);
  
  // series type and data set
  chart.line([
    {x: "Administration", value:"32"},
    {x: "Sales", value:"44"},
    {x: "Marketing", value:"46"},
    {x: "Research", value:"42"},
    {x: "Support", value:"48"},
    {x: "Development", value:"57"}
  ]);
  

  // draw chart
  chart.container('container').draw();
});
html, body, #container {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
}
<script src="https://cdn.anychart.com/releases/8.2.1/js/anychart-bundle.min.js"></script>
<div id="container"></div>

Upvotes: 1

Related Questions