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
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
Comments
Post a Comment