Rails chartkick: want only integer values on axes. Use discrete or something else?
The discrete
option applies only to the 'major axis' and is for a discrete axis. There's a difference between discrete and continuous axises that you should read up on.
And I just read the configuration options. Apparently you can pass a ticks
option to each axis. And the ticks are markers. You could get the minimum and maximum value for each range from your data and then spread it out with a 1 integer interval.
Thus the following should work for you:
data = [[1,1],[2,3],[3,5],[4,8],[6,4],[7,2]]
x_values = data.map(&:first)
x_range = (x_values.min)..(x_values.max)
y_values = data.map(&:last)
y_range = (y_values.min)..(y_values.max)
library_options = {
width: 600,
hAxis: {ticks: x_range.to_a},
vAxis: {ticks: y_range.to_a}
# to_a because I don't know if Range is acceptable input
}
line_chart(data, {library: library_options})
For more options, take a look at Google Chart's configuration options for line charts.