Quinn-Curtis Forums
Quinn-Curtis Forums
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Tools for Microsoft .Net & .Net Compact Framework
 QCChart2D and QCChart2D CF (VB and C#)
 Pixel padding to fit labels
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

cheetah

4 Posts

Posted - 23 May 2007 :  15:58:11  Show Profile  Reply with Quote
In my code, I have a chart ready with a dataset and several labels. I'm about to update the ScaleStart/Stop values for the X and Y axes, and want to adjust the Y stop so that all the labels stay within the plot area. The best way I've come up with so far is to use my transform (CartesianCoordinates) to find out how many pixels I have available in the Y axis, and do some math like:

paddedYSize = desiredYSize * (availablePixels + labelPixels) / availablePixels

Is there a more straight forward way that I can just say "use this Y size plus this many extra pixels"?

quinncurtis

1164 Posts

Posted - 24 May 2007 :  09:46:43  Show Profile  Reply with Quote
We don't have a special way of padding an coordinate system scale with extra pixels.

If you have something that works you should just stick with that.

We would probably use something like, below, working in normalized graph coordinates (NORM_GRAPH_POS) or normalized plot coordinates (NORM_PLOT_POS), to pad the x-scale with some extra space. You can't really work in pixel coordinates when you create the graph, because the pixel size of the graph is not known until the graph is actually rendered, which takes place at a time later than the code that defines the graph.


CartesianCoordinates pTransform1;
.
. // Define initial coodinate system
.

Dimension normdim = new Dimension(0.02,0.02);
Dimension physdim = pTransform1.ConvertDimension(ChartObj.PHYS_POS,normdim,ChartObj.NORM_PLOT_POS );
pTransform1.ScaleStartX -= physdim.Width;
pTransform1.ScaleStopX += physdim.Width;


This example would subtract an extra 2% from the start of the x-scale, and add 2% to the end of the x-scale.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Quinn-Curtis Forums © 2000-07 Quinn-Curtis, Inc. Go To Top Of Page
Powered By: Snitz Forums 2000 Version 3.4.07