在JFreeChart中堆积的条形图,条形图内的百分比组成,总和高于条形图 [英] Stacked Bar Chart with percentage composition inside the Bar and total above the Bar in JFreeChart

查看:157
本文介绍了在JFreeChart中堆积的条形图,条形图内的百分比组成,总和高于条形图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建堆积条形图.我的要求是,我需要条形图中的百分比组成以及条形图顶部的总数.请提出解决方案.

I am trying to create a Stacked Bar Chart. My requirement is I need percentage composition inside the bar and total count on top of the Bar. Please suggest solutions.

我的要求: 样本: http://www.jfree.org/jfreechart/api/javadoc/images/StackedBarRenderer3DSample.png

我要在条形图中添加百分比成分,并在条形顶部上方选择总成分.

I want percentage composition inside the bar and total composition on the top of the bar.

推荐答案

目前尚不清楚您正在做什么,而是使用 ,遍历每一列的数据集,并覆盖drawItem()以绘制结果.可以在 JFreeChart Demo 中找到一个示例. 作为StackedBarChartDemo3的一部分.

It's not clear what you are doing now, but using a StackedBarRenderer with setRenderAsPercentages(true) will display the percentages. To get the total, extend StackedBarRenderer, loop through the dataset for each column, and override drawItem() to draw the result. An example may be found in the JFreeChart Demo as part of StackedBarChartDemo3.

或者,考虑使用自定义 CategoryToolTipGenerator ,通过setBaseToolTipGenerator()添加.

As an alternative, consider a custom CategoryToolTipGenerator, added via setBaseToolTipGenerator().

附录:您使用

Addendum: You linked to an example using StackedBarRenderer3D, which also has a setRenderAsPercentages() method. It can be extended similarly.

这篇关于在JFreeChart中堆积的条形图,条形图内的百分比组成,总和高于条形图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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