3D Chart Maintain Aspect Ratio
Moderator: Queue Moderators
- blakeadkins
- Posts: 44
- Joined: Tue Feb 25, 2014 7:49 pm
3D Chart Maintain Aspect Ratio
Is there an easy way to get a 3D chart to maintain the ratio of the window. i.e. set dimensions to window size and then have the dimensions and/or zoom auto adjust when window size is changed?
- ArctionPasi
- Posts: 1367
- Joined: Tue Mar 26, 2013 10:57 pm
- Location: Finland
- Contact:
Re: 3D Chart Maintain Aspect Ratio
If using perspective camera (View3D.Camera.OrthographicCamera == False), I think it's better to adjust camera distance.
Then the chart shows correctly also in narrow window.
Code: Select all
void m_chart_SizeChanged(object sender, SizeChangedEventArgs e)
{
const double RegularCamDistance = 200;
double dAspectRToKeepWH = 1.5;
double dAspectR = (double)m_chart.ActualWidth / (double)m_chart.ActualHeight;
if (dAspectR > dAspectRToKeepWH)
{
m_chart.View3D.Camera.ViewDistance = RegularCamDistance;
}
else
{
m_chart.View3D.Camera.ViewDistance = RegularCamDistance / dAspectR * dAspectRToKeepWH;
}
}
LightningChart Support Team, PT