Skip to content

Utilization Donut Chart Component #570

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

Merged
merged 1 commit into from
Aug 29, 2017

Conversation

cdcabrera
Copy link
Member

@cdcabrera cdcabrera commented Aug 12, 2017

Description

Implementation for utilization donut chart component.

Create a CPU Utilization Component, which is not embedded in a Card:

  • color changes based on thresholds
  • optional details are shown
  • optional details can be stacked horizontally, after the chart
  • optional details can be stacked vertically

In Progress Checklist

  • Unit tests
  • CSS styling for labels
  • Clean up and line endings
  • Evaluate focusing on use of a C3 chart config instead of individual attributes, similar to existing chart components
  • Evaluate transcluded label instead of "parameterizing" and "concatenating" them

PR Checklist

  • Unit tests are included
  • Screenshots are attached (if there are visual changes in the UI)
  • A Designer is assigned as a reviewer (if there are visual changes in the UI)
  • A CSS rep is assigned as a reviewer (if there are visual changes in the UI)
  • Amend commit for continuous integration

Updated

screen shot 2017-08-14 at 4 13 55 pm

Previous

screen shot 2017-08-12 at 1 26 38 am

@dtaylor113
Copy link
Member

Hi David, how is this component different from the current donut chart? It seems very similar, just wondering why we could enhance the already existing component?
Thanks,
Dave

@cdcabrera
Copy link
Member Author

cdcabrera commented Aug 14, 2017

@dtaylor113 that's correct most of this component is a pass through directly for the existing donut charts.

Funny enough have an initial version that just adds a couple of additional attributes on top of the pct donut but the sizing was awkward.

Overall the differences are around label placement, minor sizing, and center label customizing... all things that a user can potentially do with the config, but with short-cuts/settings/properties instead.

Sizing and placement were/are the more bothersome properties to deal with and one of the reasons for separating it out. Now that understand how sizing functions I can look at what converting this version would take, since it sounds like we're good with the add on approach. This works as part of the conversion from attributes back to the config as part of the checklist above

@cdcabrera cdcabrera changed the title [WIP][NO-REVIEW] Utilization Donut Chart Component [WIP] Utilization Donut Chart Component Aug 14, 2017
@cdcabrera
Copy link
Member Author

@dtaylor113 have part of your input, @jeff-phillips-18 do you have input on...

  • Adding to the existing pct-donunt chart component?

And both...

  • The idea that a large percentage of this component, as is, is just structuring the "config" in a customized way, and that perhaps just placing an updated demo might be enough?
    Here's a quick snapshot of the intention behind it...
    cpuutilization-horizontallystacked

@serenamarie125
Copy link
Member

@cdcabrera agree with the approach of updating the existing donut chart rather than create a new component

@cdcabrera
Copy link
Member Author

good good @serenamarie125 , @beanh66 @cshinn

  • aspects of the initial design layout can start to be viewed, used flex to layout the columns. There's an initial screen shot, which when compared to the request is missing some bold and sized text

@beanh66 @cshinn your input on

  • adding to the existing component vs writing a new one, that's really really close to the old one.

@dtaylor113
Copy link
Member

@cdcabrera, you are right that we already have an attribute called 'center-label' which can have values 'used', 'available', 'percent', and 'none', so it sounds like setting it to 'percent' will correctly set the center label. The issue is how can we bundle the 'side labels' so that it's easy for app. dev to customize/specify.
I would suggest adding a config option, something like 'side-label': {
position: 'left' / 'right',
title: 'Storage',
type: percent, used, available (?),
format: full ('of m GB used'), idk, just spitballing here :-)
}

@jeff-phillips-18
Copy link
Member

@cdcabrera I agree with enhancing the existing component.

@cdcabrera
Copy link
Member Author

@amarie401 for reference

@jeff-phillips-18
Copy link
Member

Is this still WIP or ready for final reviews?

@cdcabrera
Copy link
Member Author

@jeff-phillips-18 et all, it's close to final can remove the WIP just...

  • need some for/against input on how the additional config option is structured on top of the existing donut
  • any minor design concerns

Then i'll rebase and amend the commit message

@cdcabrera cdcabrera changed the title [WIP] Utilization Donut Chart Component Utilization Donut Chart Component Aug 15, 2017
@cdcabrera cdcabrera force-pushed the feature-utilization branch from 7d25833 to ed38af3 Compare August 16, 2017 18:35
Copy link
Member

@jeff-phillips-18 jeff-phillips-18 left a comment

Choose a reason for hiding this comment

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

I'm OK with the additional config option.

flex-direction: row-reverse;
}
}

Copy link
Member

Choose a reason for hiding this comment

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

Should this really be put into Patternfly? Is this a Patternfly pattern?

Copy link
Member Author

Choose a reason for hiding this comment

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

@jeff-phillips-18 can move it over to core for sure np. There are aspects of charts both within this repository's less and core, just need a direction we want to head?

Copy link
Member Author

@cdcabrera cdcabrera Aug 22, 2017

Choose a reason for hiding this comment

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

After looking a little bit more on this, looks like we have a choice, move now, or move later as a whole. The appearance is, it looks like we attempted to start a PF core aspect to the charts, here:

With a distinction about only how we modify SVG aspects of the Charts within AngularPF. However it looks like we slightly diverged a little and started placing a few more bits inside AngularPF instead of core.

I can go back and move this newer piece over to core now, or hold off based on what's already in AngularPf? But in addition, outside of this PR, we probably need to go through the rest of charts.less and separate them out a bit more.

Copy link
Member Author

@cdcabrera cdcabrera Aug 23, 2017

Choose a reason for hiding this comment

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

@jeff-phillips-18 @dtaylor113 the less has been moved over to core Patternfly PR 720

@@ -26,6 +26,15 @@
* <li>.tooltipFn(d) - user defined function to customize the tool tip (optional)
* <li>.centerLabelFn - user defined function to customize the text of the center label (optional)
* <li>.onClickFn(d,i) - user defined function to handle when donut arc is clicked upon.
* <li>.label - object containing properties for external label (optional)
* <ul>
* <li>.orientation - string with possible values: 'left', 'right' (optional)
Copy link
Member

Choose a reason for hiding this comment

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

This is optional, what is the default?

Copy link
Member Author

@cdcabrera cdcabrera Aug 18, 2017

Choose a reason for hiding this comment

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

Good catch can update the comments/annotation. For our purposes the optional default is it simply doesn't exist, don't have to use it

* <ul>
* <li>.orientation - string with possible values: 'left', 'right' (optional)
* <li>.title - string representing a prefix or title (optional)
* <li>.label - similar in to the center-label parameter, which specifies the contents of the donut's external label, values: 'used', 'available', 'percent', 'none' (optional)
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand the description 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.

Yeah the wording is a little funky reading back on it, can correct it...

<pf-donut-pct-chart config="configDynamic" data="dataDynamic" center-label="labelDynamic"
on-threshold-change="thresholdChanged(threshold)">
</pf-donut-pct-chart>
</p>
</div>
<div class="col-md-3 text-center"">
Copy link
Member

Choose a reason for hiding this comment

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

Not this PR but coul you remove the extra " character.

@@ -26,6 +26,15 @@
* <li>.tooltipFn(d) - user defined function to customize the tool tip (optional)
* <li>.centerLabelFn - user defined function to customize the text of the center label (optional)
* <li>.onClickFn(d,i) - user defined function to handle when donut arc is clicked upon.
* <li>.label - object containing properties for external label (optional)
Copy link
Member

Choose a reason for hiding this comment

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

Maybe this should be labelConfig or something more descriptive so that it is understood that this is not just a simple label.

Copy link
Member

@dtaylor113 dtaylor113 Aug 18, 2017

Choose a reason for hiding this comment

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

I had suggested sideLabel

Copy link
Member

@dtaylor113 dtaylor113 Aug 18, 2017

Choose a reason for hiding this comment

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

Hi, I don't think .label should be under config, rather it should be a separate param like center-label is, and called side-label with properties orientation, title, and perhaps something like 'amount-type' for available, percent, used.

Copy link
Member Author

@cdcabrera cdcabrera Aug 18, 2017

Choose a reason for hiding this comment

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

Took using side-label into consideration, but when the label can be used on the right, left, and bottom it becomes a slight misnomer, so changed it to label.

Was also going to create it as a separate attribute similar to center-label, but then we blend the use of how center-label functions. We have both a configuration aspect, which takes a function, and the attribute, which takes a string. Based on that took the configuration route all in one, instead of a blended approach, which for myself felt less confusing.

I do agree the label label should probably be changed to something else, I like labelConfig, had also thought maybe outsideLabel, but the Config suffix seems more appropriate.

As a quick fix, I can go ahead and change the label to labelConfig while we continue to discuss.

