jfreechart

Adding date/time to JFreeChart graph

我的未来我决定 提交于 2019-12-29 07:15:33
问题 I currently have a method which queries a database for values, and plots them to a graph. The only problem is, the time variable is a long, and results in my graph looking like this: I want to convert it to a date format and then add it to the graph. How can I do this? Here is my graph code: private Long time; private Long intensity; public XYSeries series = new XYSeries("Sensor"); private XYDataset xyDataset; public JFreeChart chart; xyDataset = new XYSeriesCollection(series); chart =

How to add label values and error bars to a JFreeChart line chart?

眉间皱痕 提交于 2019-12-29 01:51:22
问题 I'm using JFreeChart to create line charts that are exported as images and embedded into automatically generated documents. For instance one simple line chart would look like this: The code I'm using to display the values would be: LineAndShapeRenderer renderer = new LineAndShapeRenderer(true, false); chart.getCategoryPlot().setRenderer(renderer); renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator("{2}", NumberFormat.getNumberInstance())); renderer

Exception with JFreechart in JInternalFrame

杀马特。学长 韩版系。学妹 提交于 2019-12-29 01:46:11
问题 Basically, I want a Java GUI with multiple frames, so I'm using JInternalFrame , but when I add my chart (created from JFreeChart ) to one of the frames, it gave me an exception. Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: javax.swing.plaf.ColorUIResource cannot be cast to java.util.List at javax.swing.plaf.metal.MetalUtils.drawGradient(Unknown Source) at javax.swing.plaf.metal.MetalInternalFrameTitlePane.paintComponent(Unknown Source) at javax.swing.JComponent.paint

Update PieChart in JFreeChart

谁说我不能喝 提交于 2019-12-28 07:10:07
问题 I have created a PieChart using JFreeChart. I for the life of my cant figure out how to update the chart once it has been created. Is the only way to do that to create an entirely new chart? 回答1: As shown here, you can alter a chart after it's been rendered. In this case, update the chart's data model , PieDataset , and the listening view will follow; in this related example a button's Action updates a CategoryDataset . In a MultiplePiePlot , you can update the appearance of the pie chart

JFreeChart simple plot (parabola)

旧巷老猫 提交于 2019-12-28 04:33:24
问题 I wrote a simple parabola plot using JFreeChart. package parabolademo; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import org.jfree.chart.ChartFactory; import org.jfree.chart.ChartMouseEvent; import org.jfree.chart.ChartMouseListener; import org.jfree.chart.ChartPanel; import org.jfree.chart.JFreeChart; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.XYPlot; import org.jfree.data.function.Function2D; import org.jfree.data.function

TimeSeriesChart按月进行统计时坐标对不齐的问题

▼魔方 西西 提交于 2019-12-26 10:41:47
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> JFreeChart里的TimeSeriesChart按月进行显示的时候(也就是TimeSeries里添加的时间是org.jfree.data.time.Month,同时"dateAxis.setDateFormatOverride(new SimpleDateFormat("yyyy-MM"));"),可能会出现X轴的标度与数据点不对应的情况,如下图: 如何解决这个问题? 实际上用"dateAxis.setDateFormatOverride(new SimpleDateFormat("MM-dd"));"来显示的话: 就会发现,数据所在的X轴坐标是每月的一号,如此就有解决方案了,只需要设置一下: dateAxis.setTickUnit(new DateTickUnit(DateTickUnitType.MONTH, 1)); 问题即可解决~ 来源: oschina 链接: https://my.oschina.net/u/54371/blog/10551

【iText5 生成PDF】纯Java代码实现生成PDF(自定义表格、文本水印、单元格样式)

情到浓时终转凉″ 提交于 2019-12-25 22:34:55
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> ​ 工作中遇到需要生成PDF。最终选择了iText。其他也有通过html再生成。感觉不太适合就用了代码实现。 使用iText 5.5.13.1版本。纯Java代码实现 1.自定义表格合并指定行列完成数据填充 2.自定义单元格显示 3.文本内容水平垂直居中显示 4.中文显示 5.图片增加(三角雷达图,基于JFreeChart 可参考另一篇博文) 先看个效果图 Maven项目引入iText <!-- itextpdf --> <dependency> <groupId>com.itextpdf</groupId> <artifactId>itextpdf</artifactId> <version>5.5.13.1</version> </dependency> <!-- itext-asian --> <dependency> <groupId>com.itextpdf</groupId> <artifactId>itext-asian</artifactId> <version>5.2.0</version> </dependency> <!-- itextpdf-tool-xmlworker --> <dependency> <groupId>com.itextpdf.tool</groupId>

How to set Pie chart values in %

自古美人都是妖i 提交于 2019-12-25 18:18:04
问题 I am using JFreechart for creating chart. When i am creating pie chart the values for the pie chart are displaying with integer format.But i need those values in Percentage. My current Output :- Service manager (1) Service Executive (6) Service co-coordinator (3) My Expected output :- Service manager (10%) Service Executive (60%) Service co-coordinator (30%) Sample code:- for(int i=0;i<dataset_bydeglist.size();i+=2){ dataset.setValue(dataset_bydeglist.get(i).toString()+" ("+(Integer)dataset

How to add data into a JFree XY chart every 5 seconds?

一世执手 提交于 2019-12-25 09:46:04
问题 I have access to a database that returns the temperature of a location and time of that location every 5 seconds. I have an idea of plotting the time on the x-axis. And probably by using the java swing timer I would be able to add data into the graph every 5 seconds. However, I do not know how to implement that because I thought of adding a timer in createDataset( ) but since it returns a dataset, I won't be able to achieve it. Any idea how I would be able to add data into the graph every 5

Initialize JFreeChart range axis values

本秂侑毒 提交于 2019-12-25 08:29:09
问题 I am trying to load dataset during initialization of the JFreeChart. But every time I tried to create a dataset with higher "number of item per series", the more data (all data) displayed visible in the chart (the bigger the dataset, the smaller the graph). But actually what I wanted is to have the fixed range of dataset values displayed on the chart while the rest is still hidden. Just the same way the data would normally be displayed in the actual trading platform, let's say Metatrader (MT4