jfreechart - Text labels inside jfree Gantt chart bars -


i have simple gantt chart here, consists of number of tasks that:

taskseries s1 = new taskseries("planned tasks"); task newtask = new task("task" + string.valueof(taskindex), new simpletimeperiod(currenttime, currenttime + (int) distributiontime) ); s1.add(newtask)  final taskseriescollection collection = new taskseriescollection(); collection.add(s1);  jfreechart chart = chartfactory.createganttchart( "distribution ",  "task",  "time",  collection,  true,  true,  false  ); 

is there way write inside each bar, representing task? example, if task made of 2 subtasks, possible mark them labels, names seen on plot? in advance!

to add a lable inside each item set setbaseitemlabelgenerator in case i'm using intervalcategoryitemlabelgenerator can implement own extending categoryitemlabelgenerator.

use code:

categoryplot plot = (categoryplot) chart.getplot(); categoryitemrenderer renderer = plot.getrenderer(); renderer.setbaseitemlabelgenerator( new intervalcategoryitemlabelgenerator()); renderer.setbaseitemlabelsvisible(true); renderer.setbaseitemlabelpaint(color.black); renderer.setbasepositiveitemlabelposition(new itemlabelposition( itemlabelanchor.inside6, textanchor.bottom_center)); 

you shold this: b

ganttt chart baseitemlabelgenerator

to customise lables implement categoryitemlabelgenerator

renderer.setbaseitemlabelgenerator( new categoryitemlabelgenerator(){      @override     public string generaterowlabel(categorydataset dataset, int row) {         return "your row text  " + row;     }      @override     public string generatecolumnlabel(categorydataset dataset, int column) {         return "your column text  " + column;     }      @override     public string generatelabel(categorydataset dataset, int row, int column) {         return "your label text  " + row + "," + column;     }   }); 

in example generatelabel controls lable in bar, categorydataset, row , column can used determine bar labelling

enter image description here


Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -