天道酬勤,学无止境

jfreechart

Creating an area graph below a XYDifference(Renderer) graph

I have been trying for the last week to find a way to make JFreeChart display something similar to the image below. Basically you are looking at three series (upper, middle, lower) with a fill inbetween. And underneath there is a (light green) fill color, or an area chart as some would perhaps call it - no meaning, just for looks. The only thing really missing from what I have come up with is the last part: the fill underneath / area chart: I even tried to subclass XYDifferenceRenderer and combine it with the renderer for Areachart, but I could not control the height of the areachart

2021-09-24 13:43:26    分类:问答    java   graphics   jfreechart   renderer

Series lines not showing up properly in JFreeChart

I am working with this plot where the data and the lines are not showing properly. When it has more data and while zooming it with mouse wheel, the lines are not showing properly. I tried placing polygon box around series line thinking that the series will show up like the XYTextAnnotation, but it's not working. import java.awt.Color; import java.awt.BasicStroke; import org.jfree.chart.ChartPanel; import org.jfree.chart.JFreeChart; import org.jfree.chart.annotations.*; import org.jfree.data.xy.XYDataset; import org.jfree.data.xy.XYSeries; import org.jfree.ui.ApplicationFrame; import org.jfree

2021-09-24 04:32:25    分类:问答    java   r   charts   jfreechart

Java 需要 stepRender 行用于某些但不是所有行(Java Need stepRender lines for some but not all lines)

问题 我有一个 JFreeChart,上面绘制了几条不同的线。 我需要将一些行更改为步进线。 我知道我需要使用 CategoryStepRenderer,但在实现它时遇到了麻烦。 我附上了以下用于更改线条颜色的代码。 我希望能够以类似的方式完成步骤线。 我发现的所有方法都涉及更改所有行。 谢谢 private void updateChartColor(ArrayList mlColor,ArrayList mlLine){ XYPlot plot=(XYPlot)chart.getPlot(); XYLineAndShapeRenderer renderer=(XYLineAndShapeRenderer)plot.getRenderer(); for (int i = 0; i < mlColor.size(); i++) { renderer.setSeriesPaint(i, mlColor.get(i)); } } 回答1 JFreeChart 允许您在每个绘图中拥有多个渲染器。 您可以将XYStepRenderer与XYLineAndShapeRenderer结合使用,此示例改编自 JFreeChart Demos import java.awt.BasicStroke; import javax.swing.JPanel; import org.jfree.chart

2021-09-24 03:27:26    分类:技术分享    java   jfreechart   renderer

Could not initialize class org.jfree.chart.JFreeChart

EDIT: Hi there i am using JBoss 7.1 Runtime Server and i have an Problem on my MAC when i build my Project and run it on localhost i get always an ERROR from the JFreeChart Library that it could not initialize. I'm using Maven to import all my Library's my repository's was: <repositories> <repository> <id>java.net2</id> <name>Repository hosting the jee6 artifacts</name> <url>http://download.java.net/maven/2</url> </repository> <repository> <id>JBoss repository</id> <url>https://repository.jboss.org/nexus/content/groups/public-jboss/</url> </repository> <repository> <id>org.openfaces</id> <url

2021-09-24 03:18:03    分类:问答    java   macos   jboss   localhost   jfreechart

Add GeneralPath shape in XYShapeAnnotation of JFreechart

I am trying to adding a general shape to highlight an area where Y is greater than X in JFreechart. for that i have defined a general path. int x3Points[] = {0, (int) Math.max(maxX, maxY), (int) Math.max(maxX, maxY), 0}; int y3Points[] = {0, (int) Math.max(maxX, maxY), (int) maxY, (int) maxY}; GeneralPath filledPolygon = new GeneralPath(GeneralPath.WIND_EVEN_ODD, x3Points.length); filledPolygon.moveTo(x3Points[0], y3Points[0]); for (int index = 1; index < x3Points.length; index++) { filledPolygon.lineTo(x3Points[index], y3Points[index]); } filledPolygon.lineTo(x3Points[0], y3Points[0])

2021-09-23 21:59:18    分类:问答    java   jfreechart

Java Need stepRender lines for some but not all lines

