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.
Related
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
I am adding charts on my Rails application and I started using chartkick the variety of charts that it offers are not quite what I would like.
I found in their documentation that you can use the Highcharts library. The issue is, I followed the steps but nothing happens...
Does anyone know the correct way to use these two together?
Here is the code I write: <%= column_chart #prsd_data, xtitle: "Members", ytitle: " # of publications", width: "100%", height: "100%" %>
#prsd_data is a hash that contains as keys the names of some people and as values an array of 2 integers.s
NOTE: The chart I want to generate is something like this one : Highcharts
Try this,
Add this gem "chartkick" to your gemfile
Add this <%= javascript_include_tag "https://www.google.com/jsapi" %> to your application.html.erb.
and you are good to go for any chartkick graph.
I can't seem to figure out how or if Chartkick supports table charts. I tried table_chart as if I were doing any other chart, but it didn't work. Anyone know if chartkick supports that? I couldn't find it in the documentation.
You can check kick chart for integration with rails
http://chartkick.com/
you can use like
for_line_chart
= line_chart Model.group_by_day(:created_at).count %>
pie_chart
= pie_chart Model.group(:field).count
column_chart
= column_chart Model.group_by_hour_of_day(:field).count
bar_chart
= bar_chart Model.group(:field).sum(:field)
area_chart
= area_chart Model.group_by_minute(:created_at).maximum(:field)
line_chart
= line_chart completed_tasks_charts_path
For more please consult the link shared above hopefully this will help you a lot.
There is no such thing as table chart in chartkick.
There are line, pie, column, area, bar, geo charts and timeline avaliable.
All kind of charts with usage explanations you can find on chartkick official website.
I used a plugin to create A QR Code from a plugin which says to use the below code in ruby page
<%= javascript_include_tag :defaults %>
<%= qrcode('http://www.facebook.com/', 2, 3, 'my-qrcode') %>
I was expecting an image file , instead i got a table with lots of values in it. I tried a different ways to find a QRCode image generator and the only one seems to give an image is google charts, which i find not that interesting, I used them like
<%= image_tag("http://chart.apis.google.com/chart?cht=qr&chl=#{'http://www.facebook.com/'}&chs=120x120&choe=UTF-8", :size => "120x120")%>
Does anyone knows any other useful plugin that gives me the following output
I need to see a QR code for a link (where the parameters of the link
changes)
When i click on a link below it, it should be able to download the
QRCode image.
Take a look into rqrcode. It seems to do what you want.
There is an old example app here
I have the following issue. I have a google map (using YM4r + Geokit) within Ruby on Rails, anyhow, i basically have an array of markers which are populated in the following manner
#shops.each do
|sto|
markers << GMarker.new (....)
end
They are definitely being stored fine as under 10 markers they are displayed just fine. The problem arises when there are more than 10 markers on the same page,
Further code related to displaying if this may help:
#map.overlay_global_init(GMarkerGroup.new(true, markers), "sto_markers")
in the html.erb file:
<%= GMap.header %>
<%= javascript_include_tag("markerGroup") %>
<%= #map.to_html%>
<%= #map.div(:width => 700, :height => 500)%>
Only 10 markers are displayed on screen instead of the correct amount in the markers array.
Has anyone ever encountered this issue please? i'm really at a loss on how to overcome this please
Hmm, I have never used these plugins (I prefer to work directly with the API, much easier :)), so this is just random thinking.
Have you looked in the source of the rendered HTML? In there you should have a Javascript Object or Array with all your markers defined. If all of them do show up there, then it is easier to pinpoint if the problem is on the Javascript or the Rails side. (That is what <%= #map.to_html%> should do unless I'm completely off).
Update:
After some looking into the plugin, I can't really tell what the error can be, however since it do put out everything in clear Javascript in the file, it would probably help a lot if you can post the rendered HTML source. I believe that you will find the solution by looking there.