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

Drawing X axis on chart view at zero when negative values exist.

6 Answers 997 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Tyler
Top achievements
Rank 1
Tyler asked on 20 Mar 2014, 08:50 PM
Hello,

Quick question, as I'm sure there is an easy solution for this, is there anyway to keep the x axis on the chart view at zero when one of the series in the graph contains a negative value? The image I have attached will explain this a bit better. If you look right next to the zero on the y axis, there is a value that goes below zero. What I'm looking for is to have my categorical x axis drawn right at that zero mark and have it look just like what you see in the desired view image. Any info on how to pull this off will be greatly appreciated. Thanks!

6 Answers, 1 is accepted

Sort by
0
Tyler
Top achievements
Rank 1
answered on 21 Mar 2014, 12:30 PM
I think a better way to word what i'm saying is I would like to draw the x axis at y=0.

Thanks!
0
Ivan Petrov
Telerik team
answered on 25 Mar 2014, 12:13 PM
Hello Tyler,

Thank you for writing.

To limit the axis value on a LinearAxis you can use the Minimum property. Here is a short example of how to access and set this property:
LineSeries series = new LineSeries();
this.radChartView1.Series.Add(series);
((LinearAxis)series.VerticalAxis).Minimum = 0d;

I hope this will be useful. Should you have further questions, I would be glad to help.

Regards,
Ivan Petrov
Telerik
 

Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

 
0
Tyler
Top achievements
Rank 1
answered on 25 Mar 2014, 12:36 PM
Ivan,

Unfortunately, that's not quite it. When you set the minimum for a series, it literally makes it the minimum value that the series can go. As a result, the negative value that I need to see gets cut off.
The following code produced the attached image..

LineSeries testing = new LineSeries();
testing.Datapoints.add(new CategoricalDatapoint(Convert.toDouble("-20"), "0");
testing.Datapoints.add(new CategoricalDatapoint(Convert.toDouble("10"), "1");
testing.Datapoints.add(new CategoricalDatapoint(Convert.toDouble("-5"), "2");
testing.Datapoints.add(new CategoricalDatapoint(Convert.toDouble("30"), "3");
testing.Datapoints.add(new CategoricalDatapoint(Convert.toDouble("-1"), "4");
chart.Series.Add(testing);
((LinearAxis)testing.VerticalAxis).Minimum = 0;

Any other suggestions?
0
Ivan Petrov
Telerik team
answered on 28 Mar 2014, 08:33 AM
Hello Tyler,

Thank you for your reply.

The idea behind the property is to set a fixed value as the beginning of an axis and leave only the maximum (if not set) to be auto-calculated by the chart. Currently, this is how axes are constrained and their position cannot be moved as my colleague Georgi has explained in your other ticket "Example of using negative values in winforms.

If you have other questions, do not hesitate to write back.

Regards,
Ivan Petrov
Telerik
 

Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

 
0
Holger
Top achievements
Rank 1
answered on 07 May 2019, 01:13 PM

This is an old thread, but the original question wasn't answered.

Just for people who search the forums, the answer can be found here:

https://docs.telerik.com/devtools/winforms/controls/chartview/axes/axis-alignment

It's about moving the axis, not about setting the mininum.

0
Dimitar
Telerik team
answered on 08 May 2019, 12:42 PM
Hello Holger,

Thank you for referring the solution. I have updated your Telerik Points.

Regards,
Dimitar
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.
Tags
ChartView
Asked by
Tyler
Top achievements
Rank 1
Answers by
Tyler
Top achievements
Rank 1
Ivan Petrov
Telerik team
Holger
Top achievements
Rank 1
Dimitar
Telerik team
Share this question
or