Varying time period based on data

2 posts, 0 answers
  1. Sam Cogan
    Sam Cogan avatar
    2 posts
    Member since:
    Feb 2010

    Posted 26 Mar 2013 Link to this post

    I have a line chart that displays some data, this data is collected on a daily basis, so currently I have a chart point for each day. That works fine, however as this data increases I will have some  data sets with many weeks or months worth of data, where as others will only have a few days worth.

    What I would like to do is have the chart deal with this dynamically, so if I have, say, over 4 weeks of data, then it should only plot a point for each week (and make this an average of the daily data for that week). If it is less than 4 weeks, plot a point for each day.

    Is there an easy way to do this with the charting component, rather than having to pre -process the data before it gets there?

    I am using the MVC wrapper.
  2. T. Tsonev
    T. Tsonev avatar
    2831 posts

    Posted 28 Mar 2013 Link to this post


    The date axis can be configured to behave in the manner you describe using the maxDateGroups option:
    categoryAxis: {
        type: "date",
        baseUnit: "fit",
        maxDateGroups: 100

    It will aggregate the data in such time intervals that the total number of points remains below [maxDateGroups]. The intervals it chooses from are defined in autoBaseUnitSteps.

    If you're dealing with a lot of data points (say 10 000) you should consider doing aggregates on the server. We do this in the stock chart virtualization demo.

    The server-side grouping code is located in the ASP.NET MVC package:

    In fact, the stock chart is an extension built on top of the regular chart widget. It does not limit you to financial series and will happily plot line charts as well. You can use it directly if you need interactive selection.

    Tsvetomir Tsonev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top