</span>
<span ng-if="$ctrl.data.dataAvailable !== false && $ctrl.config.label && !$ctrl.config.label.labelFn()" class="pct-donut-chart-pf-label">
{{$ctrl.config.label.title}}
<span ng-if="$ctrl.data" ng-switch="$ctrl.config.label.label">
Copy link
Member

Choose a reason for hiding this comment

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

$ctrl.config.label.label I think we do need 'labelConfig' or something clearer. Currently, 'label.label' is tough to read.

@cdcabrera cdcabrera force-pushed the feature-utilization branch from ed38af3 to 02f0e4e Compare August 22, 2017 14:04
dtaylor113
dtaylor113 previously approved these changes Aug 22, 2017
Copy link
Member

@dtaylor113 dtaylor113 left a comment

Choose a reason for hiding this comment

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

LGTM, aside from where the css/less goes

@cdcabrera
Copy link
Member Author

cdcabrera commented Aug 22, 2017

@dtaylor113 @jeff-phillips-18 since both commented on the Less, I'll go ahead and look at moving move it over to PF core for this update. If there are any additional PCT Donut styles that don't fall into the SVG/C3 manipulate I can try to move those as well.

EDIT: I don't necessarily agree with moving this to core by itself, unless we move the entirety of the charts.less

@cdcabrera
Copy link
Member Author

@@ -11,6 +11,7 @@ pf-c3-chart {
width: 100%;
}
}

Copy link
Member

Choose a reason for hiding this comment

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

Looks like this file's changes could be discarded. No point updating to include an empty line 😉

* <li>.title - string representing a prefix or title (optional) - default: empty string
* <li>.label - the wording format to display, possible values: 'used', 'available', 'percent', 'none' (optional) - default: 'used'
* <li>.units - unit label for values, ex: 'MHz','GB', etc.. (optional) - default: empty string
* <li>.labelFn - function to customize the text of the external label (optional) - default: undefined
Copy link
Member

Choose a reason for hiding this comment

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

Should this function take some parameters? How is the function to know what the label ought to be?

Copy link
Member Author

Choose a reason for hiding this comment

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

Can add a note/annotation on there.

The behavior is similar to the existing centerLabelFn callback. That one also seems to be lacking in the documentation/annotation department

@dtaylor113
Copy link
Member

Hi @cdcabrera, I feel like the ngDoc has somewhat gotten somewhat munged (if that is a word :-). Previously, the top row was showing the different Thresholds, the middle row was the different center-labels, the last row was some custom stuff:
image

With your current changes, the first row is now showing Thresholds and some custom label placements, and I think different donut sizes(?). However, there is no ngDoc help text or labels to denote what is being displayed in the first row:

image

I would suggest leaving the first row to denote the different Thresholds and add a new row which clearly describes the different/new label customizations and placements you are introducing.
Thanks,
Dave

@dtaylor113 dtaylor113 dismissed their stale review August 28, 2017 14:57

Wont change to 'Changes requested'

Copy link
Member

@dtaylor113 dtaylor113 left a comment

Choose a reason for hiding this comment

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

Please update ngDoc examples

@cdcabrera
Copy link
Member Author

@dtaylor113 can add a dedicated row for sure

@cdcabrera
Copy link
Member Author

cdcabrera commented Aug 28, 2017

This PR is dependent on core Patternfly PR 720 for CSS

@cdcabrera cdcabrera force-pushed the feature-utilization branch from b92fe01 to 567bbe7 Compare August 28, 2017 21:05
@cdcabrera
Copy link
Member Author

cdcabrera commented Aug 28, 2017

@dtaylor113 the revised layout linked to Patternfly core PR 720

Edit: included the wrong image... corrected below...

screen shot 2017-08-28 at 5 23 25 pm

@cdcabrera cdcabrera force-pushed the feature-utilization branch from 567bbe7 to c514361 Compare August 28, 2017 21:16
Enhancement for utilization donut chart component
@cdcabrera cdcabrera force-pushed the feature-utilization branch from c514361 to cf4c16c Compare August 28, 2017 21:21
@cdcabrera
Copy link
Member Author

The associated core PatternFly PR 720 has been merged, you'll need to update your packages to see the CSS update

@dtaylor113
Copy link
Member

@cdcabrera Perfect! Exactly what I was envisioning.

@dtaylor113 dtaylor113 merged commit 469fe4d into patternfly:master Aug 29, 2017
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.

4 participants