使用jfreechart和相同类别的条形一起创建条形图 [英] Create barchart using jfreechart with bars of same category together

查看:146
本文介绍了使用jfreechart和相同类别的条形一起创建条形图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用jfreechart制作条形图,以便将属于同一类别的条形显示为相邻而没有任何间隙.类别应显示为空白. 同样,每个类别可以具有不同数量的条. 如何使用Jfreechart库实现它? 下图是我所需要的示例. 在这里,所有相同类别的条形都应具有相同的颜色,并且没有间隙(或很小的间隙).

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).

预先感谢, 阿比纳夫

推荐答案

我知道这篇文章的年龄.无论如何,我正在发布解决方案,也许其他会在这里寻找答案的人会发现它很有用.

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.

那是我使用的代码:

BarRenderer br = new BarRenderer();
br.setItemMargin(0.0);
chart.getCategoryPlot().setRenderer(br);

这篇关于使用jfreechart和相同类别的条形一起创建条形图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