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

7 posts, 0 answers
  1. Tyler
    Tyler avatar
    3 posts
    Member since:
    Nov 2013

    Posted 20 Mar 2014 Link to this post

    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!
  2. Tyler
    Tyler avatar
    3 posts
    Member since:
    Nov 2013

    Posted 21 Mar 2014 Link to this post

    I think a better way to word what i'm saying is I would like to draw the x axis at y=0.

    Thanks!
  3. Ivan Petrov
    Admin
    Ivan Petrov avatar
    713 posts

    Posted 25 Mar 2014 Link to this post

    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.

     
  4. Tyler
    Tyler avatar
    3 posts
    Member since:
    Nov 2013

    Posted 25 Mar 2014 in reply to Ivan Petrov Link to this post

    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?
  5. Ivan Petrov
    Admin
    Ivan Petrov avatar
    713 posts

    Posted 28 Mar 2014 Link to this post

    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.

     
  6. Holger
    Holger avatar
    33 posts
    Member since:
    Jan 2015

    Posted 07 May Link to this post

    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.

  7. Dimitar
    Admin
    Dimitar avatar
    2807 posts

    Posted 08 May Link to this post

    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.
Back to Top