Programmatically setting the view angle of a 3D Pie Chart

5 posts, 0 answers
  1. Charles Covell
    Charles Covell avatar
    11 posts
    Member since:
    Apr 2010

    Posted 20 Oct 2010 Link to this post

    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
  2. Ves
    Admin
    Ves avatar
    2927 posts

    Posted 25 Oct 2010 Link to this post

    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
  3. Charles Covell
    Charles Covell avatar
    11 posts
    Member since:
    Apr 2010

    Posted 25 Oct 2010 Link to this post

    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
  4. Ves
    Admin
    Ves avatar
    2927 posts

    Posted 27 Oct 2010 Link to this post

    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
  5. Charles Covell
    Charles Covell avatar
    11 posts
    Member since:
    Apr 2010

    Posted 27 Oct 2010 Link to this post

    Those approaches were both very educational and useful, and accomplished what I needed.  Thanks!
Back to Top