Kendo Charts Minimum value for a Max of ValueAxis

6 posts, 0 answers
  1. serkan
    serkan avatar
    3 posts
    Member since:
    Aug 2014

    Posted 07 Aug 2014 Link to this post

    Hello!

    I have this little problem, I have huge amounts (260k +) combined with very little amounts (0,0001) in one chart, and sometimes in the first screen I get only very little amounts. The problem is with these very low amounts, my value Axis max value is also very very small, I wish to have a min value for the "max" attribute of my value Axis.

    For example when I have lots of values that are 1 < x < 0, I want to see no bars on my chart, but with current options I see full bars, and value axis max value at 0,0002 something. Check the attached photos.

    I wish to start with a default max value, but when I get higher values, I wish it to be updated. I used the max attribute for the valueAxis, but with that I cannot get to see my very high value data. Please find a solution to this conundrum.

    Thanks and hope to hear back from you asap
  2. T. Tsonev
    Admin
    T. Tsonev avatar
    2772 posts

    Posted 11 Aug 2014 Link to this post

    Hi,

    We can set the valueAxis max value based on the actual series data. The dataBound event is most suitable for this task:
          dataBound: function(e) {
            var data = e.sender.dataSource.view();
            // ...

            e.sender.options.valueAxis.max = ...;
          }


    -- Live demo --

    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. Kendo UI is VS 2017 Ready
  4. serkan
    serkan avatar
    3 posts
    Member since:
    Aug 2014

    Posted 15 Aug 2014 in reply to T. Tsonev Link to this post

    Hello,

    Thanks for the answer, but this does not help me. Because of the fact that I am using a kendoStockChart thus have a dynamic valueAxis.
    I have a chart with bunch of 0.0001 values together with 250k values, and when I navigate to the region of only those low values, I get my valueAxis changed to all very low values, and have full bars on the chart, still cannot get a minimum of my maximum valueAxis value. 
  5. T. Tsonev
    Admin
    T. Tsonev avatar
    2772 posts

    Posted 18 Aug 2014 Link to this post

    Hi,

    I see what you mean. The axis maximum value gets sets and remains constant regardless of the date range.

    I can offer a workaround, but I'll have to extend a private method. This makes the solution potentially fragile and future versions can break it.
    That said, I'll try to keep the changes to a minimum to hopefully avoid that.

          var initDefaults = kendo.dataviz.NumericAxis.fn.initDefaults;
          kendo.dataviz.NumericAxis.fn.initDefaults = function() {
            var defaults = initDefaults.apply(this, arguments);
            
            defaults.max = Math.max(10, defaults.max);
            
            return defaults;
          };

    -- Live demo --

    Here defaults is the effective settings that the axis will use. Changes will not carry over after panning, for example.

    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!
     
  6. serkan
    serkan avatar
    3 posts
    Member since:
    Aug 2014

    Posted 21 Aug 2014 in reply to T. Tsonev Link to this post

    Thanks but it still is not a solution.

    When I apply the above solution, it does not do anything on initialization, but after navigation it creates a scary look (attached image)
    I hope there will be a certain solution, since this bug is extremely dangerous, and needs to go :)

    Thanks a lot, and anxiously waiting for a reply.
  7. T. Tsonev
    Admin
    T. Tsonev avatar
    2772 posts

    Posted 24 Aug 2014 Link to this post

    Hello,

    I've managed to reproduce the problem with my workaround applied. Turns out the axis majorUnit is now much smaller which cases the crazy number of labels.
    This can be corrected:
      var initDefaults = kendo.dataviz.NumericAxis.fn.initDefaults;
      kendo.dataviz.NumericAxis.fn.initDefaults = function() {
        var defaults = initDefaults.apply(this, arguments);
        
        defaults.max = Math.max(10, defaults.max);
        defaults.majorUnit = defaults.max / 10;
          
        return defaults;
      };


    -- Updated demo --

    Let me take a step back to your original question - "values that are 1 < x < 0, I want to see no bars on my chart".
    Do you think we can filter the small values at the data source level? Does this make sense?

    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
Kendo UI is VS 2017 Ready