Rails 4: Removing grid lines chartkick?

2019-07-22 11:39发布

问题:

Hi I am trying to make that code work in order to remove both axis using Chartkick with rails 4:

<%= line_chart Score.where(employee_id: params[:id]).limit(10).group(:created_at).sum(:average), :library => {hAxis: {lineColor: 'transparent'}, vAxis: {lineColor: 'transparent'}, title: "#{@employee.name} latest results"}, max: 5.5, min: 0%>

But it does not work here is what I get:

I just want the blue line, I do not want the grid lines and the axis names.

thanks for your help.

回答1:

I found the answer: So I do use "google chart" with the ruby gem chartkick.

Here is what worked for me:

<%= line_chart Score.where(employee_id: params[:id]).limit(10).group(:created_at).sum(:average), discrete: true, library: {vAxis: {gridlines: {color: "transparent"}}}%>

Its actually like @chad answer but after researching and trying, the "L" in "gridlines" must not be capital.



回答2:

I'm not 100% sure you're using Google Charts but if so, you want to set vAxis.gridLines.color to 'transparent':

<%= line_chart foo, library: { vAxis: { gridlines: { color: 'transparent' } } } %>