Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making line straight in a line_chart using chartkick and removing dots

I am using a very nice gem to create charts using Ruby on Rails. But I am struggling to make a line chart with straight lines connecting the dots. It always creates curves. I need straight lines. Also I want to know if someone knows how to remove the dots from the line. I could not find a way to do it.

Chartkick.options = {
  height: "300px",
  min: -5, 
  max: 10,
  discrete: true,
}

<% series_a = {"10" => -5, "11" => 9,"12" => 3,"13" => -1,"14" => 4,"15" => -2,"16" => -4} %>

<%= line_chart [{name: "Series A", data: series_a}] %>
like image 679
erickva Avatar asked Jun 01 '14 08:06

erickva


1 Answers

So, you need to use 'library'. That lets you describe any preferences you have from Google charts, or from highcharts.

So you'll probably want to do something like the following:

<%= line_chart [{name: "Series A", data: series_a}], library: {curveType: "none", pointSize: 0}  %> 

Two things about the above line. Firstly, I do not normally use ruby-on-rails, so syntax may be off. Secondly, if you are using highcharts, it probably won't be {curveType: "none", pointSize:0} that is GoogleChart specific. For highcharts, you will have to lookup the highchart options, and look for something similar.

like image 158
Derek Halden Avatar answered Oct 09 '22 09:10

Derek Halden