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

Fixed y-axis on zero value

7 Answers 1102 Views
Charts
This is a migrated thread and some comments may be shown as answers.
Ibrahim
Top achievements
Rank 1
Ibrahim asked on 30 Apr 2014, 01:58 PM
I have a graph in Kendo with positive values. The problem is that the Y-axes takes his range in function of the values.E.g. minimum value is 5000 -> the y-axis starts from 4500.Is there a way to get the y-axis fixed on 0? So it always starts from 0 instead of a narrower range. I found that you can put the min on 0 in ValuesAxis, but the problem here is that I can't get any negative values in this way.

My code:
$scope.line = {<br>        cache:false,<br>        legend: {<br>            visible: false<br>        },<br>        title: {<br>            text: "Last 10"<br>        },<br>        series: [{<br>            type: "line",<br>            style: "smooth",<br>            field: "OBAmount",<br>            categoryField: "date",<br>            color: '#0c50dd'<br>        }],<br>        valueAxis: {<br>            line: {<br>                visible: false<br>            }<br>        },<br>        tooltip: {<br>            visible: true,<br>            template: "#= kendo.format('{0:n2}', value) # "<br>        }<br>    }

7 Answers, 1 is accepted

Sort by
0
Iliana Dyankova
Telerik team
answered on 30 Apr 2014, 03:38 PM
Hello Ibrahim,

Basically in order to fix valueAxis range you should specify its min / max values. What I can suggest for this particular case is setting these option dynamically (depending on the values) via the setOptions method. As an example:
var chart = $("#chart").data("kendoChart");
chart.setOptions({valueAxis: {min: 0}});

Regards,
Iliana Nikolova
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Ibrahim
Top achievements
Rank 1
answered on 02 May 2014, 06:49 AM
Hello Iliano

I've tried your solution, but I don't see anything changed.

Is this the right command? I'm using AngularJS with Kendo UI.

setOptions: ({
valueAxis: {min: 0}
})

0
T. Tsonev
Telerik team
answered on 02 May 2014, 02:23 PM
Hello,

I'm not sure why the valueAxis.min value is not applied. It should fix the axis range as in this demo:
http://trykendoui.telerik.com/ODIf

But even if it is applied, it still won't be a good solution because of the concerns you express about negative values.
My recommendation is to set narrowRange to false:
http://trykendoui.telerik.com/ODIf/2

This will always keep the axis minimum at 0 for positive values.

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
Ibrahim
Top achievements
Rank 1
answered on 06 May 2014, 08:18 AM
Hey,

Could it be that there is fault in the demo of the narrowRange? When I run it, it starts from 4440. I've tried it also in my own code and also here it doesn't start from 0.

Kind regards
0
T. Tsonev
Telerik team
answered on 07 May 2014, 01:31 PM
Hello,

I'm not sure what I was looking at when I prepared the demo. Indeed the narrowRange setting has no effect in this case, as it's default value is false.
We'll consider our options to make your scenario possible by modifying the behavior of this property or by introducing a new one.

For the moment, I can suggest the following workaround:
      series: [{
        data: [4500, 4600],
        type: "column"
      }, {
        data: [0],
        visible: false
      }]

-- Live demo --

Apologies for not verifying my earlier solution properly.

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
William
Top achievements
Rank 1
answered on 19 Aug 2014, 05:44 PM
I'm having the same problem with narrowRange, the chart is completely ignoring narrowRange: false
0
T. Tsonev
Telerik team
answered on 21 Aug 2014, 08:02 AM
Hi,

Indeed the workaround from my previous reply is no longer effective.

I'm afraid the only workaround for the moment is to set the axis min value conditionally, as in this snippet.

We'll investigate this issue. Apologies for the caused inconvenience.

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
Ibrahim
Top achievements
Rank 1
Answers by
Iliana Dyankova
Telerik team
Ibrahim
Top achievements
Rank 1
T. Tsonev
Telerik team
William
Top achievements
Rank 1
Share this question
or