allow decoupling of chart name and class name #40

Merged
merged 1 commit into from Oct 16, 2012

Projects

None yet

3 participants

@greinacker
Contributor

From my comment in issue #38 -

I wanted to override individual chart types (e.g. GoogleVisualr::Interactive::BarChart) to carry some extra data around before rendering. In my case I made a "ClickableBarChart". This also required redefining BaseChart.to_js, because it uses class_name to specify the Google chart type. I propose we have something like "chart_name" as a property, and in BaseChart that simply returns class_name...but in subclasses this could be overridden to be whatever was necessary.

The attached code implements this...

@travisbot

This pull request passes (merged 8284f11 into 13c76cb).

@greinacker
Contributor

Sample code using this:

class ClickableBarChart < GoogleVisualr::Interactive::BarChart

  def chart_name
    "BarChart"
  end

  # other fancy custom clickable bar chart code here
end
@winston
Owner
winston commented Oct 15, 2012

Hi, sorry for taking such a long time to get back!

Anyway, the change looks good. But I am thinking of putting this chart_name method in packages.rb instead.

Will that still work for your code? I believe it should. Let me know.

Thank you!

@greinacker
Contributor

Seems to me moving it to packages.rb should be fine.

@winston winston merged commit 8284f11 into winston:master Oct 16, 2012

1 check passed

default The Travis build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment