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

Fixes #23598 - move report metrics chart to c3 #5563

Merged
merged 1 commit into from
Jun 10, 2018

Conversation

lizagilman
Copy link
Member

Using pf-react donut chart instead of flot

image

@theforeman-bot
Copy link
Member

Issues: #23598

Copy link
Member

@amirfefer amirfefer left a comment

Choose a reason for hiding this comment

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

Thanks @lizagilman
I left some inline comments.

We have a component for a chart box with this design:
chart-box
although I know that this page uses chart bar which still using flot.

<div style="margin-top:50px;padding-bottom: 40px;">
<%= flot_pie_chart("metrics" ,_("Report Metrics"), metrics, :class => "statistics-pie small")%>
</div>
<div id="metrics_chart" class='metrics-chart' style="margin-top:50px;padding-bottom: 40px;"></div>
Copy link
Member

Choose a reason for hiding this comment

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

why not add the inline style to the metrics-chart class?

@@ -18,7 +17,7 @@
<div class="col-md-4">
<table class="<%= table_css_classes %>" style="height: 398px;">
<tbody>
<% metrics.sort.each do |title, value|%>
<% metrics.sort.each do |title, value|%>
Copy link
Member

Choose a reason for hiding this comment

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

indentation should be 2 space

<tr>
<th><%= _("Total") %></th><th><%= metric (@totaltime || @config_report.runtime) %></th>
</tr>
<tr>
Copy link
Member

Choose a reason for hiding this comment

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

ditto

<%= flot_pie_chart("metrics" ,_("Report Metrics"), metrics, :class => "statistics-pie small")%>
</div>
<div id="metrics_chart" class='metrics-chart' style="margin-top:50px;padding-bottom: 40px;"></div>
<%= mount_react_component('DonutChart', '#metrics_chart', metrics.to_a) %>
Copy link
Member

Choose a reason for hiding this comment

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

data should be in json format (to_json)

@lizagilman
Copy link
Member Author

lizagilman commented May 15, 2018

@amirfefer thanks for the quick review, updated.
should we move only one chart to a box? once @ripcurld is finished with the bar chart we can move both to chartbox

Copy link
Member

@amirfefer amirfefer left a comment

Choose a reason for hiding this comment

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

Thanks @lizagilman , just one minor issue with the css.

Generally speaking, We do test the component behavior,
but we don't test if a component actually is rendered in a page (end to end test).
do we want this kind of test?

.metrics-chart {
width: 240px;
margin: 12px auto;
margin-top: 50px;
Copy link
Member

Choose a reason for hiding this comment

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

duplicate margin-top with 12px and 50px values.
maybe use margin with 4 values?

@lizagilman
Copy link
Member Author

@amirfefer thanks, css updated
I tried to test for the chart rendering both on integration test and controller test but it seems the container div is empty (the component is not mounted to #metrics_chart). Is this a normal behavior?

@amirfefer
Copy link
Member

@lizagilman, in order to run js in integration test you should use js driver, tests with js end with _js_test, and inherit IntegrationTestWithJavascript.

@lizagilman
Copy link
Member Author

@amirfefer ok, I added a test
Is this what you had in mind?

@ohadlevy
Copy link
Member

@lizagilman mind adding an updated screenshot? thanks.


class ConfigReportJSTest < IntegrationTestWithJavascript
test "should display report metrics chart" do
@report = ConfigReport.import(read_json_fixture('reports/applied.json'))
Copy link
Member

Choose a reason for hiding this comment

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

I think @ is redundant here

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

@lizagilman
Copy link
Member Author

lizagilman commented May 21, 2018

updated -

image

amirfefer
amirfefer previously approved these changes May 22, 2018
Copy link
Member

@amirfefer amirfefer left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@ohadlevy
Copy link
Member

this looks like a solid change, the only thing I'm a bit uncomfortable with is the red (and to some degree green) color inside the chart, in your screenshots it looks like something requires attention, when i looked at it on some other sample data it didnt look as bad, but it still feels wrong to me, @Rohoover any thoughts?
image
image
image

@amirfefer
Copy link
Member

amirfefer commented May 22, 2018

@ohadlevy: these colors are suggested by pf color-palette and mentioned here
But I tend to agree when it's about two distinct colors, the red color has some negative impact.
We can change the color pattern order, and move the red color from the second place.

@Rohoover
Copy link

@amirfefer Is correct. There is some flexibility as the donut doesn't specify which colors and only gives guidance to use the recommended PF Color palette. We can technically choose from any of those colors.

@ohadlevy
Copy link
Member

ohadlevy commented May 22, 2018 via email

@Rohoover
Copy link

@ohadlevy

It's you. ;)

In all seriousness, I am not married to any particular color choice at this point. I think PF does use the red, orange, green colors as both color and status in the donuts, which can be a bit confusing.

@ares
Copy link
Member

ares commented May 23, 2018

I'd also prefer to avoid red if that's easy to do. But I can live with it :-)

@lizagilman
Copy link
Member Author

lizagilman commented May 23, 2018

How about now?

  1. red is last

image

image

  1. or we can replace it with a different color -

image

for now, pr updated with option 1 (red at last place)

@ohadlevy @ares do you prefer to avoid red completely?

@ares
Copy link
Member

ares commented May 23, 2018

I prefer option 2, but not strong opinion. If red helps color-blind people, I'm fine with keeping it.

@lizagilman
Copy link
Member Author

@tstrachota any preferences? or can we merge?

Copy link
Member

@amirfefer amirfefer left a comment

Choose a reason for hiding this comment

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

I prefer option 2 as well,
Please pick another color from this list.

@lizagilman
Copy link
Member Author

ok, changed -

image

@boaz0
Copy link
Member

boaz0 commented Jun 5, 2018

LGTM 👍

test failures not related.
[test foreman]
[test katello]

@lizagilman
Copy link
Member Author

[test foreman]

Copy link
Member

@tbrisker tbrisker left a comment

Choose a reason for hiding this comment

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

Tested, works well. Thanks @lizagilman !

@tbrisker tbrisker merged commit be6d3ed into theforeman:develop Jun 10, 2018
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.

8 participants