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

Added Charteditor #96

Merged
merged 18 commits into from
Aug 2, 2018
Merged

Conversation

Prakriti-nith
Copy link
Contributor

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

This PR is opened over the commits of Chartwrapper and is in progress (code, tests, documentation and examples all are incomplete). User needs to set class_chart as Charteditor.
Actually, I am facing a problem in this. Charteditor is working fine in rails app but in IRuby notebook, the dialog box is appearing behind the notebook as in the examples here.
I can see it working (that is above the content of jupyter notebook) if I explicitly set the z-index of the dialog box (ChartEditor) in developer tools. But that is of no help as I can not change the code of the dialog box. Is there any way I can make this work?

Also, I wanted to know why are we generating the googlecharts' code with script and without script in display.rb. We have already defined script tags in the template so we'll definitely be generating the script without the script tags?

@Prakriti-nith Prakriti-nith changed the title Charteditor wrapper Added Charteditor Jun 10, 2018
@Prakriti-nith
Copy link
Contributor Author

As it is a continuation of ChartWrapper, I will rebase it after ChartWrapper gets merged.

@coveralls
Copy link

coveralls commented Jul 14, 2018

Pull Request Test Coverage Report for Build 662

  • 533 of 538 (99.07%) changed or added relevant lines in 11 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.1%) to 98.014%

Changes Missing Coverage Covered Lines Changed/Added Lines %
lib/daru/view/adapters/googlecharts.rb 6 7 85.71%
lib/daru/view/adapters/googlecharts/display.rb 98 100 98.0%
spec/adapters/googlecharts/generate_javascript_spec.rb 237 239 99.16%
Totals Coverage Status
Change from base Build 648: 0.1%
Covered Lines: 3110
Relevant Lines: 3173

💛 - Coveralls

@coveralls
Copy link

Pull Request Test Coverage Report for Build 610

  • 312 of 313 (99.68%) changed or added relevant lines in 8 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.3%) to 97.292%

Changes Missing Coverage Covered Lines Changed/Added Lines %
lib/daru/view/adapters/googlecharts.rb 5 6 83.33%
Totals Coverage Status
Change from base Build 608: 0.3%
Covered Lines: 2731
Relevant Lines: 2807

💛 - Coveralls

@Prakriti-nith
Copy link
Contributor Author

@Shekharrajak can you please review this PR?

@Prakriti-nith
Copy link
Contributor Author

ChartEditor is working fine in rails app but in IRuby notebook, the dialog box is appearing behind the notebook as in the example here.
Below are the screenshots of rails example (can see in this PR in demo_daru-view).
ce1
ce2

@@ -62,7 +62,9 @@ def google_table_version
end

def package_name
'table'
return 'table' unless
Copy link
Member

Choose a reason for hiding this comment

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

ChartEditor is going through data_table_iruby.rb :O . But why ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ChartEditor works for both google charts and tables, and code to generate the table is written in data_table_iruby.rb. charteditor package is loaded in Google Datatables when chart_class is set to Charteditor.

Copy link
Member

Choose a reason for hiding this comment

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

Is there any example or documentation written, which describes this usecase ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have written the rails examples in demo_daru-view and also in the method documentation here.

Copy link
Member

Choose a reason for hiding this comment

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

Write examples in web apps and iruby as well, if haven't.

js << "\n \t\toptions: #{js_parameters(@options)},"
js << "\n \t\tcontainerId: '#{element_id}',"
js << "\n \t\tview: #{extract_option_view}"
js << "\n \twrapper_#{element_id.tr('-', '_')} = "\
Copy link
Member

Choose a reason for hiding this comment

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

Same code 2 times ??

def draw_wrapper
return "\n \twrapper.draw();" if
def draw_wrapper(element_id)
return "\n \twrapper_#{element_id.tr('-', '_')}.draw();" if
Copy link
Member

Choose a reason for hiding this comment

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

Just want to know, what if we don't provide element_id ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we use only the wrapper (without id) then the chart editor will work only on the last chart. That is, edit button (of any chart) will show the dialog box for the last chart only.

user_options[:chart_class].to_s.capitalize == 'Chartwrapper'
''
js = ''
js << "\n \twrapper_#{element_id.tr('-', '_')}.draw();"
Copy link
Member

Choose a reason for hiding this comment

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

same line at 172 .

@@ -35,6 +35,12 @@
chart_class: 'ChartWrapper'
)
}
let (:plot_spreadsheet_charteditor) {
Daru::View::Plot.new(
data_spreadsheet, {width: 800, view: {columns: [0, 1]}}, chart_class: 'Charteditor'
Copy link
Member

Choose a reason for hiding this comment

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

line length

@Prakriti-nith
Copy link
Contributor Author

@Shekharrajak can you please review this PR also?

@Shekharrajak
Copy link
Member

Please resolve conflicts and run all the examples again.

@Prakriti-nith
Copy link
Contributor Author

Prakriti-nith commented Jul 29, 2018

@Shekharrajak I have created a new module DisplayJavascript as the module length of Display increased to > 200 and rubocop was throwing the error. I have also rechecked all the examples of GoogleCharts and committed.

@Prakriti-nith
Copy link
Contributor Author

@Shekharrajak I have separated the modules in different files. As the same thing needs to be done with the Export GoogleCharts PR, I will update that one after this gets merged.

@@ -0,0 +1,148 @@
module GenerateJavascript
Copy link
Member

Choose a reason for hiding this comment

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

It should be inside GoogleVisualr module, isn't it ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

module GenerateJavascript is already included in BaseChart and DataTables class which is in GoogleVisualr, so, I think it is not required.

@@ -62,7 +62,9 @@ def google_table_version
end

def package_name
'table'
return 'table' unless
Copy link
Member

Choose a reason for hiding this comment

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

Write examples in web apps and iruby as well, if haven't.

@Shekharrajak Shekharrajak merged commit 6c5b0e7 into SciRuby:master Aug 2, 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