java - How can I add horizontal line to bar chart in Jasper Report? -
i'm trying designing report bar chart, in need add threshold. have tried multi-axis chart, in scale in different axis different.
is there other solution add line bar chart?
to draw line on bar chart add valuemarker categoryplot.
in jasper report done adding jrchartcustomizer
public class mychartcustomizer implements jrchartcustomizer { @override public void customize(jfreechart jfchart, jrchart jrchart) { categoryplot plot = (categoryplot) jfchart.getplot(); //set @ value line, color , size of stroke valuemarker vm = new valuemarker(13000,color.blue, new basicstroke(2.0f)); //add marker plot plot.addrangemarker(vm); } }
in jrxml make sure class in classpath , set customizerclass
attribute on chart tag
<barchart> <chart customizerclass="mychartcustomizer"> .... </chart> ... </barchart>
if using dynamic-reports can add directly in code
chart.addcustomizer(new drichartcustomizer() { private static final long serialversionuid = 1l; @override public void customize(jfreechart chart, reportparameters arg1) { categoryplot plot = (categoryplot) jfchart.getplot(); valuemarker vm = new valuemarker(13000,color.blue, new basicstroke(2.0f)); plot.addrangemarker(vm); } });
if using dynamic-jasper setcustomizerclass
(as in jrxml)
djbarchartbuilder().setcustomizerclass("mychartcustomizer");
example of result
note: in example no package name used, if mychartcustomizer
in package full package name needs indicated in setcustomizerclass
example "my.package.mychartcustomizer"
Comments
Post a Comment