airblade / chartjs-ror

[Not supported - see #53] Simplifies using Chart.js in Rails
MIT License
184 stars 57 forks source link

scale x axis? #23

Closed pjammer closed 8 years ago

pjammer commented 8 years ago

Thought I'd ask this here, as i heard about a Chart.scatter plugin that scales an x-axis but I then came here to the README, since I'm using the gem.

i got an error adding

<%= line_chart @data, {width: 1000, generateLegend: true, scaleSteps: 2} %>

and

<%= line_chart @data, {width: 1000, generateLegend: true, scaleOverride: true} %>

I'll dig more, but thought I'd ask this here.

  1. Out of the box, does the x axis scale?
  2. Is there a plugin architecture i'm unaware of to use if it doesn't? I.e., how easy is it to add chartjs plugins?

Good work and good gem.

airblade commented 8 years ago

The current version of this gem bundles Chart.js v1.0.2. It doesn't know about plugins; I imagine you could add a plugin by getting the asset pipeline to pick it up after Chart.js, but I haven't tried it.

The gem doesn't do anything to the x axis; you get whatever Chart.js gives you.

What sort of error are you seeing?

pjammer commented 8 years ago

Using <%= line_chart @data, {width: 1000, generateLegend: true, scaleOverride: true} %>


chartjs-ror (2.2.0) lib/chartjs/axis_helpers.rb:27:in `each'
chartjs-ror (2.2.0) lib/chartjs/axis_helpers.rb:27:in `max'
chartjs-ror (2.2.0) lib/chartjs/axis_helpers.rb:27:in `ordinate_scale'
chartjs-ror (2.2.0) lib/chartjs/chart_helpers.rb:25:in `chart'
chartjs-ror (2.2.0) lib/chartjs/chart_helpers.rb:7:in `block (2 levels) in '
app/views/datastores/compare.html.erb:4:in `_app_views_datastores_compare_html_erb__3985059706827773447_70232126434220'

No error on scaleSteps: 2 example above anymore, i think i had a dodgy chartjs.scatter mucking up the assets dir. I got rid of it and this is the only error i am getting now, but i don't know what scaleOverride:true does anyways, just thought i'd report.

airblade commented 8 years ago

You didn't include the actual exception message so I'm not sure what the problem is. Could you post the message please?

However I suggest you leave out the scaleOverride: true altogether. I originally put it in because I wanted the y-axis scale handled differently in my app (see nnnick/Chart.js#132) – but now I think this gem should be a simple wrapper around Chart.js, without any extra functionality.

airblade commented 8 years ago

Closing this because I've upgraded the plugin (v3.0.0) to use Chart.js v2.1.4, which has a different way of scaling.