add diamond marker on StackedBarChart

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
prfc
Posts: 1
Joined: Thu May 03, 2012 9:42 am
antibot: No, of course not.

add diamond marker on StackedBarChart

Post by prfc » Thu May 03, 2012 9:58 am

Hi,

For the moment, I have a StackedBarChart with only one horizontal bar whith no axis visible and a classic Marker on it (a vertical line with the same height of the bar).

Code: Select all

JFreeChart chart = ChartFactory.createStackedBarChart(
	null, "Ratio", "%", dataset, PlotOrientation.HORIZONTAL, false, false, false 	);
		
CategoryPlot plot = (CategoryPlot)chart.getPlot();
plot.setBackgroundPaint(new Color(0,0,0,0));
plot.setOutlineVisible(false);
CategoryAxis domainAxis = plot.getDomainAxis();
domainAxis.setVisible(false);
ValueAxis rangeAxis = plot.getRangeAxis();
rangeAxis.setVisible(false);
rangeAxis.setLabel(null);
		
final Marker start = new ValueMarker(valueMarker);
start.setPaint(Color.black);
start.setLabel(null);
start.setStroke(new BasicStroke(5.0f, BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND, 1.0f, null, 0.0f));
start.setLabelAnchor(RectangleAnchor.CENTER);
start.setLabelTextAnchor(TextAnchor.CENTER_RIGHT);
plot.addRangeMarker(start);

I need just one diamond Shape on my bar instead of the marker. What kind of object do I need (a sort of lineandshape without line) ?

thanks for the help

Amit9344
Posts: 6
Joined: Fri Apr 22, 2016 7:06 pm
antibot: No, of course not.

Re: add diamond marker on StackedBarChart

Post by Amit9344 » Fri Apr 22, 2016 7:31 pm

Did any one find solution for the post.Please let me know even I'm looking for same chart

Amit9344
Posts: 6
Joined: Fri Apr 22, 2016 7:06 pm
antibot: No, of course not.

Re: add diamond marker on StackedBarChart

Post by Amit9344 » Fri Apr 22, 2016 7:49 pm

http://www.hostingpics.net/viewer.php?i ... thLine.png

I'm looking for something like above chart.

paradoxoff
Posts: 1634
Joined: Sat Feb 17, 2007 1:51 pm

Re: add diamond marker on StackedBarChart

Post by paradoxoff » Mon Apr 25, 2016 4:47 pm

You can write your own implementation of CategoryAnnotation. This annotation should be similar to org.jfree.chart.annotations.CategoryTextAnnotation, but instead of drawing a text at the position defined by the value and the category key, your new annotation would simply draw a vertical or horizontal line dependent on the plot orientation. Your new class could directly extends AbstractAnnotation.

Amit9344
Posts: 6
Joined: Fri Apr 22, 2016 7:06 pm
antibot: No, of course not.

Re: add diamond marker on StackedBarChart

Post by Amit9344 » Mon Apr 25, 2016 10:02 pm

Thanks paradoxoff.

Locked