ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  3D scatter plot setViewAngle
Posted by xavier on Jul-10-2014 06:20
How I can change the view angle of a 3d scatter plot with out to have to rebuild the complete plot?

I just want to redraw it with the new angle without to have to set the X,Y,Z data. I have to many data point and it will take to long the rebuild the plot.

I am using the mouseMoveChart event to compute new elevation and rotation angle. the angle gets updated but the chart does not rotate. the rotation occurs only if I rebuild the chart because the data have changed. it takes up to 10 second to build the chart from scratch.

I need to have the rotation almost track the mouse motion, a small delay is acceptable (but not 10 sec)

Xavier

  Re: 3D scatter plot setViewAngle
Posted by Peter Kwan on Jul-11-2014 01:21
Hi Xavier,

Configuring the chart and passing data to ChartDirector always take negligible time
compared to actually redraw the chart. It is because the time needed to pass a data
value to ChartDirector is negligible compared to the time needed to draw the data value
graphically. If you have a lot of data points, you may think it takes a lot of time to pass
those data to ChartDirector, but still the time will be negligible when compared to the
time needed to draw those points graphically.

Even if you do not need to pass the data to ChartDirector, if you rotate the chart,
ChartDirector would still need to redraw all the data points graphically, and it will take
similar amount of time.

I do think 10 seconds is a long time for a 3D scatter plot. Are you having millions of data
points? Have you enabled the image map (the getHTMLImageMap, usually for tooltips)?
For huge number of points, the image map will take significant more time to create than
the chart itself. It is because it is time consuming to create user interface elements on
the chart (you can image each point to be a tiny push button capable of all the mouse
events and you have millions of them). On the other hand, there is no need to create the
image map unless the mouse is moving over the chart. So one method is to delay
creating the image map until the mouse moves over the chart.

Also, do not try to update the chart in any events occuring at a rapid rate (like mouse
move events). For example, if you moves the mouse slightly, it may have already
generated 30 mouse move events. If the mouse events occurs faster than the chart can
redraw, Windows may not update the screen until all the mouse events are processed. It
means the chart will be redrawn 30 times before Windows will update the screen. It may
take a while, and also 29 of the charts are wasted (as they are never displayed). If you
continue to move the mouse before all the previous mouse events are processed, then
the display may be further delayed.

Instead, in the mouse event handler, please store the update angles in some member
variables of your Form, then call "WinChartViewer.updateViewPort". This will trigger the
ViewPortChanged event. You can then update the chart in the ViewPortChanged event
handler (plot the chart based on the angles in the member variables).

Suppose it takes 100ms to redraw a chart, but Windows is producing one mouse move
event every 50ms. If the chart is drawn directly in the mouse move event handler, the
mouse move events will queue up, and Windows will not update the screen until all the
mouse events are handled, and this is what is causing the delay. With the
ViewPortChanged method, the mouse move event itself is very fast, as it just needs to
store the angles into variables and call updateViewPort. So no mouse events will queue
up. On the other hand, there will be lots of ViewPortChanged events. Now ChartDirector
can merge all those ViewPortChanged events together so they never queue up, and so
the display will update every 100ms, the same as the chart plotting time.

You may notice that in all ChartDirector examples that have "drag to scroll" feature, the
chart is always updated in the "ViewPortChanged" event handler. That is why the chart
can update smoothly despite the fast rate of the mouse events.

Regards
Peter Kwan