chartkick: library options hash does not work !!

It’s imperative that I use chartkick in my web app; however, there’s one issue stopping me from using it: I’m not able to change the background color or use any library options within the ‘library’ hash when creating the chart. I’ve tested charting libraries Chart.js and Highcharts.js, and the results are the same. Whatever library options I pass, none of them work. Am I doing something wrong? Here’s an example of my chart:

<%= line_chart User.group(:created_at).count, library: {backgroundColor: "#555"} %>

I’m using Chartkick 2.0. Is anyone else having this issue?

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 16 (3 by maintainers)

Most upvoted comments

Can someone create a JS Fiddle to reproduce? With Highcharts, you need to use:

line_chart data, library: {chart: {backgroundColor: "#eee"}}

http://api.highcharts.com/highcharts#chart.backgroundColor

Chart.js doesn’t have an option for background color, but you use CSS to set it.

update, found the solution. but ruby can’t instantiate javascript object from ruby object. is there any solution for this?

    <%= timeline @js_array, library:
                                 {title: "Company Performance",
                                  hAxis:{
                                      minValue: "new Date(#{@today})",
                                      maxValue: "new Date(#{@tomorrow})",
                                      title:"Date",
                                      gridlines:
                                          {count:3, color:"#CCC"}, format:"dd-MM H:m:s"}}
    %>

For those coming on across this closed issue… The following worked for me (from a haml file):

= line_chart([{name: 'Projects', data: user_stats, library: {lineTension: 0, pointRadius: 0}}])

NOTE: pointRadius, not pointSize!

And lineTension: 0 did indeed create straight-line, point-to-point line.