Ruby on Rails - Chartkick - Highcharts drilldown - ruby-on-rails

I have been playing around with the chartkick gem using highcharts.js and was wondering if anyone had been able to get drilldowns to work. If so what options did you pass in to get it to work?

I think you are looking for something like this
http://www.highcharts.com/demo/column-drilldown
Hope it helps you .

Related

Ruby on Rails Chartkick data

I am working on a multiple series line chart in ruby on rails. I have passed to the chart data as such:
<%= line_chart #budget.transactions.group(:category).group(:date).sum(:amount) %>
In the developer tools I looked at the script that populates the chart and it looks like:
new Chartkick.LineChart("chart-2", [{"name":"debt","data":[["2017-04-19",5.43],["2017-04-20",60.0]]},
{"name":"entertainment","data":[["2017-04-19",30.0]]},
{"name":"food","data":[["2017-04-20",15.0],["2017-04-21",20.0]]},
{"name":"housing","data":[["2017-04-02",17.33],["2017-04-10",20.0],["2017-05-01",522.0]]},
{"name":"transportation","data":[["2017-04-20",50.0]]},
{"name":"utilities","data":[["2017-04-19",35.0],["2017-04-21",20.0],["2017-04-27",77.34]]}], {});
To me the format for the data being passed to the chart seems correct, but the output... not so much. Also I was thinking using the Ruby Date class, rather than DateTime was causing a problem but I'm not sure. Any help appreciated.
enter image description here

Chartkick yAxis and Rails

Please can anyone help me with this issue?
I have A ruby on rails app and I am trying to use ChartKick.
I have the following code in my Controller to get all Publications:
#mentor_pub = Publication.all.where(user: current_user).order("mentor ASC")
And I am using the code below in my views.
<%= column_chart #mentor_pub.group(:mentor).count, height: "600px", discrete: true%>
You can see the image of what I am talking about here
the chart is displaying the way I want it, but The Yaxis is displaying decimal numbers instead of integers.
Please How would I modify the Yaxis to show integers?
Chartkick uses Google Visualization under the hood and allows you to pass options directly to the library using the library option like so:
<%= line_chart data, library: {backgroundColor: "#eee"} %>
for your exact problem you'll have to look into Googles documentation or this stackoverflow answer https://stackoverflow.com/a/16036721/390977 might help.

trouble using angularjs with slim in a rails project

I've finally decided to give angularjs a whirl and i'm running into some early trouble.
I'm using Rails 3.2 and the Slim template gem for the view.
I'm just trying the example from the angularjs site here: http://angularjs.org/#todo-html
Here's the relevant bit:
<div ng-controller="TodoCtrl">
<span>{{remaining()}} of {{todos.length}} remaining</span>
Which in slim would be something like:
div(ng-controller="TodoCtrl")
span {{remaining()}} of {{todos.length}} remaining
The problem is Slim just prints:
{{remaining()}} of {{todos.length}} remaining
literally as a string.
Anyone able to get Slim and Angular to play together?
I finally got it to work.
I had to go into my layout and do this:
html(ng-app='')
You can probably add that to a div on the particular page also.
div(ng-app='')
div(ng-controller="TodoCtrl")
span {{remaining()}} of {{todos.length}} remaining
Hopefully this helps someone. It took me a bit to figure out.
You can also do it like so:
html [ng-app]
Or:
div [ng-app]
div [ng-controller="TodoCtrl"]
span {{remaining()}} of {{todos.length}} remaining

rails: autocomplete

how do I create autocomplete that works exactly like how the tags work in here? (stackoverflow)?
There are autocomplete plug-ins but not ones where you can separate your tags by commas and do autocomplete for each tags.
You'd need Token Fields
http://railscasts.com/episodes/258-token-fields
Try the jquery autocomplete the back-end is done in PHP though you can convert it on rails
http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/
Here are some demos
http://jquery.bassistance.de/autocomplete/demo/

Ruby On Rails: Fetching records

I'm looking for a tutorial or a piece of code that can leads me to create a page
where we can find only 10 data rows per page and navigating with Ajax previous/next arrows
and also page number (i.e.: < 1 2 3 ... 10 > ).
Thank you very much.
A good place to start is Mislav's will-paginate plugin. The Readme at that link should explain how to use it.
Edited:
There's also a screencast on RailsCasts about Ajax pagination. I haven't watched it, but his stuff is usually really high-quality and easy to follow.
it's not ajax but maybe it's useful for you... when you use haml and haml_scaffolding in rails it's authomatic the pagination using this kind of sacffolding

Resources