|
Draw Line between points in 3D scatter graph |
Posted by db on Jul-24-2014 15:15 |
|
Hi, now i want to connect the 3D points in a 3D scatter graph with lines. Which function
should i use to do this? I check the manual but only find ThreeDScatterChart->addline(),
which can only draw 2d lines in the chart.
Please help me , many thanks |
Re: Draw Line between points in 3D scatter graph |
Posted by Peter Kwan on Jul-25-2014 03:05 |
|
Hi db,
Unluckily, there is no API that can be used to create a 3D line. May be instead of a 3D line,
you can drawn many very small symbols between the two points. For example, you may use
interpolation to create 100 equally spaced points between the two points, and then add
another scatter group using these 100 points with a small black symbol. Then you may be
able to get something like a "dotted line".
Regards
Peter Kwan |
Re: Draw Line between points in 3D scatter graph |
Posted by db on Jul-25-2014 09:47 |
|
Thanks for your reply.
If I use your way, how to change the size of dot to make the dot point smaller than the
other points?
And do you have plans to add the function of drawing 3D lines in the future?
Thank you |
Re: Draw Line between points in 3D scatter graph |
Posted by Peter Kwan on Jul-26-2014 03:00 |
|
Hi db,
You can specify the color, shape and size of a symbol when your add a 3D scatter group.
The "3D Scatter Groups" sample code is an example of using 3D scatter groups. See:
http://www.advsofteng.com/doc/cdcpp.htm#threedscattergroups.htm
In the above sample code, the 3 scatter groups are added all with different colors, but
they are of the same shape and size. The code in the example is:
// Add 3 scatter groups to the chart with 9 pixels glass sphere symbols of red
// (ff0000), green (00ff00) and blue (0000ff) colors
c->addScatterGroup(xData0, yData0, zData0, "Alpha", Chart::GlassSphere2Shape, 9,
0xff0000);
c->addScatterGroup(xData1, yData1, zData1, "Beta", Chart::GlassSphere2Shape, 9,
0x00ff00);
c->addScatterGroup(xData2, yData2, zData2, "Gamma", Chart::GlassSphere2Shape, 9,
0x0000ff);
Instead of setting all the symbols to 9 pixels in size as in the above code, you can add a
scatter group 3 pixels in size. These symbols will then be much smaller than the other
symbols.
In the next version of ChartDirector, there will be functions to determine the image pixel
coordinates from 3D (x, y, z) data value coordinates. If you know the image pixel
coordinates of two points, you can create a line to join the two points using
BaseChart.addLine.
Note that the line drawn this way would not have the correct 3D "z-order". A real 3D line
can be partially blocked by some symbols or other lines (because the symbols or other
lines are in front of the line), and objects in 3D can "mutually blocks" each others (that
is, line A can be in front of line B, and line B in front of line C, and line C in front of line
A). The method mentioned above produces lines that are either behind all points of in
front of all points. These lines are most useful for marking or decorating the background,
or for marking or highlighting a particular point (such as creating a line to connect a point
to a label).
Regards
Peter Kwan |
|