java - Skip printing every n-th value on the x-axis for an iText/JFreeChart bar chart? -


i realize question has been asked before, other solutions have not worked out me , i'm hoping others find inconsistencies may lie.

i'm using jfreechart in itext , building bar chart using method below:

defaultcategorydataset dataset = new defaultcategorydataset();  string rowkey = "score";  for(int = 0; <= 100; i++) {     double frequency = collections.frequency(scorelist,i);     dataset.setvalue(frequency, rowkey, i+""); }  jfreechart chart = chartfactory.createbarchart("", "score distribution (%)", "count", dataset, plotorientation.vertical, false, true, false); 

it's pretty simple way make chart (although don't know false, true, false means within createbarchart() method). problem there 101 values on x-axis , don't fit onto screen/page.

i've tried drawing every 2/3/n-th value, causes graph become different entirely, want labels appear less, not actual values , graph bars themselves.

every other solution presented on stackoverflow has suggested using xyplot. when try use xyplot, get: java.lang.classcastexception: org.jfree.chart.plot.categoryplot cannot cast org.jfree.chart.plot.xyplot. although language here appears straightforward, don't know why error appears. because it's strictly bar graph that's causing error?

i've been able this:

categoryplot plotcat =  (categoryplot) chart.getplot(); valueaxis yaxis = plotcat.getrangeaxis(); categoryaxis xaxis = (categoryaxis) plotcat.getdomainaxis(); 

so seems x- , y-axes require different types of axis names? i'm confused too.

in short: how skip printing every n-th label on x-axis bar chart?

a category plot/axis implies data split separate unrelated groups e.g. states texas, california, new york etc.. therefore chart has no sensible way hide some.

this same difference between discrete , continuous data.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

inno setup - TLabel or TNewStaticText - change .Font.Style on Focus like Cursor changes with .Cursor -