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

Kendo Charts Minimum value for a Max of ValueAxis

5 Answers 666 Views
Charts
This is a migrated thread and some comments may be shown as answers.
serkan
Top achievements
Rank 1
serkan asked on 07 Aug 2014, 09:20 AM
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

5 Answers, 1 is accepted

Sort by
0
T. Tsonev
Telerik team
answered on 11 Aug 2014, 07:25 AM
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!
 
0
serkan
Top achievements
Rank 1
answered on 15 Aug 2014, 11:10 AM
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. 
0
T. Tsonev
Telerik team
answered on 18 Aug 2014, 03:16 PM
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!
 
0
serkan
Top achievements
Rank 1
answered on 21 Aug 2014, 09:02 AM
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.
0
T. Tsonev
Telerik team
answered on 25 Aug 2014, 04:41 AM
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!
 
Tags
Charts
Asked by
serkan
Top achievements
Rank 1
Answers by
T. Tsonev
Telerik team
serkan
Top achievements
Rank 1
Share this question
or