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

Message ListMessage List     Post MessagePost Message

  Fill inside a curve data
Posted by Ray Kissen on Jan-30-2013 23:13
Hi Peter,

I'm using a licenced CD inside VC++ 2008 and want to fill a closed curve with a color. Your
MFC examples show only filling to the zero line (y=0) but not inside a closed curve. How do
do this?

Regards,
Ray

  Re: Fill inside a curve data
Posted by Peter Kwan on Jan-31-2013 00:52
Hi Ray,

Are you referring to filling among lines in an XYChart?

For the built-in layers, the filling does not need to be to the zero line (y = 0). For example, see the "Inter-Line Coloring" sample code and "Line Comparison" sample code.

However, the lines must flow from left to right, or right to left. If a line is "zig-zag" in the x-direction (that is, sometimes flows from left to right, then folds back and flows from right to left, and so on), then the "inter-line coloring" will not work.

As a result, inter-line coloring would not work on a closed curve, as a closed curve necessarily means it can flow backwards.

In a polar chart, ChartDirector can fill closed curves, but the data points must flow other clockwise or counter-clockwise and not in random directions.

If you have a close curve in an XYChart, if your can separate the curve into the upper half and lower half so that the x-flow direction of both curves are either from left to right or right to left, then you can add them as two line layers, and fill the region between them.

If the close curve is an arbitrary polygon that can be of any shape (such as a self intersecting concave polygon, such as how a "five pointed star" is drawn by hand), so that it is not possible to cut it into two halves with monotonic x-coordinates, the only method to draw it is to use low level drawing functions, such as DrawArea.polygon (which can draw any arbitrary polygons). Unluckily, it only works for polygons (which has straight edges), but not "curves".

Regards
Peter Kwan

  Re: Fill inside a curve data
Posted by Ray Kissen on Jan-31-2013 04:14
Attachments:
Hi Peter,

I found the solution in the freeware SimplexNumerica that also use
ChartDirector (CD) inside (see Attachment). But we want to use CD directly.

Regards,
Ray
CurveFill.png

  Re: Fill inside a curve data
Posted by Peter Kwan on Feb-01-2013 01:11
Hi Ray,

I am not sure exactly how the curved shape is implemented in SimplexNumerica. Apparently, the curve is not computed by ChartDirector. Curves computed by ChartDirector should pass through all data points, but in the chart you attached, the curve does not pass through all the data points.

My guess is that SimplexNumerica uses its own algorithm to compute the curve, then reduces the shape to a polygon and asks ChartDirector to plot the polygon. (In computer graphics, virtually all shapes are plotted as polygons. All the spline curves in ChartDirector are in fact polygons that approximate the actual shape, with an error of no more than 0.5 pixel.)

If the above is the case, to do similar things, your code would need to compute the curve and reduces it to a polygon, then ask ChartDirector to plot the polygon.

Regards
Peter Kwan

  Re: Fill inside a curve data
Posted by Ray Kissen on Feb-01-2013 05:53
Hi Peter,

thank you very much for your response. You said to use CD to plot the developed curve by my own. Understood that, but how to shade (the resulting polygon) inside a curve like this with CD?

Regards,
Ralf

  Re: Fill inside a curve data
Posted by Peter Kwan on Feb-01-2013 19:37
Hi Ray,

When you use DrawArea.polygon, you may ask ChartDirector to fill the polygon. (The DrawArea.polygon API includes an argument for the fill color.)

Hope this can help.

Regards
Peter Kwan