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?

my expect output chart below: enter image description here

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 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 setcustomizerclass (as in jrxml)

djbarchartbuilder().setcustomizerclass("mychartcustomizer"); 

example of result

chart

note: in example no package name used, if mychartcustomizer in package full package name needs indicated in setcustomizerclass example "my.package.mychartcustomizer"


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -