|
resizing charts |
Posted by MBB on Jun-27-2009 03:26 |
|
Hi,
I have more questions. I would like to create charts that can be moved and resized. I note that the size of the plot is specified by:
Dim c As XYChart
Set c = cd.XYChart(450, 420)
So what to do if one wants to make the chart larger once it has been created?
I am imagining that I could have a form for each chart and then when the form was resized, attempt to recreate the chart with new values for the XYChart call. Is this the only way to "resize" existing charts? And is this even possible? Form_Resize would be called repeatedly....recreating the chart every time would be extremely inefficient. Do you have experience with resizing charts?
And is putting a chart on a form a typical action some users take? I don't see any other way to move my charts around and control their life...I want a close box to click on to destroy the charts. I have poked around the very good documentation but the only resize reference I can find is in the graphics primitives. The zoom and scroll demos show a chart in a window but it doesn't resize.
TIA,
MBB |
Re: resizing charts |
Posted by Peter Kwan on Jun-27-2009 14:30 |
|
Hi MBB,
You may try to see the charts in the "Windows Performance Monitor" (enter "perfmon" in the command line), or in the "Windows Task Manager" (click on the Performance tab).
When you enlarge a chart in the above applications, the plot area is increased. However, the font size or line width is not increased. The axis labels may change (with more grid lines and more labels), etc.. So you can see it iis not a graphics stretch of the chart. Instead, it is a completely redraw of a chart.
So redraw the chart is a normal and common method to resize a chart. It is not necessarily slow and inefficient comparing to other methods to resizing a chart. So long as your resize code only draws the chart (but does not re-query the database for the data again), it is not necessarily inefficient.
Also, you do not have to resize the when the form when the user is still dragging on the form to resize it. You only need to resize the chart when the resizing is done (eg. when the user has released the mouse button, or when the form stops changing size for 0.5 second, etc).
You can drag the chart around using the same method as you would for any other control. For example, you may handle the mouse down/move/up events, and to use them to control the Left and Top properties of the control (in case of the chart, it is the ChartViewer control).
I think VB does not allow you to "click a close box to destroy a control", but you can hide a control by using the Visible property.
To resize a chart, you just need to put a bigger chart in the ChartViewer control.
For more information on how to drag a VB control, or to hide a VB control, please refer to the VB documentation.
Hope this can help.
Regards
Peter Kwan |
|