Author |
Topic  |
|
Benlehman
6 Posts |
Posted - 11 Feb 2010 : 10:42:50
|
I was wondering if there was a way to have the Chart "zoom to fit" the current set of points. I have several SimpleScatterPlots since I have the need for multiple types of points; red circles, blue triangles, etc). I have a requirement to only show certain plots under certain situations. Currently I remove all plots that I do not want to show (ChartView.DeleteChartObject). This works fine, but I would like the chart to zoom to fit the SimpleScatterPlots that are still remaining. I have tried the PhysicalCoordinates.AutoScale and it seems to sorta work, but it doesn't zoom in far enough. Also, it seems to no longer draw the LinearAxis when it zooms in. Any help would be greatly appreciated.
Thank you for your help, |
|
quinncurtis
1164 Posts |
Posted - 11 Feb 2010 : 11:53:57
|
Trying to change a chart into a different chart, by deleting objects, rescaling, ect. can be difficult, and is rarely the best choice. The simplest method is to just write your graph creation routine to plot the specific items you want in the current graph, allowing it to auto-scale on the current data you want plotted. It is easy enough to verify that this works for any combination of your data. Then, if you want remove or add things, just clear the chart using the ChartView ResetChartObjectList method, redefine what you want to plot, and call your chart creation routine again. You will design your chart creation routine to plot all combinations of your data, using whatever flags you want to use. You may need to include an Invalidate (or chartVu.UpdateDraw) at the end of your graph creation routine to force an update of the screen. |
 |
|
Benlehman
6 Posts |
Posted - 11 Feb 2010 : 17:46:46
|
Do to the amount of data we are dealing with I have to maintain the plots state so I cant simply replot the points. I think I have found a better way to disable the drawing of the scatter plots I do not want shown, by setting the GraphObj to diabled. Also, I found if I change the AutoScale to exact or near then I get the desired result. This all works great, but I still have the same problem that the linear axis, their titles, and ticks are not being drawn. I have verifiied that their respective draw methods are being called, but for some reason they just dont show. The points know the boundaries, because I can see they stop where the axis should start, but no axis are visible. I know they are enabled and part of the graph objects collection and like I said the draw methods are being called. Thanks again for you help, |
 |
|
Benlehman
6 Posts |
Posted - 11 Feb 2010 : 18:01:32
|
So I determined that they are being drawn, but they are being drawn off screen, I can't make my form big enough to show much of any of the axis. Basically the X axis is drawn too low and the Y axis is drawn too far left. I also noticed that when it auto scaled the axis didnt scale properly, for example; a point that was at X:10 and Y:10 was now shown to be at X:2 Y:20 when the scale was applied. If you have any suggestions for these two problems I would be so greatful. |
 |
|
quinncurtis
1164 Posts |
Posted - 11 Feb 2010 : 19:16:08
|
Our answer is to use our suggestion.
Having a lot of data points will not affect things one way or another. Everything needs to be re-drawn no matter what you do.
Every single aspect of the chart, including the the coordinate system and axes needs to be re-autoscaled and drawn. That is what is done in the initial chart and that will work 100% of the time. There is no speed improvement in trying to do it piecemeal.
Please try it, and if it is unacceptable explain why. |
 |
|
quinncurtis
1164 Posts |
Posted - 11 Feb 2010 : 19:41:22
|
If you plan on sticking with your approach, you need to re-autoscale the coordinate system for the datasets you plan to display, then call CalcAutoAxis and CalcAutoAxisLabels on each of the axes and axes labels. If you apply any other changes to the axes and axes labels, these will need to be set again, because the auto-axis routines map the axes to the current coordinate system, but return everything else to the defaults.
int n = 2; // number of datasets in view SimpleDataset [] plotsinview = new SimpleDatasetp2[n];
plotsinview [0] = Dataset1; plotsinview [1] = Dataset2;
pTransform1.AutoScale(plotsinview, ChartObj.AUTOAXES_FAR, ChartObj.AUTOAXES_FAR); xAxis.CalcAutoAxis(); yAxis.CalcAutoAxis(); xAxisLab.CalcAutoAxisLabels(); yAxisLab.CalcAutoAxisLabels();
This will be no faster than the first method we described. And there is no other way to do it other than these two. We don't like this method because it is usually completely redundant with code in the original graph building routine. The AutoScale routine is called in the graph building routine and the the CalcAutoAxis and CalcAutoAxisLabels are called in the constructors of the axis and axis labels objects.
|
 |
|
Benlehman
6 Posts |
Posted - 16 Feb 2010 : 11:49:23
|
I'm sorry it has taken me so long to respond. I guess I should have provided more information. We are maintaining a list of hundreds of thousands points. And we are adding\removing thousands per second. This would force us to have to create several new SimpleScatterPlots (since we are dealing with red circles, blue squares, etc) and re-add all of the points to the correct SimpleScatterPlot. I am more than willing to try your way, and I completely agree that it would make things so much easier, but I can't imagine that will be faster than just maintaining the current collection of SimpleScatterPlots. Another kicker is that we have "selected" points, which is nothing but another SimpleScatterPlot drawing a square around the point itself. There is a requirement that they can turn off selected or unselected causing us to have to stop drawing one or the other sets of SimpleScatterPlots. This means we can feasibly be added\removing hundreds of thousands of points on demand. We seem to be pushing your tool to its limits, but so far it has withstood the test. I do have it working the second way you suggested by just re-scaling everything when needed. If I find the time to try out your original suggestion I will be sure to add a reply and let everyone know how it performs. Thanks for your quick responses and help. |
 |
|
|
Topic  |
|
|
|