我正在尝试使用 Rails 7 使用不同的 div(或 svg)id 在页面上显示多个 d3 图表:
view.html.erb
<%= content_tag "svg", class: 'chart', id: raw(chart_type)+'_'+raw(chart_num), data: {chart_type: chart_type, chart_num: chart_num} do %>
<script>
line('#line_1');
</script>
<% end %>
javascrip