Skip to content
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

Support for bubble charts #235

Open
portwood opened this issue Feb 29, 2016 · 10 comments
Open

Support for bubble charts #235

portwood opened this issue Feb 29, 2016 · 10 comments

Comments

@portwood
Copy link

Any chance you could add support for bubble charts? Google Charts and Highcharts support them, and I hope you can add them to your product roadmap.
Thanks.

@lettergram
Copy link

It's been supported on: https://github.com/ankane/chartkick.js

Will work on implementing for chartkick

@ankane
Copy link
Owner

ankane commented Jan 30, 2017

Hey @lettergram, thanks for wanting to help with this. Right now, support for bubble charts in Chartkick.js is experimental, so don't think it makes sense to add it to Chartkick.

@lettergram
Copy link

@ankane Sounds good, is there something you could use help with?

@ankane
Copy link
Owner

ankane commented Feb 1, 2017

@lettergram thanks for offering. At the moment, I'm hesitant to add new chart types. The most common types are already covered and it increases maintenance.

@alexmc6
Copy link

alexmc6 commented Mar 3, 2017

I am not sure of the status of bubble charts in Chartkick or Chartkick.js. Are they still experimental a year later?

@Spone
Copy link

Spone commented Jan 13, 2018

Seems to be available in Chart.js as well: http://www.chartjs.org/samples/latest/scriptable/bubble.html

@josephbridgwaterrowe
Copy link

josephbridgwaterrowe commented Dec 21, 2019

I know this issue is old, but I thought I would chime in with the hope of helping to put it to rest 😄

I achieved this with a simple monkey patch...

module Chartkick
  module Helper
    def bubble_chart(data_source, **options)
      chartkick_chart "BubbleChart", data_source, options
    end
  end
end

I'd be happy to add this in a PR if people feel comfortable adding BubbleChart support now?

One thing I found awkward was when grouping and counting with ActiveRecord, i.e.

Model.group(:x, :y).count

# {[30, 70] => 1, [20, 70] => 1], [60, 40] => 1], [70, 30] => 1], [20, 20] => 1], [50, 50] => 2]}

I would need to "flatten" the results, which I chose to do like so (for now)...

Model.group(:x, :y).count.map { |k, v| k.concat([v]) }

# [[30, 70, 1], [20, 70, 1], [60, 40, 1], [70, 30, 1], [20, 20, 1], [50, 50, 2]]

The reason I mention this is that I wonder if there should be a helper (another gem?) to help massage these kinds of results?

@jcquarto
Copy link

One thing I found awkward was when grouping and counting with ActiveRecord, i.e.

Model.group(:x, :y).count

# {[30, 70] => 1, [20, 70] => 1], [60, 40] => 1], [70, 30] => 1], [20, 20] => 1], [50, 50] => 2]}

I would need to "flatten" the results, which I chose to do like so (for now)...

Model.group(:x, :y).count.map { |k, v| k.concat([v]) }

# [[30, 70, 1], [20, 70, 1], [60, 40, 1], [70, 30, 1], [20, 20, 1], [50, 50, 2]]

The reason I mention this is that I wonder if there should be a helper (another gem?) to help massage these kinds of results?

I thought that was the point of extending chart_json in Enumerable ? Try calling .chart_json on your data after querying for it.

@jcquarto
Copy link

@lettergram thanks for offering. At the moment, I'm hesitant to add new chart types. The most common types are already covered and it increases maintenance.

I get it. However, I have to add -- three years later -- that a wrapper that has so many unimplementeds in it, suffers because of lack of confidence. There are umpteen different Google Charts in their API, and ChartKick does a PHENOMENAL job ... on <10. So it doesn't really act like "oh I can use this gem and easily work with Google Charts". Rather, it's "well as long as I only want to take on the easy low-hanging fruit, I can use the gem ....". I know it's a tough call balancing stuff out , but I've been working with it for around a week and I'm feeling the limitation.

Can you give some details for how you are converting data on the Ruby side and outputting it as JS on the browser? Google's JS seems to want a set of data to start with the column names and then outputting the data as an array of arrays in the JS sent to the browser. It's unclear to me where you picked the column names off of and how you attached that to the data

(on the Ruby side the ActiveRecord::Relation seems to want to resolve as a Hash, not an Array)

@npinochet
Copy link

Are there still plans to add this chart type? There's already a PR that implements it #411

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants