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

Initial implementation of numeric report charts. #3894

Merged
merged 19 commits into from Sep 8, 2015

Conversation

martinpovolny
Copy link

Replacement for #3528 w/o use of "Consolidation"

Work towards numeric report charts: https://bugzilla.redhat.com/show_bug.cgi?id=1213294

@martinpovolny martinpovolny changed the title Initial implementation or numeric report charts. Initial implementation of numeric report charts. Aug 17, 2015
@martinpovolny
Copy link
Author

Average number of CPUs per provider

chart-cpus-1
chart-cpus-2
chart-cpus-3
chart-cpus-4

@martinpovolny
Copy link
Author

Number of VMs per host

chart-vms-1
chart-vms-2
chart-vms-3
chart-vms-4

@dclarizio dclarizio added ui and removed build labels Aug 17, 2015
@dclarizio
Copy link

@martinpovolny This is looking pretty good . . . I did a report on disk space and noticed that maybe we could use the same formatting for the legend markers as we have in the report, as seen below:

Report sort criteria
report sort

Report chart options
report chart

Note the legends with all the zeroes and no commas
bar chart

Report shows them as humanized, to MB, GB, TB, etc
bar chart 2

Same in column view with vertical axis legends
col chart

This may be a jqPlots issue, but something to keep in mind for the future C3 charting is that with the flash charts, we could hover over a bar or chart item or node on a line chart and it would show a popup with the actual value. Would be a nice feature to keep.

Pie charts for values look good and they have hover text over the pie slices, but same note about formatting of the values shown
piechart

Pie chart using counts didn't fare as well, chart is blank.
piecounts

Column chart based on counts results in a line chart (strange)
chartcolcounts

colcountchart

@dclarizio
Copy link

@martinpovolny Lots of feedback above, let's discuss where you're at tomorrow morning. Thx, Dan

@martinpovolny
Copy link
Author

@dclarizio :

  1. fixed the missing chart and the line chart -- seems chart type information was missing in the json
  2. added a spec for 2 main cases of the count-based charts -- this shoul cover the case above
  3. fixed some problem in the report editor when switching chart types

@dclarizio
Copy link

@martinpovolny more testing . . .

Summary tab set to counts with no aggregations set, Chart tab should not allow values. Currently lets you select values, but the data column has a null choice. If no aggregations are being done, it should show Counts as a string with no choice and, of course, not show the column drop down. Here are the screenshots:
summary tab
charts tab

Running the report with counts, not sure the output is correct. I can see some break lines in the report output and 1 of them lines up with the legend and has a value of 3 showing. The others, I think the name is too long so I can't see the count in the legend??? The chart shows percentages (which is probably ok), but hovering the mouse over the pie slices doesn't tell me which provider it is or the count, there is no popup. Basically, I can't tell if the chart matches the report.
count chart report

@dclarizio
Copy link

@martinpovolny Simple test, ran the "Vendor and Guest OS" report with the stacked bar chart (so 3d charts by count) and the charts look identical, so it seems those are working as before. Thought I would post some good news as well. :)

Before:
vendorandguest before

After:
vendorandguest after

@dclarizio
Copy link

@martinpovolny More good news, testing of column charts with values. Only issue here is from before, Y axis labels need formatting. Would be nice to have hover over values, but we can wait for C3.

Chart configuration:
colchartsummary
colchart charts

Chart/Report:
colchart report

@dclarizio
Copy link

@martinpovolny Same issues as above for bar charts (X axis labels crazy) . . . they look pretty good tho:

barchart

@martinpovolny
Copy link
Author

@dclarizio : Thinking about the use of MiqReport::Formatting for the formatting of the axis labels. The problem is that the ticks for numeric values are calculated by the javascript library. The same most likely holds for the flash charts.

For one we don't know the values for the ticks when calculation the chart. Then depending on type of chart we might have a problem with associating labels of the axis with the values in the chart. In jqplot you can have a formatter class for the ticks or you can use a special axis renderer for a couple of typical axis such as Date and Cathegory.

Seems to me that the proper way would be providing formatters based on column types similarly to what we have in db/fixtures/miq_report_formats.yml -- bytes, mHz, percent etc. No idea how to do this for the flash charts. Also might be work investigating what we will do if we use the C3 charts instead and do in in a general way. Definitely even though the labels are pretty ugly (I can rotate them at least to fit better) I would say that we need a separate issue and some research for this.

@himdel : do you know that ways one can use in the C3 to format axis values?

@himdel
Copy link
Contributor

himdel commented Aug 20, 2015

@martinpovolny sure, I think this should be useable :)

@martinpovolny
Copy link
Author

@himdel : http://www.jqplot.com/docs/files/plugins/jqplot-canvasAxisTickRenderer-js.html#$.jqplot.CanvasAxisTickRenderer.formatter

