any

gets a random property value from a group

any any(string property,object data);
property
stringa data property data
objecta dataset with items of a group
anyproperty value

Example

$$("mychart").group({
    by:"year",
    map:{
        sales:["sales","any"]
    }
});
 
//or with the same result
$$("mychart").group({
    by:"year",
    map:{
        sales:["sales"]
    }
});

Related samples

Details

Generally, the functor gets the value of the first item but it's not mandatory.

Note that the same effect of grouping will be achieved if you omit the functor at all.


Let's assume that you have the following data set initially:

initial_data = [
    {id:1, sales:262, year:2003, company:"Company 3"},
    {id:2, sales:527, year:1998, company:"Company 1"},
    {id:3, sales:629, year:2006, company:"Company 3"},
    {id:4, sales:403, year:2008, company:"Company 2"},
    {id:5, sales:377, year:2006, company:"Company 2"}
];

You group the data like this:

$$("mychart").group({
    by:"company",
    map:{
        sales:["sales", "sum"],
        year:["year", "any"]
    }
});

And get a new data set:

new_data = [
    {id: "Company 1", sales: 527,  year: 1998}
    {id: "Company 2", sales: 780,  year: 2008}
    {id: "Company 3", sales: 891,  year: 2003}
];
See also
  • Articles
  • Back to top
    Join Our Forum
    We've retired comments here. Visit our forum for faster technical support, connect with other developers, and share your feedback there.