Distinguish aggregated values.

4 posts, 1 answers
  1. Jose Mejia
    Jose  Mejia avatar
    107 posts
    Member since:
    May 2009

    Posted 19 Jun 2015 Link to this post

    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. 

     

     

  2. T. Tsonev
    Admin
    T. Tsonev avatar
    2817 posts

    Posted 23 Jun 2015 Link to this post

    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!
     
  3. Jose Mejia
    Jose  Mejia avatar
    107 posts
    Member since:
    May 2009

    Posted 24 Jun 2015 in reply to T. Tsonev Link to this post

    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. 

     

  4. Answer
    T. Tsonev
    Admin
    T. Tsonev avatar
    2817 posts

    Posted 26 Jun 2015 Link to this post

    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!
     
Back to Top