|
MultiChart... include two surface chart |
| Posted by Hong on Oct-16-2025 13:28 |
|
I want merge two surface chart at one DrawArea.
Two surface chart is divided by Z-Axis Value.
One is upper zero, other is below zero.
But, my code is not work.
First surface chart is not shown.
Just second surface chart is shown.
And, Chart is not update before rolling mouse wheel. :-(
Can I get some sample code about it?
My code is here.
///////////////////////////////
CRect rect;
viewer->GetClientRect(rect);
int nWidth = rect.Width();
int nHeight = rect.Height();
MultiChart* m = new MultiChart(nWidth, nHeight);
double fWidth = rect.Width() * 0.7;
double fDepth = 200;
int nX = (int)(rect.left + rect.Width() / 2) - 20;
int nY = (int)((rect.top + rect.Height() / 2) - 10);
int zHeight = (int)(rect.Width() * 0.35) - 15;
// Surface #1
SurfaceChart* c_Top = new SurfaceChart(nWidth, nHeight);
c_Top->setPlotRegion(nX, nY, (int)fWidth, (int)fDepth, zHeight);
c_Top->setViewAngle(m_dElevationAngle_3D, m_dRotationAngle_3D);
c_Top->setData(DoubleArray(m_pData_3D_X, m_nSize_3D_Y), DoubleArray(m_pData_3D_Y, m_nSize_3D_X), DoubleArray(m_pData_3D_Z, m_nSize_3D_X * m_nSize_3D_Y));
c_Top->setWallVisibility(true, true, true);
// Surface #2
SurfaceChart* c_Back = new SurfaceChart(nWidth, nHeight);
c_Back->setPlotRegion(nX, nY, (int)fWidth, (int)fDepth, zHeight);
c_Back->setViewAngle(m_dElevationAngle_3D, m_dRotationAngle_3D);
c_Back->setData(DoubleArray(m_pData_3D_Back_X, m_nSize_3D_Y), DoubleArray(m_pData_3D_Back_Y, m_nSize_3D_X), DoubleArray(m_pData_3D_Back_Z, m_nSize_3D_X * m_nSize_3D_Y));
c_Back->setWallVisibility(true, true, true);
m->addChart(0, 0, c_Top);
m->addChart(0, 0, c_Back);
m->setMainChart(m);
deleteMultiChart((MultiChart*)viewer->getChart());
viewer->setChart(m); |
Re: MultiChart... include two surface chart |
| Posted by Peter Kwan on Oct-17-2025 00:24 |
|
Hi Hong,
Your code creates two independent surface charts. The two charts are at the same position (0, 0) in the MultiChart. The plot area of the two charts are also at the same position (fWidth, fDepth, zHeight). So the two charts exactly overlap. If the second chart does not have a transparent backgroiund, it will cover and hide the first chart.
Whether the data are positive or negative are not important. As the two charts are independent, the axis will auto-scale so that the surface will be at the center of the plot region. It is not "one surface at the top" and "one surface at the bottom".
Do you actually want to draw two surfaces on the same plot region sharing the same axis scale, like the following example:
https://www.chartdir.com/forum/download_thread.php?bn=chartdir_support&thread=1553840180#N1553840180
The above example is achieved by:
(a) Draw the bottom surface chart. Configure the axis scale so that it can accommodate the data for both surfaces.
(b) Draw the top surface chart with the axis scale synchronize with that of the first chart. Disable the walls and configure the background to be transparent. So the chart contains just the surface only.
(c) Merge the top chart to the bottom chart using DrawArea.merge
If the above is what you need, please let me know. I can write a short example for you.
Best Regards
Peter Kwan |
|