2

I am trying to change the shape of a line chart's points, in my app. I am using afreechart's TimeSeriesChart. I want to make this line fancy in terms of thickness, color and points shape. Where to change the code? which method will use for that?

What I'm having now:

current
(source: googlecode.com)

What I want:

desired](http://afreechart.googlecode.c![enter image description hereom/svn/doc/screenshot/images/XYDrawableAnnotationDemo01.png)

As you can see, in the first chart, the points of the line chart are opaque and rectangle(square?), and in the second one, they are fancy. So, what needs to be changed? I cant seem to figure out the variable used to store this shape value nor how to change it. Any help appreciated. Thanks in advance..

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Ace
  • 43
  • 1
  • 8

1 Answers1

2

Assuming XYLineAndShapeRenderer, you'll need to condition the renderer to use the desired shape and make the outlines visible, a shown in this example.

renderer.setSeriesShape(0, circle);
renderer.setSeriesPaint(0, line);
renderer.setUseFillPaint(true);
renderer.setSeriesShapesFilled(0, true);
renderer.setSeriesShapesVisible(0, true);
renderer.setUseOutlinePaint(true);
renderer.setSeriesOutlinePaint(0, line);

image

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
  • Hey... thanks! Those were the correct methods to use. Just had to modify a little, using setBase methods instead of setSeries so all series are affected. While on this, may I ask one more question? How to draw the line connecting two points in a series in such a way that the line doesn't really intersect the points but just stays in between them. That is, the line starts after a small distance from a point and ends a small distance before the next point. Like a dotted line but with only one big continuous segment in between two points. Hope you get the picture. Any solutions? :) Thanks again. – Ace Jul 08 '12 at 20:35
  • Excellent; I started to guess what options you needed, but you got the idea. You could _try_ the `dash` feature of `BasicStroke`, but you're probably going to need a custom renderer to make it pretty. – trashgod Jul 08 '12 at 20:53
  • Hmm.. seems like AWT library was thrown from afreechart.. would have worked on JFreeChart though. Looks like I need to use android.graphics to make a custom Stroke, then implement it in XYLineAndShapeRenderer, and apply it in the GraphActivity. Or something like that. :| – Ace Jul 09 '12 at 06:50
  • A custom renderer will generally be more satisfactory anyway. – trashgod Jul 09 '12 at 15:42