Search code examples
javanetbeansjfreechart

How to eliminate the punctuation on jfreechart


i want to eliminate (punctuation or comma) on my value plot

here is my code

LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();

    /** **/
    int z = Integer.parseInt(set_render_font.getText());
    Font fontr = new Font("Arial", Font.PLAIN, z);
    renderer.setBaseItemLabelFont(fontr);
    /** **/

    renderer.setBaseItemLabelsVisible(Boolean.TRUE);
    renderer.setSeriesShapesVisible(0, false);
    renderer.setSeriesLinesVisible(0, false);
    renderer.setBaseItemLabelGenerator((CategoryItemLabelGenerator) new StandardCategoryItemLabelGenerator());

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
 rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    renderer.setShapesVisible(true);
    renderer.setDrawOutlines(true);
    renderer.setUseFillPaint(true);

    plot.getRenderer().setSeriesPaint(0, Color.decode("#FEC240"));

    jchart=chart;

my chart like this the result. how to eliminate the punctuation.


Solution

  • You need to specify the number format of your ItemLabelGenerator:

      DecimalFormat df = new DecimalFormat();
      df.setGroupingUsed(false);
      renderer.setBaseItemLabelGenerator((CategoryItemLabelGenerator) new StandardCategoryItemLabelGenerator("{2}", df));