[英]Change line color in Anychart radar chart
Is it possible to add color to the lines in the following radar chart? 是否可以在以下雷达图的线条中添加颜色?
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 我尝试添加
fill
,但是似乎没有用
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"}
]);
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:
因此,它遵循折线图系列设置:并且您需要设置Stroke而不是fill,例如:
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 或者,如果需要几条不同的线,则可以使用AnyChart调色板 : AnyChart调色板多行雷达图
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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.