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

Vislib: Percentage Bar Charts and Grouped Bar Charts #1659

Merged
merged 11 commits into from
Oct 24, 2014

Conversation

stormpython
Copy link
Contributor

Adds the ability to create percentage bar charts and grouped bar charts. These changes work for both time series and nominal (d3 ordinal) scales. See photos below.

screen shot 2014-10-14 at 1 29 20 am
screen shot 2014-10-13 at 9 45 52 pm

To use them, you'll need to specify an offset string in the parameters passed into the Vis constructor.
There are 3 options available:

  1. zero (default) - stacked bars
  2. expand - percentage bars
  3. group - grouped bars

For example:

var params = {

  type: 'vertical-bar',
  offset: 'expand'
};

var myVis = new Vis($el, params);

NOTE: There are still issues that need discussing before the pull request can be merged.

The first is regarding event data returned on by an event listener. Currently, it passes back the percentage value with the percentage bar charts, but in many cases, we will need both the percentage values and the original doc count, avg, min, max, etc.

The second issue is regarding buckets being cutoff on the left and right side of the charts, particularly on grouped bar charts. Some values in the group will appear while others will not.

Finally, there is the need for error handling with grouped bar charts on a time scale. Bars may become too thin to interact with.

@w33ble w33ble added the discuss label Oct 13, 2014
@w33ble
Copy link
Contributor

w33ble commented Oct 13, 2014

Should provide the vislib side of #1618

@w33ble w33ble mentioned this pull request Oct 13, 2014
@rashidkpc
Copy link
Contributor

  1. zero (default) - stacked bars
  2. expand - percentage bars
  3. group - grouped bars

Why not call these what they are?

  1. stacked (default)
  2. percentage
  3. grouped

Also, the "offset" parameter seems weird to me, is there a better name for that? View? Mode? Something better than either of those?

@stormpython
Copy link
Contributor Author

@rashidkpc, there are several reasons.

  1. Both zero (default, referring to zero-filled) and percentage are stacked.
  2. These are the same terms which the d3 API uses to alias the functions - so, less work having to think about what stacked is an alias for. However, it does assume that someone has that particular d3 knowledge.

I am fine with changing offset to something else. Disregard the above comments, we can easily change the options to the 3 you listed.

@stormpython
Copy link
Contributor Author

Ok, so, now the options are:

  1. stacked (default) - stacked bars
  2. percentage - percentage bars
  3. grouped - grouped bars

For example:

var params = {

  type: 'vertical-bar',
  mode: 'percentage'
};

var myVis = new Vis($el, params);

@stormpython
Copy link
Contributor Author

stormpython@fee0c73 adds formatted percentage values to tooltips, as well as displays the actual value. See picture below.
screen shot 2014-10-17 at 7 06 33 pm

NOTE: This change should also work for area charts, pull request #1674.

@stormpython
Copy link
Contributor Author

I am removing the discuss tag, since I've taken care of 2 of the major issues on my previous list in the initial pull request comment. I think this is ready for review.

@simianhacker
Copy link
Member

This seems ready to go... just need to rebase against master so we can cleanly merge it.

var yScale = this.getYScale(height);
var tickFormat = (self._attr.mode === 'percentage') ?
d3.format('%') : d3.format('n');
Copy link
Contributor

Choose a reason for hiding this comment

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

Single line here is fine

Conflicts:
	src/kibana/components/vislib/lib/data.js
	src/kibana/components/vislib/lib/y_axis.js
	src/kibana/components/vislib/visualizations/column_chart.js
@stormpython
Copy link
Contributor Author

Merged with master and made a correction in the y_axis.js file that @w33ble commented on.

Conflicts:
	src/kibana/components/vislib/lib/data.js
	src/kibana/components/vislib/lib/y_axis.js
stormpython added a commit that referenced this pull request Oct 24, 2014
Vislib: Percentage Bar Charts and Grouped Bar Charts
@stormpython stormpython merged commit 62b20e4 into elastic:master Oct 24, 2014
@stormpython stormpython deleted the feature/add_bar_chart_options branch October 24, 2014 18:43
@martinhynar
Copy link

Hi, in which version will this feature be present? I have CPU data from collectd that needs to be displayed as percentage and having the percentage being displayed when hovering over part of the bar would be great. I am running now Kibana4beta3 and when displaying max values, the percentage is not in the tooltip.

@simianhacker
Copy link
Member

@martinhynar It's coming in the next release which will be a release candidate.

@martinhynar
Copy link

I just tried Kibana 4 RC1 and it seems that percentage values are not displayed in the tooltip.

kibana-percentage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants