jfreechart

How to display values within pie chart sector

一笑奈何 提交于 2019-12-23 08:50:27
问题 I am using JFreeChart to create pie charts. Values are displayed outside pie chart sectors as labels. I want to display the values within the pie sectors. How can I achieve this. Please can any one help me? 回答1: Use setSimpleLabels(), as shown below; org.jfree.chart.demo.PieChartDemo1 is a good starting point. PiePlot plot = (PiePlot) chart.getPlot(); plot.setSimpleLabels(true); 回答2: If you are using createPieChart3D to create Pie chart, following URL will be helpful to you. http://www.java2s

How to draw legend as a table with JFreeCharts?

大城市里の小女人 提交于 2019-12-23 05:25:58
问题 I'm able to plot this chart like this: But I want to plot it like this, which means at the bottom of the chart and as a table (at least look like one). Here is my code: 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;

How to update a chart in JFreeChart?

泄露秘密 提交于 2019-12-23 03:55:09
问题 I have a combinedXYPlot and a drop-down list. I want to update my chart based on user input from drop-down. How to do this? I tried the following code frmJPanel.getContentPane().removeAll(); frmJPanel.setLayout(new BorderLayout()); initChart(option); frmJPanel.repaint(); The changes are reflected only after I minimize/ maximize the window. What is the function that needs to be called? What is the better way to do this ? 回答1: ChartPanel "registers with the chart to receive notification of

How do I get started with JFreeChart?

纵饮孤独 提交于 2019-12-23 03:35:35
问题 I've never used any third party library before. What should I do after I downloaded jfreechart-1.0.14.tar.gz ? I don't know if I'm doing these things right: 1. Put the jcommon-1.0.17.jar and jfreechart-1.0.14.jar at the same directory as my source code. 2. Import needed class in the source code (e.g. import org.jfree.util.Rotation; ) Many articles tell you how to do this in IDEs. But instead of IDEs, I'm writing codes with vim and compile by myself. So, assume I didn't do any thing wrong, how

Why is there no text in JFreeChart?

只愿长相守 提交于 2019-12-23 03:02:00
问题 JFreeChart seems to be working, except for all the text. It just doesn't show up at all, and I've no idea why. I attached a picture of a window with a pie graph that I got from a tutorial site. As you can see, the text isn't visible. (sorry my twitter feed was really long) Thanks Edit: Here is the code that generates the above graph: package analyzer_main; import java.awt.Font; public class FloatChart extends Composite implements Screen { JFreeChart floatChart; public FloatChart(Composite

Java event handling with a delay

倾然丶 夕夏残阳落幕 提交于 2019-12-23 02:55:09
问题 import java.awt.Color; import java.awt.Dimension; import javax.swing.JPanel; import javax.swing.Timer; 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.entity.ChartEntity; import org.jfree.chart.plot.PiePlot; import org.jfree.chart.plot.PiePlot3D; import org.jfree.data.general.DefaultPieDataset; import org.jfree.data.general

第6章 视图和视图解析器

那年仲夏 提交于 2019-12-22 20:02:05
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> Spring MVC如何解析视图 视图和视图解析器 请求处理方法执行完成后,最终返回一个 ModelAndView 对象。对于那些返回 String , View 或 ModeMap 等类型的处理方法,Spring MVC也会在内部将它们装配成一个 ModelAndView 对象,它包含了逻辑名和模型对象的视图。 Spring MVC 借助视图解析器(ViewResolver)得到最终的视图对象(View),最终的视图可以是JSP,也可以是Excel、JFreeChart等各种表现形式的视图。 对于最终究竟采取何种视图对象对模型数据进行渲染,处理器并不关心,处理器工作重点聚焦在生产模型数据的工作上,从而实现MVC的充分解耦。 视图 其作用是渲染模型数据,将模型里的数据以某种形式呈现给客户。 为了实现视图模型和具体实现技术的解耦,Spring在 org.springframework.web.servlet 包中定义了一个高度抽象的 View 接口: 视图对象由视图解析器负责实例化。由于视图是无状态的。所以它们不会有 线程安全 的问题。 常用的视图实现类 视图解析器 SpringMVC为逻辑视图名的解析提供了不同的策略,可以在Spring WEB上下文中配置一种或多种解析策略,并指定他们之间的先后顺序

Setting different y-axis for two series with JFreeChart

╄→гoц情女王★ 提交于 2019-12-22 08:45:50
问题 I am using JFreeChart to plot two series of data (XYSeries) using a linechart. The complicating factor is that one of the data series has y-values that are typically much higher than the y-values of my second data series (let's say that the first series has y-values in the order of magnitude of millions, while the second series has y-values in the order of magnitude of hundreds). The existence of the high values in my first data set cause the range of the plot to be such that the y-values of

How to avoid negative values with JFreeChart fixed auto range

我的梦境 提交于 2019-12-22 01:29:27
问题 I have a JFreeChart line plot that is updated dynamically with one data point for every iteration of my algorithm. Because the number of data points can quickly become very large, I have used the setFixedAutoRange(double) method on the domain axis. This restricts the graph to displaying the n most recent iterations (200 in my case). This works well, except during the first 200 iterations. The problem is that, until there have been 200 iterations, the axis includes negative values (for example

Generate chart with JFreeChart and Apache PDFBOX

China☆狼群 提交于 2019-12-20 10:58:14
问题 I need to generate charts using JFreeChart and then export them to PDF using Apache PDFBOX. I don't want to use iText as it cannot be used in proprietary software. I searched all over Google, but no luck! Has anyone done it? 回答1: Copy the OutputStream from your chosen writeChartAs*() method in ChartUtilities to the InputStream used to create a PDXObjectImage in AddImageToPDF. A typical copyStream() implementation is shown here. Addendum: Alternatively, use piped streams to copy from output to