This is a migrated thread and some comments may be shown as answers.

Programmatically setting the view angle of a 3D Pie Chart

4 Answers 95 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Charles Covell
Top achievements
Rank 1
Charles Covell asked on 20 Oct 2010, 07:12 PM
Hi,

I have a 3D pie chart using the Pie3dSeriesDefinition with a CameraExtension to enable the user to drag and change the viewing angle of the chart.  At certain instances, I want to programmatically set the chart to a certain viewing angle.  How can I do this?

Thanks,

Charley

4 Answers, 1 is accepted

Sort by
0
Ves
Telerik team
answered on 25 Oct 2010, 10:49 AM
Hello Charles Covell,

Please, find attached a small example. The key point is in the ViewportCamera configuration:

<media3d:ViewportCamera FieldOfView="60" Position="5,87.5,250" LookDirection="0.18, -0.21, -1" />

The origin of the coordinate system is at the chart area's lower left corner. So here is an example -- increasing the value of X property of the ViewportCamera's position would lead to moving the camera to the left, so you would need to decrease the X of the LookDirection. The values above are the default ones, while the attached example uses these:

Position="95,127.5,250" LookDirection="-0.18, -0.41, -1"

Sincerely,
Ves
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Charles Covell
Top achievements
Rank 1
answered on 25 Oct 2010, 04:30 PM
Thanks for your prompt reply.  The enclosed code works great for setting the chart's viewing angle in XAML.

I am sorry if I wasn't clear in my previous post, but I would actually like to be able to set the viewing angle of the chart at certain instances in the flow of my program--that is, during runtime--from the codebehind (C# for me).  I am sure there must be a good way to do this, because the CameraExtension allows the viewing angle to be changed on the fly through mouse drags.  If you could give me some advice on how to do so using the codebehind, I would greatly appreciate it!

Thanks for the help,

Charley
0
Ves
Telerik team
answered on 27 Oct 2010, 06:07 PM
Hi Charles,

You can find an updated version of that example attached. It shows two possible approaches -- finding the ViewportCamera and altering its properties or using the CameraExtension API -- methods like Zoom, RotateX, RotateY, RotateZ, RotateXY etc.  The latter is commented, you can uncomment the three lines in the button click event handler.

Best regards,
Ves
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Charles Covell
Top achievements
Rank 1
answered on 27 Oct 2010, 06:24 PM
Those approaches were both very educational and useful, and accomplished what I needed.  Thanks!
Tags
Chart
Asked by
Charles Covell
Top achievements
Rank 1
Answers by
Ves
Telerik team
Charles Covell
Top achievements
Rank 1
Share this question
or