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#)
 Auto scaling for bar graphs
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

quinncurtis

1164 Posts

Posted - 04 Oct 2004 :  15:12:46  Show Profile  Reply with Quote
Using QCChart2D I'm having issues getting my chart scale set properly. When I use "transform.AutoScale(data);" to scale a bar graph, I end up with half the bar on the far left and far right cut off (off the edge of the char). This becomes worse when working with a grouped bar chart, as several bars are off the edge of the chart and not seen.

When examining your sample programs, I notice that the chart scale is often manually set to properly fit known data. I'm working with unknown data. How do I autoscale a chart to fit an unknown calendar range, or unknown number range and leave some extra space on the ends to ensure no chart data is lost from view?

quinncurtis

1164 Posts

Posted - 04 Oct 2004 :  17:30:58  Show Profile  Reply with Quote
The coordinate system and axis auto-scale routines do not take into account the plots that you place within the coordinate system. If you select a bar plot (or any other plot type that has a user defined Width), the auto scale routines cannot take that into account because the scale is set before the plot type is added to the chart.

The simplest solution is to just subtract the bar width that you plan to use from the initial auto-scale minimum scale value. From that point on the axis will auto scale to match, and the bar plot will not be cut off.

TimeSimpleDataset Dataset1 = new TimeSimpleDataset("Actual Sales",x1,y1);

TimeCoordinates pTransform1 = new TimeCoordinates();

pTransform1.AutoScale(Dataset1, ChartObj.AUTOAXES_FAR , ChartObj.AUTOAXES_FAR);

pTransform1.ScaleStartX -= ChartCalendar.GetCalendarWidthValue(ChartObj.MONTH,8)/2;


If the bar is to be right justified against the x-value, subtract the width of the bar, if it center justified subtract half the bar width as above.
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