0

I'm doing bar chart with JFreeChart, and my category is completely overlapped. I've seen already JFreechart: Displaying X axis with values after specific units, but I can't do this with mine somehow. I have

DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    for (int l = 1; l<256; l++)
    {
        dataset.setValue(CountRed[l],"Red",Integer.toString(l));
        dataset.setValue(CountBlue[l], "Blue", Integer.toString(l));
        dataset.setValue(CountGreen[l], "Green", Integer.toString(l));

    }
    JFreeChart chart = ChartFactory.createStackedBarChart("RGB", "pixels", "Num", dataset, PlotOrientation.VERTICAL, false, true, false);

    CategoryPlot p=chart.getCategoryPlot();
    p.setRangeGridlinePaint(Color.BLACK);
    CategoryAxis xAxis = p.getDomainAxis();
    xAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_90);
    xAxis.setTickLabelFont(new Font("Times New Roman", Font.PLAIN, 7));

    ImgDiag1 = chart.createBufferedImage(700,250);
    diag1 = new ImageIcon(ImgDiag1);
    jLabel4.setIcon(diag1);

where CountRed, CountBlue and CountGreen are arrays of int. So there are numbers 0-255, and I'd like to show for example every 30 of them in category. Hope you can help me.

https://i.stack.imgur.com/wB7Xf.jpg

image

Update: With a stacked bar chart it looks like this:

image

Community
  • 1
  • 1
Okeyman
  • 43
  • 8
  • Please edit your question to include a [complete example](http://stackoverflow.com/help/mcve) that exhibits the problem you describe; post a [screenshot](http://meta.stackoverflow.com/questions/99734/how-do-i-create-a-screenshot-to-illustrate-a-post) to [imgur](http://imgur.com) and cite a link. – trashgod Oct 09 '14 at 02:31
  • Updated. This diagram shows how many pixels of red color of each value(0-255) there is in the image. – Okeyman Oct 09 '14 at 09:25
  • Have you looked at [`ChartFactory.createHistogram()`](http://stackoverflow.com/search?q=%5Bjfreechart%5D+ChartFactory.createHistogram)? – trashgod Oct 09 '14 at 10:16
  • Just tried this. It gives me wrong result. It looks like this http://imgur.com/fGqRezk btw i'm now need to use stacked bar chart – Okeyman Oct 10 '14 at 11:19
  • so the result must be this http://imgur.com/G4bnWwi but this category still overlapped. – Okeyman Oct 10 '14 at 11:26
  • Please edit your question to include a [complete example](http://stackoverflow.com/help/mcve) that shows your updated approach. – trashgod Oct 10 '14 at 12:52
  • Done. I hope someone can help me now. – Okeyman Oct 10 '14 at 13:30

0 Answers0