English 中文(简体)
Create barchart using jfreechart with bars of same category together
原标题:

I want to make bar chart using jfreechart such that the bars which belong to the same category should be displayed adjacent without any gaps. The categories should be displayed with gaps. Also each category may have different number of bars. How it can be achived using Jfreechart library? Following image is the sample of what I require. Here all the bars of same category should be of same color and with no gap(or a very little gap).

alt text

Thanks in advance, Abhinav

最佳回答

I am aware of the age of this post. Anyway I am posting my solution, maybe someone else who will find himself here looking for the answer will find it useful.

I was looking for the answer but didn t find it and had to figure it out myself.

That is the code I use:

BarRenderer br = new BarRenderer();
br.setItemMargin(0.0);
chart.getCategoryPlot().setRenderer(br);
问题回答

You can do this with the setCategoryMargin() method on the domain axis.

For example with a Category Plot:

CategoryPlot plot = chart.getCategoryPlot();
CategoryAxis domainAxis = plot.getDomainAxis();
domainAxis.setCategoryMargin(0.15f);

You will need to play with different values for the margin to find the correct value for your graph.





相关问题
wpf-DragDrop in a listbox with groupstyle

I am using the control library from http://code.google.com/p/gong-wpf-dragdrop/successfully for my listbox dragging operation.But there is an issue when i drop an item to a listbox with a group style....

Combine pairs to groups [PHP / Arrays]

I have pairs of items in an PHP array. Example: <?php $elements = array( tiger => lion , car => bike , lion => zoo , truck => plane ); ?> Now I want to combine ...

LINQ Merging results in rows

I have a LINQ query which returns a set of rows. The structure is: NAME, col1, col2, col3, col4 name1 1 null null null name1 null 1 null null name1 null null 1 1 As a ...

How to group items by date range in XSLT?

I have a bunch of data that looks a little like this: <item> <colour>Red</colour> <date_created>2009-10-10 12:01:55</date_created> <date_sold>2009-10-20 22:...

Self-Joins, Cross-Joins and Grouping

I ve got a table of temperature samples over time from several sources and I want to find the minimum, maximum, and average temperatures across all sources at set time intervals. At first glance this ...

Grouping with SubSonic 3

I have the following table "GroupPriority": Id Group Priority 1 1 0 2 2 0 3 3 0 4 2 1 5 1 1 6 2 2 7 ...

热门标签