我正在看Mike Bostock的气泡图:http://bl.ocks.org/mbostock/4063530使用圆形包装。但是,我想能够通过包含类的名称为圆圈着色。
我在这里尝试JSBin:http://jsbin.com/qoveguvopu/edit?css,js,output
我的错在这里:
node.append("circle")
.attr("r", function(d) { return d.r; })
.style("fill", function(d) {return color(d.data.name);});
谢谢!
有点像这样:
答案 0 :(得分:1)
您可以获取绑定到父级的数据...
<%= form_for @user, url: user_invitation_path(@user) do |f| %>
<%= f.label :first_name, "First Name", class: "control-label col-md-2 col-sm-2 col-xs-12" %>
<%= f.text_field :first_name, class: "form-control", :required => true, required: "" %>
<%= f.label :last_name, "Last Name", class: "control-label col-md-2 col-sm-2 col-xs-12" %>
<%= f.text_field :last_name, class: "form-control", :required => true, required: "" %>
<%= f.label :email, "Email", class: "control-label col-md-2 col-sm-2 col-xs-12" %>
<%= f.email_field :email, class: "form-control", :required => true, required: "" %>
<%= f.label :phone_number, "Phone Number", class: "control-label col-md-2 col-sm-2 col-xs-12" %>
<%= f.text_field :phone_number, class: "form-control", :required => true, required: "" %>
<%= f.label :password, "Password", class: "control-label col-md-2 col-sm-2 col-xs-12" %>
<%= f.password_field :password, class: "form-control", :required => true, required: "" %>
<%= f.label :password_confirmation, "Password Confirmation", class: "control-label col-md-2 col-sm-2 col-xs-12" %>
<%= f.password_field :password_confirmation, class: "form-control", :required => true, required: "" %>
<%= link_to "Cancel", "", class: "btn btn-danger" %>
<%= f.submit "Submit", class: "btn btn-success" %>
<% end %>
...并根据它为圈子着色,首先检查父项是否存在:
d.parent.data.name
这是您更新的Bin:http://jsbin.com/ruyegidopo/1/edit