Reputation: 573
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}] %>
Upvotes: 7
Views: 2978
Reputation: 31
I know this thread is a bit old but it looks like an answer still doesn't exist here yet. This is a solution I just found while building out charts with Chartkick recently.
<%= line_chart [{name: "Series A", data: series_a}],
curve: false,
dataset: { pointRadius: 0} %>
Upvotes: 3
Reputation: 2323
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.
Upvotes: 9