NumberBucket Process

This example shows the usage of NumberBucket process

namecharity
John $5
Marry $13
Peter $15
David $10
Jane $20
Donald $50
Them $60
Smith $10
Johny $17
Michael $90
Jolie $65
Bradpit $45
Eddie $35

->pipe(new NumberBucket(array(
    "charity"=>array(
        "step"=>20,
        "prefix"=>"$"
    )
)))
namecharity
John $0 - $20
Marry $0 - $20
Peter $0 - $20
David $0 - $20
Jane $20 - $40
Donald $40 - $60
Them $60 - $80
Smith $0 - $20
Johny $0 - $20
Michael $80 - $100
Jolie $60 - $80
Bradpit $40 - $60
Eddie $20 - $40

->pipe(new Group(array(
    "by"=>"charity",
    "count"=>"count"
)))
charitycount
$0 - $20 6
$20 - $40 2
$40 - $60 2
$60 - $80 2
$80 - $100 1
Description

The example demonstrates usage of NumberBucket process. The NumberBucket will create a number of buckets with same size to put number into. A bucket is defined as "{from} - {to}" format, for example: "0-20", "20-40".

The NumberBucket takes the "step" a must-have property. This is actually the size of a bucket. Beside the "step", there are several optional settings such as "prefix", "suffix", "thousandSeparator", "decimals" and "decimalPoint". Those are actually the settings to format number.