jfreechart

JFreeChart: customizing BoxAndWhisker chart

半腔热情 提交于 2019-12-02 13:43:14
问题 I started using JFreeChart to do some plotting. I would like my chart to look like the image below: I came very close by using BoxAndWhisker chart: However, there are certain things that I would still like to change. Is there a way to remove the boxes so I only have the middle line? And how can I add labels to the bars? Also for some reason the last number of the y axis (bottom right in the image) is cut off. Here is my sample code: import java.awt.Color; import java.awt.Component; import

JfreeChart: dynamic Date time values into XY chart

你说的曾经没有我的故事 提交于 2019-12-02 13:33:45
I am using JfreeChart to create dynamic charts. Currently, am facing a problem to create a Chart to show dynamic Date time values from database. Showing above picture, I want to fix Y axis with months JAN to Dec. Since long back trying , but I could not find any solution. Please give me the solution to fix above issue Catalina Island Use a DateAxis , like they show here , and format the labels for months. DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("MMM")); 来源: https://stackoverflow.com/questions/40280364/jfreechart-dynamic-date-time-values

Jfreechart with scroller

柔情痞子 提交于 2019-12-02 12:53:50
I wanted to add to the chart a scroll bar in order to view big datasets which did not fit on the screen, because to keep all xtick. However, I got the following error message: Exception in thread "main" java.lang.ClassCastException: org.jfree.data.xy.XYSeriesCollection cannot be cast to org.jfree.data.category.CategoryDataset at MySlidingCategoryDatasetDemo3$DemoPanel.<init>(MySlidingCategoryDatasetDemo3.java:86) at MySlidingCategoryDatasetDemo3.createDemoPanel(MySlidingCategoryDatasetDemo3.java:112) at MySlidingCategoryDatasetDemo3.<init>(MySlidingCategoryDatasetDemo3.java:107) at

Pretty pie charts in JFreechart

﹥>﹥吖頭↗ 提交于 2019-12-02 11:51:06
Is it possible to get complex, beautiful colors for pie charts in JFreechart? I mean how can I achieve the colors like the image shown in the link ? Is it possible using the RGB format, or do you need to use a different format? How can we do it. thank you for your help You can specify the color using RGB values for each slice of the pie with PiePlot.setSectionPaint . Here is an example : DefaultPieDataset result = new DefaultPieDataset(); result.setValue("1", 40.); result.setValue("2", 30.); result.setValue("3", 20.); result.setValue("4", 10.); JFreeChart chart = ChartFactory.createPieChart3D(

Jfreechart vertical line is blurry

帅比萌擦擦* 提交于 2019-12-02 11:43:22
问题 I am using JFreechart to generate some plots, and I found the lines in my plot is blurry, but the demo shows that all the lines are thin and without any blurry, I was wondering if there any to generate good quality plot on a panel. 回答1: With more information, I can't explain the rendering and resampling artifact illustrated in your question. Starting from MinMaxCategoryPlotDemo1.java in the demo, I added this line to get the PNG image shown. ChartUtilities.saveChartAsPNG(new File("temp.png"),

Limit JFreeChart TimeSeries to Business Hours

你。 提交于 2019-12-02 11:41:52
问题 Rendering a chart over several days, with a dataset that has 24 hour data, but it's only useful during M-F, 7AM to 5PM. If I setup a time series with the code below, I get a chart that contains all 24 hours, 7 days a week. Makes sense, but not for my use case. Is there a way to define what interval the time series displays? Or do I need to use a different chart type and attempt to fit my data into regular periods? I hope not the latter, while the data I receive is usually in 30 second

Graph Plot in JFreeChart

落花浮王杯 提交于 2019-12-02 11:28:15
On the X axis my data points(20 of them) take values between 0 and 0.2. My X axis should have range from 0 to 1. On the Y axis corresponding values are between 0.8 and 0.86. When I plot this graph using NumberAxis in JFreeChart I get very dense graph especially in the interval X belongs to 0.01 to 0.02.(so I can't see much) Is it meaningful to use log scale for X axis in this case? How should I adjust LogAxis in JFreeChart here? To use LogAxis , just create the axis and set it as the plot's domain: LogAxis xAxis = new LogAxis("X"); plot.setDomainAxis(xAxis); LogAxisDemo1 , shown among the XY

How do I apply a color to a single bar of my single series graph?

帅比萌擦擦* 提交于 2019-12-02 11:25:43
问题 I am new to JFreeChart and I am trying to see what action do what. In my chart I only have one series, and I would like -according to the value- to set a different color for the bar. For example : 0-20 -> RED, 20-80 -> YELLOW, 80-100 -> GREEN CategoryPlot plot = chart.getCategoryPlot(); CategoryDataset dataset = plot.getDataset(0); Number value = dataset.getValue(dataset.getRowKey(0), dataset.getColumnKey(0)); Double val = value.doubleValue(); if (val <= 20.0) { BarRenderer renderer =

I need to create a XYLineChart with values from database (Java(Mysql)

空扰寡人 提交于 2019-12-02 11:21:30
I need to create a XYLineChart with values from database. I see this: public class Test { public static void main(String[] args) { XYSeries series1 = new XYSeries("Lions"); series1.add(20, 10); series1.add(40, 20); series1.add(70, 50); XYSeries series2 = new XYSeries("Rabbits"); series2.add(20, 30); series2.add(40, 40); series2.add(70, 10); XYSeriesCollection xyDataset = new XYSeriesCollection(); xyDataset.addSeries(series1); xyDataset.addSeries(series2); JFreeChart chart = ChartFactory.createXYLineChart("Weight","kg","Numbers",xyDataset,PlotOrientation.VERTICAL,true,false,false); chart

Displaying JFreeChart in a web page using Struts2

霸气de小男生 提交于 2019-12-02 11:19:14
问题 I am using Struts2. I need to display JFreeChart in a web page. Can any body help me on that? Edit: it is getting displayed in binary format. public String execute() throws Exception { System.out.println("Refresh bar Chart"); response.setContentType("image/png"); OutputStream outstream = response.getOutputStream(); try { JFreeChart chart = getChartViewer(); ChartUtilities.writeChartAsPNG(outstream, chart, 500, 300); System.out.println("Created bar Chart"); return SUCCESS; } finally {