-
Notifications
You must be signed in to change notification settings - Fork 92
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
Adds ability to generate Material charts when applicable #88
Changes from all commits
4e9d867
45830d2
0e1bda1
d294d30
74c1d54
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
PATH | ||
remote: . | ||
specs: | ||
google_visualr (2.4.0) | ||
google_visualr (2.4.1) | ||
|
||
GEM | ||
remote: https://rubygems.org/ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,6 +69,46 @@ def draw_js(element_id) | |
js << "\n };" | ||
js | ||
end | ||
|
||
# material js option | ||
def material_package_name | ||
chart = chart_name.gsub("Chart","") | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Trailing whitespace detected. |
||
# column chart uses the "Bar" namespace | ||
# https://google-developers.appspot.com/chart/interactive/docs/gallery/columnchart#Material | ||
if chart == "Column" | ||
chart = "Bar" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unnecessary spacing detected. |
||
end | ||
|
||
return chart | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redundant |
||
end | ||
|
||
def to_material_js(element_id) | ||
js = "" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unnecessary spacing detected. |
||
js << "\n<script type='text/javascript'>" | ||
js << load_material_js(element_id) | ||
js << draw_material_js(element_id) | ||
js << "\n</script>" | ||
js | ||
end | ||
|
||
def load_material_js(element_id) | ||
"\n google.load('visualization','1.1', {packages: ['#{material_package_name.downcase}'], callback: #{chart_function_name(element_id)}});" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. [144/80] |
||
end | ||
|
||
def draw_material_js(element_id) | ||
js = "" | ||
js << "\n function #{chart_function_name(element_id)}() {" | ||
js << "\n #{@data_table.to_js}" | ||
js << "\n var chart = new google.charts.#{material_package_name}(document.getElementById('#{element_id}'));" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. [117/80] |
||
@listeners.each do |listener| | ||
js << "\n google.visualization.events.addListener(chart, '#{listener[:event]}', #{listener[:callback]});" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. [116/80] |
||
end | ||
js << "\n chart.draw(data_table, google.charts.#{material_package_name}.convertOptions(#{js_parameters(@options)}));" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. [126/80] |
||
js << "\n };" | ||
js | ||
end | ||
# end material js option | ||
end | ||
|
||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module GoogleVisualr | ||
VERSION = "2.4.0" | ||
VERSION = "2.4.1" | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Space missing after comma.