I have a scaffold called statistics with the following data:
Year, Sales, Agents.
Year is a select with several years and sales and agents are integer fields.
I installed the gem Chartkick to be able to visualize the data of these 3 columns (that are all numeric) in my graph. For this in the controller I have:
def show
@estadisticas = Estadistica.all
respond_to do |format|
format.html {render template: "estadisticas/graficaVentas"}
end
end
And then I created within the scaffold "statistics" a file called graficaVentas.html.erb
where it is redirected when I click on show and there I put it:
<h1>Grafica Ventas</h1>
<%= pie_chart Estadistica.pluck do |estadistica|%>
<%end%>
This way I can see my graph, but it only takes me the Sales data (I guess it's because it's the first column), but not Agents.
How can I get hold of Agent data as well and show me the names: Yearbook, Sales and Agents instead of just the number?