我是这方面的新手(JS、Rails 和 highcharts,但它们非常好),我非常感谢一些帮助。我的故事是我有一个for loop
并且我想显示 for 循环的结果highcharts
。我该怎么做?
<p>A n: <%= @calculation.a_n %></p>
<p>H: <%= @calculation.h %></p>
<p>K: <%= @calculation.k %></p>
<p>P: <%= @calculation.p %></p>
<p>A: <%= @calculation.a %></p>
<small>T: <%= @calculation.created_at %></small>
<br /><br />
<%= @calculation.a_n %> <br />
<% @amount = (@calculation.h * @calculation.k) %>
<% @percent = (@calculation.h * @calculation.k) / @calculation.p %>
<% for i in 0..@calculation.a do %>
<% @newAmount = ((@amount/(@percent)) + @amount) %>
<%= "#{i}" + " - #{@amount}" %><br />
<% @amount=@newAmount %>
<% end %>
<script type="text/javascript" charset="utf-8">
$(function() {
new Highcharts.Chart({
chart: {
renderTo: "calculations_chart"
},
title: {
text: "Sum for a year"
},
xAxis: {
text: "Years"
},
yAxis: {
title: {
text: "Sum"
}
},
series: [{
data: //for loop?
}]
});
});
</script>
<div id="calculations_chart" style="width:560px; height:300px;"></div>