jfreechart

Adding a static gridline to a JFreeChart time series chart

旧城冷巷雨未停 提交于 2019-11-27 08:04:45
问题 I am trying to implement a timeseries chart with a peculiar requirement in JFreeChart. I can draw the chart, but I don't know how to implement the vertical red line at the last value in the chart. It should always be in the same spot and should always intersect with the last value. I am absolutely out of ideas on how this would be done. I was thinking that it might be possible to implement it as a static gridline, but I don't know how to specify one. Also, the size of the charts will be

Subscript in Axis description

南笙酒味 提交于 2019-11-27 08:02:26
问题 I wanted to know if it is possible to use subscript in axis description. I have the following code XYItemRenderer lineYY = new StandardXYItemRenderer(); lineYY.setSeriesPaint(0, Color.BLUE); lineYY.setSeriesVisibleInLegend(0,false); final NumberAxis yaxY = new NumberAxis("ax [m/s²]"); yaxY.setRange(-11, 11); yaxY.setAutoRangeIncludesZero(false); XYPlot plotYY = new XYPlot(datasetY,null,yaxY, lineYY); plotYY.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT); Is there a way to subscript the x in

How can i display pie chart in jsp page?

核能气质少年 提交于 2019-11-27 07:33:12
问题 <%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <%@ page import="java.awt.*"%> <%@ page import="java.io.*"%> <%@ page import="org.jfree.chart.*"%> <%@ page import="org.jfree.chart.entity.*"%> <%@ page import="org.jfree.data.general.*"%> <% DefaultPieDataset pieDataset = new DefaultPieDataset(); pieDataset.setValue("JavaWorld", new Integer(75)); pieDataset.setValue("Other", new Integer

how to import and plot CSV in Java with timestamp

懵懂的女人 提交于 2019-11-27 07:14:33
问题 Hi Currently I am trying to import the CSV file into the Java to plot the data, basically, I can import successfully but it does not work in my CSV because it has the time format as: HH:mm:ss MM-dd-yy The data is as follow: 2016-05-15 00:00:00 0 2016-05-15 00:00:00 0 2016-05-15 00:00:00 5.44852 2016-05-15 00:00:01 0 2016-05-15 00:00:01 0 2016-05-15 00:00:01 5.26064 the code is as follow: import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java

Why does a Latin-characters-only Java font claim to support Asian characters, even though it does not?

两盒软妹~` 提交于 2019-11-27 06:07:59
问题 When rendering a chart with JFreeChart, I noticed a layout problem when the chart's category labels included Japanese characters. Although the text is rendered with the correct glyphs, the text was positioned in the wrong location, presumably because the font metrics were wrong. The chart was originally configured to use the Source Sans Pro Regular font for that text, which supports only Latin character sets. The obvious solution is to bundle an actual Japanese .TTF font and ask JFreeChart to

Multiple axes on the same data

夙愿已清 提交于 2019-11-27 05:38:28
I'm trying to have two axes on the same data. The data is a couple of DefaultTableXYDatasets . The plot is a XYPlot , and I have two XYLineAndShapeRenderers and one StackedXYAreaRenderer2 . All data is in meters for the y-values, and I want to have one axis displaying it in meters and one axis displaying it in feet. Now this feels like a common thing to do, but I can't decide on the most obvious way to do it. One way that works would be to duplicate the data and have the y-values in feet, then add another NumberAxis and be done with it. But I thought it would be wiser to subclass NumberAxis ,

JFreeChart create tooltip in ChartPanel

南楼画角 提交于 2019-11-27 05:37:42
How can I generate a tooltip on chart mouse over in JFreeChart ? I tried this: chartPanel.setToolTipText("this is the string"); but this does not work. Am I supposed to do something else before? Something like this: chartPanel.createToolTip(). I am calling these methods in the chartMouseMoved event. trashgod Most ChartFactory methods include a boolean tooltips parameter. Just look in the source for your factory of choice to see how to instantiate a default tooltip generator suitable for the designated renderer. You shouldn't need to handle the events yourself. Addendum: As you are using

Choose the series of data that you want to display

只谈情不闲聊 提交于 2019-11-27 05:32:29
I have a plot with multiple series of data: I want to be able to pick the series that I want to display. For example, only the 0° and 20° ones. Is there a simple way to do this by manipulating the chart without using JCheckBox ? I want to be able to do this, for example, by clicking on the legend of the series. trashgod As shown here , JCheckBox is more flexible, but clicking directly on the chart may be more convenient. The example below adds a ChartMouseListener that makes a series invisible when clicking on either an XYItemEntity in the series or its LegendItemEntity . Of course, once a

Jfree chart Find Subplot

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-27 05:31:57
This may sound very basic as a question, but i am stuck in JFreechart use. Let me lay out my problem : I have a CombinedDomainXYPlot to which I add my subplots as and when required. I have used my custom JPopup menu and have included a menu item that is intended to provide user the facility to delete a particular subplot I am assuming that one can find a subplot using findSubplot method of the main plot. I am able to get mouse positions but not able to do anything with PlotRenderingInfo that's required as input. Would appreciate some help. trashgod You can get a List of subplots using

jfreechart customize piechart to show absolute values and percentages

断了今生、忘了曾经 提交于 2019-11-27 05:25:40
How can this compilable minimal code snippet example, which uses JFreeChart as plotting API, adapted in order to show both absoulte values AND percentages ? I couldn't extract this information neither from any code snippet on the internet nor from the JFreechart manual itself. The code snippet produces a pie chart showing only percentages. The absolute values in my case also matter, so i need to display them right under the percentages. Here is the code: (Note it lacks the imports) public class MyMinimalPieChartExample { public static void main(String[] args) { DefaultPieDataset dataset = new