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

Projects
None yet
3 participants
@Prakriti-nith
Contributor

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"
}

Prakriti-nith added some commits Jun 26, 2018

@coveralls

This comment has been minimized.

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 added some commits Jul 15, 2018

@Prakriti-nith

This comment has been minimized.

Contributor

Prakriti-nith commented Jul 18, 2018

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

@Shekharrajak

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)

This comment has been minimized.

@Shekharrajak

Shekharrajak Jul 22, 2018

Collaborator

ChartWrapper here ?

This comment has been minimized.

@Prakriti-nith

Prakriti-nith Jul 22, 2018

Contributor

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

This comment has been minimized.

Collaborator

Shekharrajak commented Jul 22, 2018

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

@Prakriti-nith Prakriti-nith force-pushed the Prakriti-nith:listener_googlechart branch from 3de4278 to 454c58b Jul 22, 2018

@Prakriti-nith

This comment has been minimized.

Contributor

Prakriti-nith commented Jul 22, 2018

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'}}

This comment has been minimized.

@Shekharrajak

Shekharrajak Jul 22, 2018

Collaborator

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

@Prakriti-nith

This comment has been minimized.

Contributor

Prakriti-nith commented Jul 23, 2018

@Shekharrajak can you please review this PR?

@Prakriti-nith Prakriti-nith force-pushed the Prakriti-nith:listener_googlechart branch from 6ede940 to 14ecc63 Jul 26, 2018

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.

This comment has been minimized.

@Shekharrajak

Shekharrajak Jul 26, 2018

Collaborator

Open an issue to track this.

This comment has been minimized.

@Prakriti-nith

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

This comment has been minimized.

@Shekharrajak

Shekharrajak Jul 26, 2018

Collaborator

Are we using it ?

@Shekharrajak Shekharrajak merged commit e6a5e2f into SciRuby:master Jul 26, 2018

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage increased (+0.02%) to 97.623%
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment