d3圆圈:设置圆圈颜色

编程入门 行业动态 更新时间:2024-10-28 21:14:42
本文介绍了d3圆圈:设置圆圈颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我尝试使用 mbostock.github/d3/ex/ bubble.html ,但颜色已更改。

I try to use mbostock.github/d3/ex/bubble.html but with changed colors.

我想知道如何在d3.layout.pack中设置颜色。

I would like to find out how the colors are set in d3.layout.pack.

推荐答案

在您提到的示例中,圆圈颜色定义如下:

In the example you mentioned, the circle color is defined here:

.style("fill", function(d) { return fill(d.packageName); });

这里, d 在此示例中,函数传递一个对象(packageName属性 d )而不是颜色。 每个对象根据所选的颜色标度获得分配给它的唯一颜色:

Here, d is the data, bound to the circle. Instead of color, in this example the function passes an object (packageName attribute of d). Each object gets own unique color assigned to it, according to selected color scale:

fill = d3.scale.category20c();

如果您对使用的着色标准(packageName)感到满意,您可以更改调色板(颜色刻度): https:// github/mbostock/d3/wiki/Ordinal-Scales 如果要更改着色标准,则需要更改返回部分,将其替换为颜色值作为数据 d 的函数。

If you are happy with used criteria for coloring (packageName) and all you need is to change colors, you could change the palette (color scale): github/mbostock/d3/wiki/Ordinal-Scales if you want to change the coloring criteria, then you need to change the return part, replacing it with color value as a function of data d.

在这里您可以找到D3颜色构造函数: github/mbostock/d3/wiki/Colors

Here you can find D3 color constructors: github/mbostock/d3/wiki/Colors

更多推荐

d3圆圈:设置圆圈颜色

本文发布于:2023-07-18 05:13:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1141327.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:圆圈   颜色

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!