【发布时间】:2016-05-07 23:32:33
【问题描述】:
这是我的目标,我有一堆数据,一个包含名称值的名称数组,以及相同的重量、高度、颜色。
所以在我的控制器功能中,我有以下内容 我的数据库名称人
def display
people= Person.all
end
在 display.html.erb 里面:
<h1> Display Result</h1>
<div id='chart'>
<% @people.each do |x| %>
<svg width="<%=x.weight%>" height="<%=x.height%>">
<rect width = "<%=x.weight%>" height="<%=x.height%>" style="fill:<%=x.color%>;stroke-width:3;stroke:black">
<text fill="#ffffff",50,50><%= x.name %></text>
</svg>
<% end %>
</div>
【问题讨论】:
标签: ruby-on-rails html svg html5-canvas