I have a JFreeChart that has several different lines plotted on it. I need to change some of the lines to step lines. I know I need to use the CategoryStepRenderer but am having trouble implementing it. I attached the following code that I use to change the color of the lines. I would like to be able to do the step line in a similar way. All of the ways I have found involve changing all of the lines. Thanks private void updateChartColor(ArrayList mlColor,ArrayList mlLine){ XYPlot plot=(XYPlot)chart.getPlot(); XYLineAndShapeRenderer renderer=(XYLineAndShapeRenderer)plot.getRenderer(); for (int

2021-09-23 20:02:02    分类:问答    java   jfreechart   renderer

如何使用 JFreeCharts 将图例绘制为表格?(How to draw legend as a table with JFreeCharts?)

问题 我可以像这样绘制这个图表: 但是我想像这样绘制它,这意味着在图表的底部并作为表格(至少看起来像一个)。 这是我的代码: package charts; import java.awt.*; import java.io.*; import org.jfree.chart.ChartUtilities; import org.jfree.chart.ChartFactory; import org.jfree.chart.JFreeChart; import org.jfree.chart.block.BlockBorder; import org.jfree.chart.labels.PieSectionLabelGenerator; import org.jfree.chart.labels.StandardPieSectionLabelGenerator; import org.jfree.chart.plot.PiePlot; import org.jfree.chart.title.LegendTitle; import org.jfree.chart.title.TextTitle; import org.jfree.data.general.DefaultPieDataset; import org.jfree.ui.RectangleEdge; public

2021-09-23 16:27:37    分类:技术分享    java   user-interface   plot   charts   jfreechart

将 JFreeChart 系列名称映射到系列索引(Mapping JFreeChart Series Name to Series Index)

问题 我正在使用StackedXYBarRenderer绘制TimeTableXYDataset 。 不幸的是,每个系列的颜色在刷新时都会发生变化。 我知道如何使用渲染器的setSeriesPaint方法设置颜色,但这需要一个整数系列索引作为参数。 我使用字符串作为系列名称创建我的数据点: ds.add(new SimpleTimePeriod(us.getDate(), new Date(us.getDate().getTime() + 1000*60)), us.getTotal(), us.getName())); 如何发现系列名称和系列索引之间的映射,以便我可以调用setSeriesPaint ? 回答1 最简单的方法是随着数据的积累更新合适的Map 。 或者,方法 getSeriesKey() 和 indexOf() 可用于在任一方向进行转换。 例如, for (int i = 0; i < ds.getSeriesCount(); i++) { String name = (String) ds.getSeriesKey(i); System.out.println(ds.indexOf(name) + ": " + name); }

2021-09-21 13:46:54    分类:技术分享    java   jfreechart

JFreeChart 拨入 NetBeans JButton(JFreeChart dial in NetBeans JButton)

问题 当我按下 NetBeans 中的JButton时,我正在尝试使用JFreeChart进行拨号。 问题是,虽然代码在JButton之外看起来没问题,但当我把它放在里面时它会给我程序错误。 private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here } public class DemoChartProblem { private final DefaultValueDataset dataset = new DefaultValueDataset(50); private final JFrame frame = new JFrame(); public void main(String[] args) throws Exception { new DemoChartProblem(); } public DemoChartProblem() { frame.setPreferredSize(new Dimension(300, 300)); frame.add(buildDialPlot(0, 30, 5)); frame.pack(); frame.setLocationRelativeTo(null); frame

2021-09-21 09:43:36    分类:技术分享    java   swing   jbutton   jfreechart

从 CombinedDomainXYPlot 获取图(并删除它们)(Get plots from CombinedDomainXYPlot (and remove them))

问题 如果我不保留对它们的任何引用,有没有办法将绘图列表添加到 CombinedDomainXYPlot 中? 我想得到那里的情节,与他们一起工作,并可能将它们从合成的情节中删除。 这是将绘图添加到 CombinedDomainXYPlot 的示例代码: // axis DateAxis domainAxis = new DateAxis("Date"); // plot container CombinedDomainXYPlot plotCombined = new CombinedDomainXYPlot(domainAxis); // plot 1 XYPlot plot1 = new XYPlot(); plot1.setDomainAxis(domainAxis); plotCombined.add(plot1); // plot 2 XYPlot plot2 = new XYPlot(); plot2.setDomainAxis(domainAxis); plotCombined.add(plot2); 更新 1: 我刚刚试过这段代码,但它没有返回所有的图。 这不可靠。 for (Object sp : plotCombined.getSubplots()) { plotCombined.remove((XYPlot)sp); } 这种去除地块的方法正确吗?

2021-09-21 08:56:22    分类:技术分享    java   jfreechart