Why are not all the Bars in my Barchart red?

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
shamy_de
Posts: 5
Joined: Wed Nov 19, 2014 12:51 am
antibot: No, of course not.

Why are not all the Bars in my Barchart red?

Post by shamy_de » Wed Nov 19, 2014 1:14 am

Hi there,
Somehow i am getting some white Bars into my Histogram, any idea why?


http://www.directupload.net/file/d/3811 ... xf_png.htm

int number = 155897;//max number of Pixels
HistogramDataset dataset = new HistogramDataset(); //create a Histogram
dataset.setType(HistogramType.RELATIVE_FREQUENCY);

dataset.addSeries("Histogram",doubleArray,number);
String plotTitle = "Histogram";
String xaxis = "pixel";
String yaxis = "intensity";
PlotOrientation orientation = PlotOrientation.VERTICAL;//sets the vertical orientation of the Histogram
boolean show = false;
boolean toolTips = false;
boolean urls = false;
JFreeChart chart = ChartFactory.createHistogram( plotTitle, xaxis, yaxis,
dataset, orientation, show, toolTips, urls);

int widthg = 500;
int heightg = 300;
try {
ChartUtilities.saveChartAsPNG(new File("histogram41.PNG"), chart, widthg, heightg);//converted the Histogram to image foramt(PNG) and saves it in your workspace
} catch (IOException e) {}
}}

shamy_de
Posts: 5
Joined: Wed Nov 19, 2014 12:51 am
antibot: No, of course not.

Re: Why are not all the Bars in my Barchart red?

Post by shamy_de » Fri Nov 21, 2014 10:58 am

Is it really no one out there, that can tell me why???

matinh
Posts: 483
Joined: Fri Aug 11, 2006 10:08 am
Location: Austria

Re: Why are not all the Bars in my Barchart red?

Post by matinh » Fri Nov 21, 2014 1:33 pm

To me this seems like a rendering artifact. The bars are quite small on the image. Did you try enlarging the chart?

hth,
- martin

shamy_de
Posts: 5
Joined: Wed Nov 19, 2014 12:51 am
antibot: No, of course not.

Re: Why are not all the Bars in my Barchart red?

Post by shamy_de » Fri Nov 21, 2014 2:12 pm

now i zoomed it and actually most of the bars are like 2- or 3-coloured.
some are redwhite some are red and hellred and all i do want is just all of them to be just standard RED :)

matinh
Posts: 483
Joined: Fri Aug 11, 2006 10:08 am
Location: Austria

Re: Why are not all the Bars in my Barchart red?

Post by matinh » Fri Nov 21, 2014 7:13 pm

How did you zoom? Zoom the generated PNG?
You should create a PNG with higher resolution or zoom in your application.

shamy_de
Posts: 5
Joined: Wed Nov 19, 2014 12:51 am
antibot: No, of course not.

Re: Why are not all the Bars in my Barchart red?

Post by shamy_de » Sat Nov 22, 2014 2:48 pm

http://www.ayukucode.org/wp-content/upl ... xample.jpg

why is there a thin white line at the left side of evry bar, i need the bar to have only one colour

matinh
Posts: 483
Joined: Fri Aug 11, 2006 10:08 am
Location: Austria

Re: Why are not all the Bars in my Barchart red?

Post by matinh » Mon Nov 24, 2014 8:40 am

Ha, just what I thought!

That's eyecandy ;-) Try this:

Code: Select all

ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
hth,
- martin

shamy_de
Posts: 5
Joined: Wed Nov 19, 2014 12:51 am
antibot: No, of course not.

Re: Why are not all the Bars in my Barchart red?

Post by shamy_de » Mon Nov 24, 2014 8:10 pm

Thanks a lot
I tried that, but now i need to find out how to turn off the shadows of the bars that are been showed.

matinh
Posts: 483
Joined: Fri Aug 11, 2006 10:08 am
Location: Austria

Re: Why are not all the Bars in my Barchart red?

Post by matinh » Mon Nov 24, 2014 8:56 pm

BarRenderer.setDefaultShadowsVisible(false)
Or the corresponding method if you are using a different renderer.

hth,
- martin

Locked