javascript - 设置雷达图标记的颜色

标签 javascript node.js plotly

我使用此代码创建了以下雷达图。 Codepen

data = [{
  type: 'scatterpolar',
  r: [39, 28, 8, 7, 28, 39],
  theta: ['A','B','C', 'D', 'E', 'A'],
  fill: 'toself'
}]

layout = {
  polar: {
    radialaxis: {
      visible: true,
      range: [0, 50]
    }
  },
  showlegend: false
}

Plotly.newPlot("myDiv", data, layout)

结果如下: enter image description here 如何设置形成多边形的每个点的颜色?

使用此工具,online graph maker ,似乎你可以按比例设置颜色,但我想单独设置每个点,

任何有关如何自定义其余元素的指导都会非常有帮助。

谢谢。

最佳答案

#myDiv path.point{
  fill: blue !important;
}

如果你想进一步自定义颜色,你可以使用 CSS :nth-of-type(n) 修饰符 https://www.w3schools.com/cssref/sel_nth-of-type.asp

data = [{
  type: 'scatterpolar',
  r: [37, 28, 8, 7, 28, 39],
  theta: ['A','B','C', 'D', 'E', 'A'],
  fill: 'toself',
  marker : { color : '#B80102'}
}]


layout = {
  polar: {
    radialaxis: {
      visible: true,
      range: [0, 50]
    }
  },
  showlegend: false
}

Plotly.newPlot("myDiv", data, layout)
#myDiv path.point{
  fill: blue !important;
}
<head>
	<!-- Load plotly.js into the DOM -->
	<script src='https://cdn.plot.ly/plotly-latest.min.js'></script>
</head>

<body>
	<div id='myDiv'><!-- Plotly chart will be drawn inside this DIV --></div>
</body>

关于javascript - 设置雷达图标记的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60412132/

相关文章:

python - 将 plot.ly JSON 保存到文件

javascript - 如何检测javascript中的复制和粘贴?

javascript - Facebook 发送对话框识别发送或取消是否被点击

javascript - 如何将 Mongoose/Mongodb 与 node.js- Passport 身份验证一起使用

ruby-on-rails - 木材 : Command 'lumber' not found

python - key 错误 : Timestamp

python - plotly 图: Add grid

javascript - 将相机捕获的图像转换为 base64 - Ionic

javascript - 输入复选框 true 或 checked 或 yes

node.js - 如何使用 RequireJS 运行 jasmine-node 测试