Here's a short term (very short) solution if you have to have values at the end of your bars. Im sure David can give a more robust solution in terms of growing the chart width out but this worked for me.
Edit HorinzontalBarRenderer and add the following to drawCategoryItem's...
//....
// WIDTH
double rectWidth = Math.abs(translatedValue-zeroInJava2D);
// HEIGHT
double rectHeight = itemWidth;
// DRAW THE BAR...
Rectangle2D bar = new Rectangle2D.Double(rectX, rectY, rectWidth, rectHeight);
Paint seriesPaint = plot.getSeriesPaint(series);
g2.setPaint(seriesPaint);
g2.fill(bar);
//BEGIN VALUE HACK
float valueX = (float) (rectX + 5 + rectWidth);
float valueY = (float) (rectY + rectHeight);
g2.setPaint(java.awt.Color.black);
g2.drawString(String.valueOf(value), valueX, valueY);
//END VALUE HACK
if (itemWidth>BAR_OUTLINE_WIDTH_THRESHOLD) {
g2.setStroke(plot.getSeriesStroke(series));
g2.setPaint(plot.getSeriesOutlinePaint(series));
g2.draw(bar);
}
result = bar;
Values at the end of horizontal bars
Re: Values at the end of horizontal bars
Thanks Kerry!
A quick (manual) way to get more space for your values is to call the setUpperMargin(...) method in the NumberAxis class, for example:
NumberAxis rangeAxis = (NumberAxis)myPlot.getRangeAxis();rangeAxis.setUpperMargin(0.15); // 15 percent of the total range
This will leave more space between the edge of the plot and the top of the bars. Choose a percentage that suits your data (of course, it would be nice if the code determined an appropriate setting automatically).
Regards,
DG.
A quick (manual) way to get more space for your values is to call the setUpperMargin(...) method in the NumberAxis class, for example:
NumberAxis rangeAxis = (NumberAxis)myPlot.getRangeAxis();rangeAxis.setUpperMargin(0.15); // 15 percent of the total range
This will leave more space between the edge of the plot and the top of the bars. Choose a percentage that suits your data (of course, it would be nice if the code determined an appropriate setting automatically).
Regards,
DG.