1

I implemented a code to represent a bar chart (as of picture). Now my problem is that I want to add $ sign to the values to represent the currencies. So that the values would be:

$0 ---- $500,000 ----- $1,000,000

Any idea?

enter image description here

pms
  • 944
  • 12
  • 28

2 Answers2

3

As shown here, you can use NumberFormat.getCurrencyInstance():

NumberFormat currency = NumberFormat.getCurrencyInstance();
NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
domainAxis.setNumberFormatOverride(currency);
Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
1

Thanks. Exactly that's what I found as well

final CategoryPlot plot = chart.getCategoryPlot();
NmberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
DecimalFormat format = new DecimalFormat("$##,###,###,###");
rangeAxis.setNumberFormatOverride(format);

pms
  • 944
  • 12
  • 28