Zoom in/out kendo stock chart

2 posts, 1 answers
  1. Challa
    Challa avatar
    3 posts
    Member since:
    Jul 2018

    Posted 26 Jul 2018 Link to this post


    The current implementation of kendo stock chart samples all the data points. In my case, when I drag right on the stock chart, fetches remote data and bind it to a local DataSource using add(). Let's say If I get 100 data points with values for each category nearer, chart renders only a few data points.

    eg. This is the data I get on drag


    eg: This is how I assign above json to respective category

    Lets say above data array is assigned to a variable called 'points'

    points.forEach(function (data) {
         var _payload = {};
        _payload[deviceId] = data.value; // deviceId can be different for another series data
        _payload.date = new Date(data.time);
        chart.data_source.add(_payload); // chart is kendo-stock-chart reference obj


    In the above example chart data_source holds whatever payload added. But I could see only few data points because of default sampling algorithm. I have implemented pan and zoom on kendo chart but, it only works with sampled data. 

    So, I want to have plus and minus icon on the chart as an overlay. When I click on plus icon chart should render hidden data points.

  2. Answer
    Tsvetina avatar
    2443 posts

    Posted 30 Jul 2018 Link to this post

    Hello Challa,

    I am not sure what you mean with that the pan and zoom in the StockChart only works with sampled data. When the default pan and zoom is used the Chart can be zoomed into the original data item values (even past them). This can be seen in the demos. When the Chart is zoomed out, there are less categories than values and the only correct way to display the Chart is to display one value per category. What the StockChart does is calculate an aggregate from all values belonging to the same category and draw one data point from this value.

    If you want to display your original values, you need to set the StockChart category axis baseUnit value to the unit that corresponds to the time difference between values in your data. From the sample data you provided, I see values are minutes apart, so if the base unit is set to "minutes", all values will be visible. It is important to also adjust the selected period in the Chart navigator to avoid drawing hundreds or thousands of labels. Here is an example showing my suggestion:

    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top