so we need

  1. some javascript code that would take understand how to format according to the db/fixtures/miq_report_formats.yml formats and
  2. then we just pass in the format of the column that is being projected on the axis along with the other options as we generate the charts

@dclarizio : I'd probably create an issue for that

at least is seems that we can use most of the work we do on the charts for both jqplot and C3

@martinpovolny
Copy link
Author

@himdel : do you know about some nice js library we could use? https://github.com/adamwdraper/Numeral-js maybe?

@himdel
Copy link
Contributor

himdel commented Aug 20, 2015

Uh, looking at the formats, angular actually has most of these as filters but it'd be rather hacky to use here I guess... I've never heard of Numeral.js but looks like it could be useful for the numeric formats. We already have moment.js so we can use that for dates/times, and possibly something like sprintf-js (any version) to cover the rest?

I can look more into it tomorrow .. sounds like simply reimplementing most of miq_report/formatting.rb in JS, right?

@martinpovolny
Copy link
Author

@himdel : seems to me to be the best way to reimplement that in JS. In the reports we have way for the user to specify his/her format so we might actually end really reimplementing it so that we have the same format specification on both sides.

@martinpovolny
Copy link
Author

@himdel : if you can look into it, I'd be glad. I can make the charts pass in the formating information for the right column, but If you could help with the javascript implementation of the formating function, it would be great help for me. Your experience with variety of javascript libraries would be usefull here ;-)

@himdel
Copy link
Contributor

himdel commented Aug 21, 2015

@martinpovolny sure, no problem :) I'm assuming we want to keep the same function names mentioned in :function :name, I'll put it under .. say, ManageIQ.charts.formatters or something like that, ok?

@himdel
Copy link
Contributor

himdel commented Aug 21, 2015

Support for strftime-like date format specifiers in format_date will depend on this moment-strftime PR. Is there any chance we may need other format specifiers not mentioned in the yaml?

@himdel himdel mentioned this pull request Aug 21, 2015
3 tasks
@dclarizio
Copy link

@martinpovolny Minor detail in pie popup, not sure why it shows 2 values with : separator. Maybe legend has the value in the text, then it is adding the actual value again after the text in the popup.
piepopup

@martinpovolny martinpovolny force-pushed the report_charts3 branch 2 times, most recently from 509fa7c to 07ee471 Compare August 27, 2015 13:13
@martinpovolny
Copy link
Author

@dclarizio : thanks for detailed testing!

Now I:

  1. fixed the field labels in editor
  2. unified the formating of counts and value based 2dim charts

@dclarizio
Copy link

@martinpovolny looks like a relevant spec test failure on vmdb.

@dclarizio
Copy link

@martinpovolny Reran my saved chart report (with 2 series and non-stacked chart selected) with the new code, got this error again when chart is rendered for display (same as above with productization):

  • Notes: this also occurs with stacked charts and no error when set to Count
    chartcols
