i would like to create a x shape as the points for a graph but it is not shown out? below is my coding
GeneralPath temp = new GeneralPath();
temp.moveTo(0f, 0f);
temp.lineTo(3f, 3f);
temp.moveTo(3f, 0f);
temp.lineTo(0f, 3f);
Shape shape = (Shape)temp;
plot.setDataset(7,ds);
XYLineAndShapeRenderer xylineandshaperenderer = new XYLineAndShapeRenderer();
xylineandshaperenderer.setSeriesShape(0, new GeneralPath(shape));
xylineandshaperenderer.setSeriesLinesVisible(0, false);
xylineandshaperenderer.setSeriesShapesVisible(0, true);
plot.setRenderer(xylineandshaperenderer);
customizing shapes
You need a real shape - one that defines an outline. Two lines will not do it. This is a java.awt requirement, nothing related two JFreeChart.
You can define a star like this, for example:
In order to make the shape solid, you can fill it with:
You can define a star like this, for example:
Code: Select all
GeneralPath shapeStar = new GeneralPath();
shapeStar.moveTo(0f, 1f);
shapeStar.lineTo(3f, 3f);
shapeStar.lineTo(1f, 0f);
shapeStar.lineTo(3f, -3f);
shapeStar.lineTo(0f, -1f);
shapeStar.lineTo(-3f, -3f);
shapeStar.lineTo(-1f, 0f);
shapeStar.lineTo(-3f, 3f);
shapeStar.closePath();
Code: Select all
renderer.setShapesFilled(true);