|
Set color to be transparent for 0 on a surface chart |
Posted by David Littau on Oct-13-2011 01:37 |
|
I have created a surface chart that looks okay. However, it puts in a color when the height of the surface is zero. I would like that to be transparent instead. All the values for height are greater than or equal to zero.
Is there a good way to do this? It would be okay if it were transparent for small values of height (e.g. 0.1) as well, as long as the "tops" have color. If the solution involves specifying the range of colors, that's fine. I will eventually have to do that too.
thanks,
David |
Re: Set color to be transparent for 0 on a surface chart |
Posted by David Littau on Oct-13-2011 08:34 |
|
I should have also said that this is a scatter plot. It has to be, given the nature of the data. |
Re: Set color to be transparent for 0 on a surface chart |
Posted by Peter Kwan on Oct-14-2011 01:27 |
|
Hi David,
For your case, one simple method is to set the "underflow" color to transparent.
To do this, you need to create an underflow condition, by manipulating the axis scale and/or your data. I think for your case, the simplest method is as follows:
(a) Replace all your zero data value with -1 (or -0.1, or -999).
(b) Set the z-axis scale so that the lower limit is 0. In this way, your negative data "underflow".
c.zAxis().setLinearScale(0, Chart.NoValue);
(c) Set the underflow color to transparent:
c.colorAxis().setColorGradient(false, null, Chart.Transparent, Chart.Transparent)
Note that even with the above method, the chart created will not be a true "3D scatter chart". There will still be a slope joining your data points to z = 0. It would look more like a 3D "pointed bar chart".
If you really want a 3D Scatter Chart, and do not mind to test "beta software", I can send the beta version of ChartDirector Ver 5.1 to you, which supports 3D Scatter Chart.
Regards
Peter Kwan |
Re: Set color to be transparent for 0 on a surface chart |
Posted by David Littau on Oct-14-2011 03:43 |
|
I tried to change the z-axis scale settings but they were ignored. I was trying to start the scale at something greater than zero.
The problem is I don't actually specify any points that have zero height. I just supply a set of scatter points all having positive height. Therefore, I cannot set the zero points to something less than zero because they are implied.
I attached a picture just to show you what I'm drawing. You can see the "floor" of the imagine is colored in, and I need it to be blank.
If the beta version of 5.1 is relatively stable I would be happy to try it out, especially if it can solve my problem.
|
Re: Set color to be transparent for 0 on a surface chart |
Posted by David Littau on Oct-14-2011 03:46 |
|
Sorry, I totally forgot what I was doing. I must be setting values to be zero somewhere. Sorry for the confusion.
However, I would still like to try the beta version to see how it works.
thanks,
David |
Re: Set color to be transparent for 0 on a surface chart |
Posted by David Littau on Oct-14-2011 04:01 |
|
Okay, I tried your suggested method and it had no effect. I verified that the zero values were being set to negative values, and the z axis only displays from 0 on up, but the color on the flat plane is still there, just like in the picture I uploaded.
Is there anything else I can try?
thanks,
David |
Re: Set color to be transparent for 0 on a surface chart |
Posted by Peter Kwan on Oct-15-2011 03:03 |
|
Hi David,
I have just uploaded the beta version with some 3D scatter sample code to:
http://www.advsofteng.com/netchartdir510b1.zip
It can generate true 3D scatter chart like the one I attached.
Sorry for the mis-information in my last message. I have tried myself, and to make an underflow condition, I need to use the following code:
c.colorAxis().syncAxis(c.colorAxis());
c.colorAxis().setLinearScale(1, Chart.NoValue);
c.colorAxis().setRounding(false, true);
c.colorAxis().setColorGradient(true, null, Chart.Transparent, Chart.Transparent);
There is no need to touch the z-axis, but just to manipulate the color axis.
Hope this can help.
Regards
Peter Kwan
|
Re: Set color to be transparent for 0 on a surface chart |
Posted by David Littau on Oct-16-2011 11:05 |
|
If I use the settings exactly as you stated, and don't set the 0-valued points to a negative number, I get the following graph. The first picture shows the results, with the graphed items hovering over the field, and the items with less height removed completely.
If I set the 0-valued points to a small negative number, and in place of what you said, change the one function call to have a 0 in the first argument:
c.colorAxis().setLinearScale(0, Chart.NoValue);
then I get the result in the second picture, which is really quite close to what I need. I need to have it so no negative values are shown in the z-axis scale (labeled Pulse Count in my pictures), and the grid does not appear at all.
I will look at the beta code, and plan to offer the true scatter plot as an option for the user if it tests out okay, but I will need the other kind of plot working as well.
Thanks for your help so far. I'm really close to what I need.
David
|
Re: Set color to be transparent for 0 on a surface chart |
Posted by Peter Kwan on Oct-17-2011 22:30 |
|
Hi David,
To control the z-axis scale (to make sure it starts from 0 even though there are negative data), you may use the same method as the color axis. For example:
c.zAxis().setLinearScale(0, Chart.NoValue);
Hope this can help.
Regards
Peter Kwan |
Re: Set color to be transparent for 0 on a surface chart |
Posted by David Littau on Oct-18-2011 06:58 |
|
It doesn't seem to work that way. Given the following piece of code:
c.colorAxis().syncAxis(c.colorAxis());
c.colorAxis().setLinearScale(0, Chart.NoValue);
c.colorAxis().setRounding(false, true);
c.colorAxis().setColorGradient(true, null, Chart.Transparent, Chart.Transparent);
// c.zAxis().setLinearScale(0, Chart.NoValue);
//c.zAxis().setRounding(false, true);
If I leave the last two lines commented, I get the last picture I uploaded, with negative values for the z-axis. If I take the comments out, I get the first picture I uploaded, with color appearing at 0. Setting the linear scale for the z-axis seems to cancel out anything I did to the color axis.
I guess the command either conflicts with it or overrides it. I tried changing the order, putting the two lines referencing the z-axis first, but it didn't make a difference.
David |
Re: Set color to be transparent for 0 on a surface chart |
Posted by Peter Kwan on Oct-19-2011 02:06 |
|
Hi David,
May be try to use a slight negative value, and then the followings:
c.colorAxis().syncAxis(c.colorAxis());
c.colorAxis().setLinearScale(0, Chart.NoValue);
c.colorAxis().setColorGradient(true, null, Chart.Transparent, Chart.Transparent);
c.zAxis().setLinearScale(-0.01, Chart.NoValue);
c.zAxis().setRounding(false, true);
Hope this can help.
Regards
Peter Kwan |
Re: Set color to be transparent for 0 on a surface chart |
Posted by David Littau on Oct-19-2011 02:55 |
|
That solved the problem. It now works exactly as I desired. Perhaps I was not making my negative value small enough, I don't know, but in either case, using -0.01 for the "0" height value and the other settings exactly you wrote, it works.
Thanks for all your help,
David
|
|