In the next version of our software, we would like to allow the user to drag and drop axis around. I am in the beginning stages of coding this feature, and I have already run in to an issue:
I can use Axis.Clicked(x, y) to see if a mouse click is inside the axis, but this only checks the tiny area where the ticks are. How do I get the rectangle that encompasses the entire axis area, including the labels and titles? I wonder the user to be able to drag from anywhere in that area, not just the ticks. AxisTitle has no Clicked method, and in fact it's Top, Left, Width and Height properties are always 0 (so I can't even created the rect for myself).
Is there a way to work around? Or a way to get the complete axis rect, including the titles and labels?
Drag and drop axes, having an issue
-
- Newbie
- Posts: 16
- Joined: Fri Jul 27, 2007 12:00 am
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi MattHolmes,
In that case you can try combining properties shown in the code snippet below. For labels's width you can use MaxLabelsWidth and for title's dimensions you could use its Font.Size or even ChartRect's bounds.
In that case you can try combining properties shown in the code snippet below. For labels's width you can use MaxLabelsWidth and for title's dimensions you could use its Font.Size or even ChartRect's bounds.
Code: Select all
private void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
{
listBox1.Items.Clear();
listBox1.Items.Add("tChart1.Axes.Left");
listBox1.Items.Add("IStartPos: " + tChart1.Axes.Left.IStartPos);
listBox1.Items.Add("IEndPos: " + tChart1.Axes.Left.IEndPos);
listBox1.Items.Add("MaxLabelsWidth: " + tChart1.Axes.Left.MaxLabelsWidth());
listBox1.Items.Add("Title.Font.Size: " + tChart1.Axes.Left.Title.Font.Size);
listBox1.Items.Add("tChart1.Chart.ChartRect.Left: " + tChart1.Chart.ChartRect.Left);
}
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
-
- Newbie
- Posts: 16
- Joined: Fri Jul 27, 2007 12:00 am
Hello,
I actually figured this out yeterday. This is what I did, which works perfect:
I actually figured this out yeterday. This is what I did, which works perfect:
Code: Select all
Graphics g = this.CreateGraphics ();
SizeF size = g.MeasureString (axis.Title.Caption, axis.Title.Font.DrawingFont);
int width = axis.MaxLabelsWidth ();
width += (int)Math.Ceiling (size.Height);
Rectangle rect = axis.AxisRect ();
rect.Offset ((axis.OtherSide ? 0 : -width), 0);
rect.Width += width;