New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Line chart x-axis values other than date and time #38
Comments
This is not possible w/ Chartkick. You could use a column chart. new Chartkick.ColumnChart("chart-1", {"1":11,"2":6,"3":3,"4":2,"5":8}); |
Is it still true that LineChart only work with date time values? Thanks. |
Yes, still true. |
I found my way with it :) Thanks a lot for sharing. |
This is now possible with the |
How do you use the discrete option? |
I'm also interested about it. @camiloribeiro could have been great to share your solution even if it's now 3 years old.... :/ |
In the view, add the - # app/views/charts/index.html.haml
- # ...
= line_chart charts_test_path, discrete: true, height: "400 px" In the controller, where the data is filled, the x-axis values are defined as the keys of the data hash. # app/controllers/charts_controller.rb
class ChartsController < ApplicationController
def index
end
# GET /charts/test.json
def test
@test_series = [
{
name: "Series 1",
data: { "x1": 1, "x2": 5, "x3": 9 }
},
{
name: "Series 2",
data: { "x1": 14, "x2": 25, "x3": 2 }
}
]
render json: @test_series.chart_json
end
end Suppose, you have an array of x-values, {
name: "Series 1",
data: Hash[x_values.collect { |x| [x, y_value(x)] }]
} |
Hi,
Trying to create my first chart.
What I want to do is create a line chart with a series of data (no time or date associated with it)
Below lines did not work,
new Chartkick.LineChart("chart-1", { 11,6,3,2,8});
new Chartkick.LineChart("chart-1", { "1":11,"2":6,"3":3,"4":2,"5":8});
How can I make this work?
Cheers
The text was updated successfully, but these errors were encountered: