gpt4 book ai didi

javascript - 更改 Anychart 雷达图中的线条颜色

转载 作者:行者123 更新时间:2023-12-03 01:41:58 26 4
gpt4 key购买 nike

是否可以为下面雷达图中的线条添加颜色? 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();
});

我尝试添加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"}
]);

最佳答案

这是雷达图上的线系列 Radar Plot: Line说。所以如下 Line Chart系列设置:需要设置Stroke ,不填,例如:

  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);

Radar Line Chart with Stroke Settings Sample所示:

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

或者,您可以使用 AnyChart Palette如果您需要多条不同的线路:AnyChart Palette Multiple Lines Radar Chart

这里也是基本示例的片段:

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>

关于javascript - 更改 Anychart 雷达图中的线条颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50794328/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com