[----] I, [2015-09-03T15:03:15.888138 #5574:ad9990]  INFO -- : Completed 200 OK in 500ms (Views: 0.3ms | ActiveRecord: 16.4ms)
[----] I, [2015-09-03T15:03:16.048822 #5574:ad9990]  INFO -- : Started GET "/report/render_chart?height=250&rand=558489395&width=350" for 127.0.0.1 at 2015-09-03 15:03:16 -0700
[----] I, [2015-09-03T15:03:16.109741 #5574:ad9990]  INFO -- : Processing by 
ReportController#render_chart as JSON
[----] I, [2015-09-03T15:03:16.109938 #5574:ad9990]  INFO -- :   Parameters: {"height"=>"250", "rand"=>"558489395", "width"=>"350"}
[----] F, [2015-09-03T15:03:16.274265 #5574:ad9990] FATAL -- : Error caught: [ArgumentError] comparison of String with nil failed
/home/dclarizio/dev/manageiq/lib/report_formatter/chart_common.rb:448:in `sort'
/home/dclarizio/dev/manageiq/lib/report_formatter/chart_common.rb:448:in `build_numeric_chart_grouped_2dim'
/home/dclarizio/dev/manageiq/lib/report_formatter/jqplot.rb:127:in `build_numeric_chart_grouped_2dim'
/home/dclarizio/dev/manageiq/lib/report_formatter/chart_common.rb:560:in `build_reporting_chart_numeric'

@dclarizio
Copy link

@martinpovolny Easy fix, remove (2D) from chart type names since there are no 3D charts:
charttype

@martinpovolny
Copy link
Author

@dclarizio : on "Reran my saved chart report (with 2 series and non-stacked chart selected) with the new code, got this error again when chart is rendered for display (same as above with productization):"

Can you, please, either create the report again from scratch or send me also a screenshot of the "Summary page". I cannot reproduce the error.

Seems to me you must have only one sort criteria in the Summary (which the editor does not allow any more) -- so you have an invalid combination or I don't know. Just cannot create the situation on my box.

@dclarizio
Copy link

@martinpovolny Still seeing the exception when rendering the values chart, screenshots below. Also IRC'd you a link to my DB.
errsummary
errcharts

@martinpovolny
Copy link
Author

@dclarizio : please, retest with the last patch. I have also modified the spec to fail w/o the change.

@miq-bot
Copy link
Member

miq-bot commented Sep 4, 2015

Checked commits martinpovolny/manageiq@1900db9~...97ceb99 with ruby 1.9.3, rubocop 0.33.0, and haml-lint 0.13.0
14 files checked, 86 offenses detected

app/controllers/report_controller/reports/editor.rb

app/helpers/report_helper.rb

  • 🔹 - Line 29, Col 3 - Metrics/AbcSize - Assignment Branch Condition size for chart_fields_options is too high. [30.33/15]

app/models/miq_report/generator/aggregation.rb

app/views/report/_form_chart.html.haml

  • 🔴 Warn - Line 23, Col - - Style/ExtraSpacing: Unnecessary spacing detected.
  • 🔴 Warn - Line 23, Col - - Style/ExtraSpacing: Unnecessary spacing detected.
  • 🔴 Warn - Line 23, Col - - Style/ExtraSpacing: Unnecessary spacing detected.
  • 🔴 Warn - Line 23, Col - - Style/ExtraSpacing: Unnecessary spacing detected.
  • 🔴 Warn - Line 38, Col - - Style/ExtraSpacing: Unnecessary spacing detected.
  • 🔴 Warn - Line 38, Col - - Style/ExtraSpacing: Unnecessary spacing detected.
  • 🔴 Warn - Line 38, Col - - Style/ExtraSpacing: Unnecessary spacing detected.
  • 🔴 Warn - Line 38, Col - - Style/ExtraSpacing: Unnecessary spacing detected.

lib/charting/jqplot_charting.rb

lib/report_formatter/chart_common.rb

lib/report_formatter/jqplot.rb

spec/helpers/report_helper_spec.rb

spec/lib/report_formater/jqplot_formater_spec.rb

@dclarizio
Copy link

@martinpovolny Exception is gone upstream. When productized, I get the following when rendering the chart with values (counts renders fine). Should be able to reproduce this with the DB I sent you.

[----] I, [2015-09-04T13:21:45.238407 #7786:64f988]  INFO -- : Started GET "/report/render_chart?height=250&rand=144678747&width=350" for 127.0.0.1 at 2015-09-04 13:21:45 -0700
[----] I, [2015-09-04T13:21:45.294838 #7786:64f988]  INFO -- : Processing by ReportController#render_chart as HTML
[----] I, [2015-09-04T13:21:45.295038 #7786:64f988]  INFO -- :   Parameters: {"height"=>"250", "rand"=>"144678747", "width"=>"350"}
[----] F, [2015-09-04T13:21:45.453925 #7786:64f988] FATAL -- : Error caught: [NoMethodError] undefined method `match' for nil:NilClass
/home/dclarizio/dev/manageiq/lib/report_formatter/chart_common.rb:437:in `build_numeric_chart_grouped_2dim'
/home/dclarizio/dev/manageiq/lib/report_formatter/chart_common.rb:560:in `build_reporting_chart_numeric'
/home/dclarizio/dev/manageiq/lib/report_formatter/chart_common.rb:62:in `call'
/home/dclarizio/dev/manageiq/lib/report_formatter/chart_common.rb:62:in `build_document_body'

@martinpovolny
Copy link
Author

@dclarizio : the above error seems as if you where loading a broken report from DB. That's a failure in parsing the saved chart column from the report definition.

Also I was not able to reproduce this even when I tried your database, opened "Dan's Chart Tests" and then tried to edit your report (changing Value based to Counts based and more).

Tried switching to product charts (should have no effect as the stacktrace leads to common code) and no change.

Clicked on all reports that have "Dan" in the name too...

@dclarizio
Copy link

@martinpovolny OK, so I created a chart report from scratch when productized and it worked just fine. I also copied the suspect chart and when I went to the summary screen, non of the aggregations were defined. Defined those and the charts worked there as well. Merging this now.

dclarizio pushed a commit that referenced this pull request Sep 8, 2015
Initial implementation of numeric report charts.
@dclarizio dclarizio merged commit bb89929 into ManageIQ:master Sep 8, 2015
@dclarizio dclarizio added this to the Sprint 29 Ending Sept 14, 2015 milestone Sep 8, 2015
@@ -68,6 +71,27 @@ function jqplot_redraw_charts() {
}
}

function jqplot_pie_highligh_values(str, seriesIndex, pointIndex, plot) {
Copy link
Member

Choose a reason for hiding this comment

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

Should highligh be spelled highlight?

@martinpovolny martinpovolny deleted the report_charts3 branch November 28, 2017 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants