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

Handling events in GoogleCharts #100

Merged
merged 8 commits into from
Jul 26, 2018

Conversation

Prakriti-nith
Copy link
Contributor

@Prakriti-nith Prakriti-nith commented Jun 26, 2018

With this feature, a user can apply multiple listeners to a google chart/table to handle various events. I have added jspdf dependency for web frameworks because a user can at least use ready event to export the chart in pdf format. There are fewer examples provided on the official website. Examples.
Event handling can be done in Highcharts easily through the highcharts options like this, so in googlecharts also, we are handling events through options (in third parameter).
Syntax:
Provide this in user_options (third parameter)

listeners : {
event_name: "callback_code",
another_event_name: "callback_code"
}

@coveralls
Copy link

coveralls commented Jul 13, 2018

Pull Request Test Coverage Report for Build 635

  • 156 of 157 (99.36%) changed or added relevant lines in 9 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.02%) to 97.623%

Changes Missing Coverage Covered Lines Changed/Added Lines %
spec/adapters/googlecharts/base_chart_spec.rb 2 3 66.67%
Totals Coverage Status
Change from base Build 626: 0.02%
Covered Lines: 2629
Relevant Lines: 2693

💛 - Coveralls

@Prakriti-nith
Copy link
Contributor Author

@Shekharrajak can you please review this PR and let me know if there are any changes that I have to make?

Copy link
Member

@Shekharrajak Shekharrajak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Separate the other PRs code from this

js << "\n \t\toptions: #{js_parameters(@options)},"
js << "\n \t\tcontainerId: '#{element_id}',"
js << "\n \t\tview: #{extract_option_view}"
js << extract_chart_wrapper_options(data, element_id)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ChartWrapper here ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add_listeners_js('wrapper') in this method was generating rubocop error so I've created another method extract_chart_wrapper_options in the common module display.

@Shekharrajak
Copy link
Member

Please write examples which can be useful in real world application.

@Prakriti-nith
Copy link
Contributor Author

Right now, I have added these examples.

)
}
let (:table_spreadsheet) {
Daru::View::Table.new(
data_spreadsheet, {width: 800}
)
}
let(:data_table) {Daru::View::Table.new(data)}
let(:user_options) {{chart_class: 'Chartwrapper'}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better if you write new variables for new specs, rather than modifying existing variables completely.

@Prakriti-nith
Copy link
Contributor Author

@Shekharrajak can you please review this PR?

sh "curl -# http://www.google.com/jsapi -L --compressed -o lib/daru/view/adapters/js/googlecharts_js/google_visualr.js"
end
end
# FIXME: Updating jsapi is causing error in IRuby notebook and Googlecharts do not work.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Open an issue to track this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#99


task :loader do
say "Grabbing loader.js from the google website..." do
sh "curl -# http://www.gstatic.com/charts/loader.js -L --compressed -o lib/daru/view/adapters/js/googlecharts_js/loader.js"
end
end

task :jspdf do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we using it ?

@Shekharrajak Shekharrajak merged commit e6a5e2f into SciRuby:master Jul 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants