app/views/stocks/show.html.haml
.page-header
%h2 Calculation result
%p#notice= notice
.row
.col-md-2
%p#name
%b Name:
= @stock.name
%p#price
%b Price:
= '%.2f' % @stock.price
%p#quantity
%b Quantity:
= @stock.quantity
%p#percentage
%b Percentage:
= '%.2f' %@stock.percentage
%p#years
%b Years:
= @stock.years
.col-md-3
%table.table.table-striped.col-sm-4
%thead
%th
Year
%th
Price
%tbody
- @calculation_result.each do |row|
%tr{data: {year: row[:year]}}
%td
=row[:year]
%td
- if row[:stock_price] < @max_value_show_as_long
='%.2f' % row[:stock_price]
- else
='%.3E' % row[:stock_price]
.col-md-7
%canvas#stock_graph{height: '450', width: '600'}
:javascript
var lineOptions = {
bezierCurve: false,
animation: false
};
var data = {
labels : #{@labels_for_chartjs},
datasets : [
{
fillColor : "rgba(220,220,220,0.5)",
strokeColor : "rgba(220,220,220,1)",
pointColor : "rgba(220,220,220,1)",
pointStrokeColor : "#fff",
data : #{@calculation_result_for_chartjs}
}
]
};
myNewChart = new Chart($("#stock_graph").get(0).getContext("2d")).Line(data, lineOptions)
%hr
= link_to '← Back', :back, class: 'btn'
= link_to 'Edit', edit_stock_path(@stock), class: 'btn'