How to remove black border generated in CharDirector ContourLayer?

53 views Asked by At

I have this piece of code that generates an image. I pass proper expected data to this method and it is generating the image as expected except 1 thing.

ContourLayer layer = c.addContourLayer(dataX, dataY, zData);

double[] myColorScale = {-2,0x000000,0.0,0x00ffff,minval, 0xFFD700, maxval}; //this line creates the issue 

        // set the color scale, with underflow color 0x0000ff and overflow color 0xff0000
        layer.colorAxis().setColorScale(myColorScale, 0x00ffff, 0xFF6347);

Image that has issue - Need the black border removed which is outside

Expected output image is: Expected output image is this

1

There are 1 answers

2
user3100235 On

In your code, the black color is for -2 < x < 0. (Note the zero value is not black.) The cyan color is for 0 <= x < minval and for x < -2 (underflow color).

The black ring probably is because the value at that point brief drops below 0 (such as -0.0000000001). I do not know what is your data, but I can think of two possibilities:

(a) The data near the center is larger than 0 (such as x = 10), while the data at the border of the chart is a large negative value (such as x = -99). Both of these values are cyan in color. However, from x = 10 to x = -99, there must be a region which is -2 < x < 0, so that region is black in color. This causes the black ring. To check if this is the cause of the problem, please use another underflow color (such as 0x0000ff), so we can see if the cyan at the border is due to underflow or not. If this in fact the cause of the problem, and if you just want to artificially fill the outer region with cyan, you can use a value between 0 <= x < minval, or you can just set the background color of the plot area to cyan.

(b) In your coloring scheme, the zero value is cyan. If you are using spline interpolation, it is possible for the spline to undershoot. So even if smallest data points are 0, some interpolated region can drop below 0 (such as -0.00001), and they become black in your coloring scheme. I have attached an image to explain why a spline can overshoot or undershoot. To test if this is the cause of the problem, please try to set the interpolation method to bi-linear to see if there is any difference:

layer.setSmoothInterpolation(false);

enter image description here