nnajm / orb

Pivot table javascript library
https://nnajm.github.io/orb/
MIT License
556 stars 173 forks source link

Add a UI to select the aggregation function of a field #15

Closed ValentinH closed 6 years ago

ValentinH commented 9 years ago

As discussed in #10.

The list of selectable functions is set using the aggregates option of the config.

The default value is:

[
      {name: 'count', caption: 'Count', aggregateFunc: Aggregations.count},
      {name: 'sum', caption: 'Sum', aggregateFunc: Aggregations.sum},
      {name: 'avg', caption: 'Average', aggregateFunc: Aggregations.avg},
      {name: 'min', caption: 'Minimum', aggregateFunc: Aggregations.min},
      {name: 'max', caption: 'Maximum', aggregateFunc: Aggregations.max},
      {name: 'prod', caption: 'Product', aggregateFunc: Aggregations.prod},
      {name: 'stdev', caption: 'Standard Deviation', aggregateFunc: Aggregations.stdev},
      {name: 'stdevp', caption: 'Standard Deviation P.', aggregateFunc: Aggregations.stdevp},
      {name: 'var', caption: 'Variance', aggregateFunc: Aggregations.var},
      {name: 'varp', caption: 'Variance P.', aggregateFunc: Aggregations.varp}
]
nnajm commented 9 years ago

Hi Valentin,

Really good start. But, imo, it's not complete. My observations:

Thanks,

nnajm.

ValentinH commented 9 years ago
  • the code for this popup and the filter popup can be combined (using mixins)

I think we should directly merge filters and aggregates in a common settings popup (like you mention in #10)

  • config aggregates should extend default ones, not replace them.

I am not sure to understand what you mean. I added a default array in the aggregate module to add caption field for the aggregates (for the select widget).

  • no need to rebuild the entire pivot grid, just recompute that field values and refresh the data area.

About the rebuilding part, I was not sure how to handle it. I simply copied the way it was done in the applyFilter functions... Any advice would be welcomed ;)

  • aggregate name should be highlighted when hovered

It will be handle in the settings popup.

  • popup is not aligned with anything and its style is different from the filter popup (all popups should have the same style)

idem.

katherdx commented 8 years ago

@ValentinH Can you share aggregateFunc code that is Change the aggregateFunc of a data from the UI ?

ValentinH commented 8 years ago

The code is the one in this pull request