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

Message ListMessage List     Post MessagePost Message

  How can I draw lines and arcs ?
Posted by Jack on Dec-08-2015 13:21
Hi Peter,

I want to draw a polyline with lines and arcs, how can I achieve?

I have test addSplineLayer,addStepLineLayer and so on. But none can solve my problem.

Is there available C++ sample code to accomplish the above ?

Any suggestion may help.

Thanks

Jack

  Re: How can I draw lines and arcs ?
Posted by Peter Kwan on Dec-09-2015 04:27
Attachments:
Hi Jack,

As ChartDirector is a charting problem, the line it draws is based on your data points. If
you want to draw lines and arcs, first, make sure your data points line on the lines and
arcs, then join them together using a suitable method. If your data points are dense,
you just join them with straight lines (addLineLayer). If your data points are sparse, you
can join them with spline curves. In this case, to keep the straight line straight, you can
insert additional end points.

I have attached an example, which is just a simple spline curve, but with some data
that represent curves and straight lines. The code is as follows:

doubel dataY[] = {32, 32, 39, 39, 23, 23, 41, 30, 30, 26, 26, 35, 29};
double dataX[] = {1, 1, 2, 2, 3, 4.1, 5, 5.5, 5.5, 7.5, 7.5, 8, 9};
int pointCount = (int)(sizeof(dataX) / sizeof(dataX[0]));

XYChart *c = new XYChart(600, 300);
c->setPlotArea(55, 20, 520, 235, 0xffffff, -1, 0xcccccc, 0xcccccc, 0xcccccc);

SplineLayer *layer = c->addSplineLayer();
layer->setLineWidth(2);

layer->addDataSet(DoubleArray(dataY, pointCount), 0x0000c0)->
setDataSymbol(Chart::CircleSymbol, 9, 0xffff00);

layer->setXData(DoubleArray(dataX, pointCount));

c->makeChart("c:\\\\test.png");

Regards
Peter Kwan
test.png

  Re: How can I draw lines and arcs ?
Posted by Jack on Dec-09-2015 12:57
Hi peter

I understand  your saying,so I need to convert the parameters arc to real value.

Thank you.