This project is read-only.

How to make vertical axis start from top end on bottom

Sep 18, 2009 at 3:59 PM

All the samples are showing chart with the Y axis start from bottom and go up, but I need to make a log chart in which the Y axis start from top and go down, and also I need to show vertical scrollbar so user can scroll the chart if the curve is going out of boundry. Is it easy?

Sep 25, 2009 at 1:53 PM

Hi,

as I think, the easies way to negate the direction of vertical axis is to apply a custom DataTransform to Viewport. This data transform should be a descendant of DataTransform class and can look like this:

 

public class NegativeYDataTransform : DataTransform
{
 public override Point DataToViewport(Point pt)
 {
  return new Point(pt.X, -pt.Y);
 }

 public override Point ViewportToData(Point pt)
 {
  return new Point(pt.X, -pt.Y);
 }
}

That you should create an instance of this class and assign it to plotter.DataTransform property: plotter.DataTransform = new NegativeYDataTransform();

This will produce the following picture:

Hope this helps.

Regards,

Mikhail.