|
Problem with AreaLayer |
Posted by achar on Aug-10-2022 19:49 |
|
Hello,
I am using an AreaLayer to display a water area in a section. Whenever i draw an area, a black line appears, as shown in the attached picture. The code is very simple:
waterlayer(iA) = c.addAreaLayer()
waterdataset(iA) = waterlayer(iA).addDataSet(dataY, dataWaterAreaColor, "")
waterlayer(iA).setXData(dataX)
waterlayer(iA).setLineWidth(0)
For example, the data for the right triangle is:
datax(0)=14905.237187017408
datax(1)=16500.848
datax(2)=20758.908858257691
datax(3)=14905.237187017408
and
datay(0)=3915.596
datay(1)=-3492.651
datay(2)=3915.596
datay(3)=3915.596
Any ideas what is happening?
TIA
|
Re: Problem with AreaLayer |
Posted by Peter Kwan on Aug-11-2022 03:06 |
|
Hi achar,
The reason is because your data point flows backwards. The first 3 data point flows from left to right, while the last data point flows from right to left back to the first point.
An area layer is the region between the line formed by the data point, and a "baseline". By default, the "baseline" is at y = 0 and can be configured using Layer.setBaseLine. Its horizontal position is from the starting x coordinate to the ending x coordinate.
For your case, if you specify 3 points for your triangle, the shape should be as shown in the attached image. When you specify the 4th point to the same as the 1st point, the baseline, which is horizontal from the first point to the last point, become a pixel at the first/last point. This is the cause of the vertical line you see.
For your case, if your intention is to draw a shape with a horizontal baseline at y = 3915.596 (or some other value), you can use Layer.setBaseLine to configure the baseline. Note the the setLineWidth(0) only disables the line the joins the data points. If does not disable the "border lines" (including the baseline). To hide the border lines, use layer.setBorderColor(Chart.Transparent) or layer.setBorderColor(Chart.SameAsMainColor).
If your intention is to draw a general convex polygon, you can draw two lines for the top half and bottom half of the polygon. Each line should only run in one direction (either left to right or right to left). You can then fill the region between the lines using the InteLineLayer. See:
https://www.advsofteng.com/doc/cdnet.htm#linefill.htm
Best Regards
Peter Kwan
|
|