ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Area with Border as spline layer
Posted by Ankit Jain on Jan-15-2018 16:18
Attachments:
Hi Peter,

I want to create a area chart which should be smoothed. What I did is, I create a area layer and add spline layer over it to make it smooth and using addInterLineLayer to color it. Till that everything works great.
Next step was to add border over this layer.

For adding border to a smoothed chart(area + splinelayer) I added another spline layer to it but the end edges are coming out of area.

Is there any way to make it in sycn with area.?

Please find attached 2 images.

Area_SpLinelayer.jpg : This includes a spline layer over smoothed chart.
Area_WithoutSpLine.jpg : Non smoother chart.Area + border only.


Let me know also if above approach is ok.
Area_SpLinelayer.jpg
Area_SpLinelayer.jpg

21.18 Kb
Area_WithoutSpLine.jpg
Area_WithoutSpLine.jpg

22.15 Kb

  Re: Area with Border as spline layer
Posted by Peter Kwan on Jan-15-2018 23:47
Hi Ankit,

You can try XYChart.setClipping. For example:

c.setClipping();

Hope this can help.

Regards
Peter Kwan

  Re: Area with Border as spline layer
Posted by Peter Kwan on Jan-16-2018 01:29
Hi Ankit,

You can try XYChart.setClipping. For example:

c.setClipping();

Hope this can help.

Regards
Peter Kwan

  Re: Area with Border as spline layer
Posted by Ankit Jain on Jan-16-2018 11:58
Hi Peter,

This works perfect for me but it also clip the last label "testlable" label at last datapoint.
Anyway to accommodate this as well.

Thanks
Ankit

  Re: Area with Border as spline layer
Posted by Peter Kwan on Jan-16-2018 14:18
Hi Ankit,

The cause of the issue is because the line or spline is very wide. At this line width, you can clearly see how the line terminates (in computer graphics, it is called the line cap). If the line is horizontal, the line ending edge will be vertical. If the line is vertical, the line ending edge is horizontal. For lines that are neither vertical or horizontal, the line cap depends on whether it is nearer to vertical or horizontal.

For the spline line, it is steeper (or more vertical) at the right side and is treated as a vertical line the the line cap. (It is probably because the spline curve is rounded and less steep at the top turning point, so it must be steeper at the end in order to join the points.) For the straight line is not as steep and is treated as a horizontal line for the line cap.

So for other data, it is possible for both types of line to be treated as vertical line for the line cap.

The XYChart.setClipping will clip all layers to the plot area. This is not enabled by default because in may charts, it is possible for the some part layers to draw outside the plot area (such as the labels in your case). To solve the problem, there are two methods:

- Instead of using a very thick line, you just color the pink region as an another area (using the think border and fill in between), instead of as a thick line. When I first looked at the chart, I initially thought it is a filled area. Only when I saw the line cap did I notice it is a very thick line. So I think drawing it as an area is quite natural.

- I am not sure how your labels area added. If you can add the labels not using a layer, then it will not be subjected to clipping. Some methods that can add labels are BaseChart.addText, Axis.addMark, etc..

Regards
Peter Kwan

  Re: Area with Border as spline layer
Posted by Ankit Jain on Jan-17-2018 20:06
Attachments:
Hi Peter,

I think I can't add area over top of area because I am using spline layer to smooth the existing one.

I will work on label issue later but here is another one.
Could you please review where the things are getting messed up

I am using below code for putting the area with gradient color.
int color;

color = c.linearGradientColor(c.getPlotArea().getRightX(), 0, 0, 0,
pLayer.getEndingColor(),pLayer.getStartingColor());
FrontLayer.getDataSet(0).setDataColor(color);

now I am adding spline layer to give it a smoothed shape

SplineLayer layerspine = c.addSplineLayer(pLayer.getDataPointData(),color);
c.addInterLineLayer(layerspine.getLine(), c.yAxis().addMark(-99999999, 0x000000).getLine(), color);

Now it is something related to shading. When I have 100% as color percent everything looks ok. but when I reduce this percentage below 100 say 50.the color of area and color between area and spline layer looks different.

Although same color variable is used and it is not getting change in between.

Please find attached images for both the case.

Thanks
Ankit
Area_UniformColor.jpg
Area_UniformColor.jpg

29.39 Kb
Area_nonUniformColor.jpg
Area_nonUniformColor.jpg

29.56 Kb

  Re: Area with Border as spline layer
Posted by Peter Kwan on Jan-18-2018 00:12
Hi Ankit,

I was thinking you are just using the spline curve and the interline layer to creating the chart. Are you using an "area layer" as well? The "area layer" does not seem to be necessary. I think the code below, without using any area layer, should already obtain what you need:

SplineLayer layerspine = c.addSplineLayer(pLayer.getDataPointData(), color);
c.addInterLineLayer(layerspine.getLine(), c.yAxis().addMark(-99999999, 0x000000).getLine(), color);

For your case, it seems you have both an area layer and an interline layer partially overlapping. If you use a semi-transparent color, the region that overlaps should have a different color from the region that does not ovelrap. It is like looking through sunglasses. If you wear two pairs of sunglasses at the same time, it will be darker than just one pair of sun-glasses.

If your area is created out of just one layer (the interline layer), then the color will be uniform.

Regards
Peter Kwan