This is a migrated thread and some comments may be shown as answers.

Distinguish aggregated values.

3 Answers 53 Views
Charts
This is a migrated thread and some comments may be shown as answers.
Jose Mejia
Top achievements
Rank 1
Jose Mejia asked on 19 Jun 2015, 07:37 PM

Hi.

Suppose I'm using some aggregation function which gives me several values instead of one. I have seriesClick event handler

with something like following:

var dsObject = e.sender.dataSource.get(e.dataItem.markerId);

And when I click on aggregated value it returns some value from datasource and I don't know why it returns this value. 

Is there any way to distinguish aggregated values from usual (from datasoure) values? Or is there any way to specify returned value in case of my aggregation function?

Thanks in advance. 

 

 

3 Answers, 1 is accepted

Sort by
0
T. Tsonev
Telerik team
answered on 23 Jun 2015, 05:49 PM
Hello,

By default the aggregate result will link back to the first data item that was aggregated. That is, if you have data items such as:
{ value: 1, markerId: 1 }, { value: 2, markerId: 2 }

The "max" aggregate will produce an object that looks like
{ value: 2, markerId: 1 }

If you need to do something special with these fields then you should configure a custom aggregate:
series: [{
  aggregate: function(values, series, dataItems) {
    return {
      value: <max value>,
      markers: dataItems.map(function(ddata) { return data.markerId })
    };
  }


Which should produce something like:
{ value: 2, markers: [1, 2] }

I hope this helps.

Regards,
T. Tsonev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Jose Mejia
Top achievements
Rank 1
answered on 24 Jun 2015, 09:26 PM

Hi.

Sorry, but your answer is not clear to me. Suppose that I have stock chart bounded to some datasource. What I need is some how distinguish  simple values from aggregated one. Maybe via some custom field. In a sample above there may be check that selected value (on seriesclick event) is aggregated and display information about it's  component values.

Also, what is exact format of object I should return from aggregate function?

Thanks in advacnce. 

 

0
Accepted
T. Tsonev
Telerik team
answered on 26 Jun 2015, 02:56 PM
Hello,

The Chart will call the aggregate function for each category. What you return from it will be the data item you see in the series.

In order to distinguish from aggregated values you can do something like:
  aggregate: function(values, series, dataItems) {
    return {
      srcDataitems: dataItems,
      ...
    };
  }


Then at any point you can check for dataItem.srcDataItems.length to tell if this is an aggregate or not.
I hope this sheds some light on the custom aggregate functionality.

Regards,
T. Tsonev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Charts
Asked by
Jose Mejia
Top achievements
Rank 1
Answers by
T. Tsonev
Telerik team
Jose Mejia
Top achievements
Rank 1
Share this question
or