在JFreeChart中堆积的条形图,条形图内的百分比组成,总和高于条形图 [英] Stacked Bar Chart with percentage composition inside the Bar and total above the Bar in 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屋!