jfreechart

Shift the origin from (0,0) to (0,50) in JFreeChart

こ雲淡風輕ζ 提交于 2019-12-31 03:28:09
问题 As shown in image the graph is from line y=0, here i want to plot a graph from y=50, how can i specify this in JFreeChart ? Here is Some Code: public class Profile { double last=0; public void generateProfile(int[] pointValue,double[] distance){ ArrayList pv=new ArrayList(); ArrayList dist=new ArrayList(); pv.add(pointValue); dist.add(distance); for(int i=0;i<pv.size();i++){ System.out.print(pointValue[i]); } for(int i=0;i<dist.size();i++){ System.out.print(distance[i]); } XYSeries series =

JFreeChart Bar Chart Production

久未见 提交于 2019-12-31 03:19:07
问题 I'm trying to create a bar chart that generates a dataset from within a for loop. String scores = scoreText.getText(); String[] data = scores.split(","); DefaultCategoryDataset barChartDataset = null; for (int l = 0; l < data.length; l++) { barChartDataset = new DefaultCategoryDataset(); // barChartDataset.setValue(new Double(data[l]), "Scores", stu); barChartDataset.addValue(new Double(data[l]), "Scores", stu); System.out.println(data[l]); } JFreeChart barChart = ChartFactory

How to change the color of multiple ellipses using a loop (JFreeChart)

蓝咒 提交于 2019-12-31 02:51:09
问题 I have drawn multiple ellipses using a loop as shown below, and the results are perfect using one color for all the ellipses, but my target is to color each ellipse with different color. Is there any way to let the property Color.BLUE change its value in each iteration? for (int i = 0; i < 3; i++) { XYShapeAnnotation unitCircle1 = new XYShapeAnnotation( new Ellipse2D.Double((FinalArayOfOptpar[s][i] - Math.abs(FinalArayOfOptpar[s][i + 2])), (FinalArayOfOptpar[s][i + 1] - Math.abs

modify dataset of an already built chart with Java and JFreeChart

纵然是瞬间 提交于 2019-12-30 18:56:14
问题 Let's say I've generated a chart with the following code: private ChartPanel createChart(){ XYSeries series1 = new XYSeries("First"); XYSeries series2 = new XYSeries("Second"); XYSeries series3 = new XYSeries("Third"); series1.add(0.0, 5.5); series1.add(5, 10); series1.add(10, 5.5); series2.add(0.0, 2); series2.add(5, 2); series2.add(10, 7); series3.add(0.0, 10); series3.add(5, 5); series3.add(10, 6); XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series1); dataset

JFreeChart - customizing RingChart

半城伤御伤魂 提交于 2019-12-30 13:27:24
问题 I want to make two ring charts that look like the following: But the RingPlot doesn't seem very customizable. The best I could come up with is this: Any chance of doing what I want with JFreeChart? 回答1: JFreeChart can do most things, this should get you started (I'll probably incorporate the center text feature into the upcoming 1.0.18 release so that the subclassing isn't necessary): package org.jfree.chart.demo; import java.awt.Color; import java.awt.Dimension; import java.awt.Font; import

Multiple OHLC datasets in one image

烈酒焚心 提交于 2019-12-30 11:52:22
问题 How can I chart multiple datasets in one image using JFreeChart ? Essentially I want to chart a stock's price and it's moving average line in one image. I've tried getting the XYPlot and adding the second dataset, but it does not work. DefaultOHLCDataset dataset = new DefaultOHLCDataset(symbol, items); DefaultOHLCDataset dataset2 = new DefaultOHLCDataset(symbol, evs); JFreeChart chart2 = ChartFactory.createHighLowChart( symbol, "minutes", "prices", dataset, true); chart2.getXYPlot()

Multiple OHLC datasets in one image

て烟熏妆下的殇ゞ 提交于 2019-12-30 11:51:32
问题 How can I chart multiple datasets in one image using JFreeChart ? Essentially I want to chart a stock's price and it's moving average line in one image. I've tried getting the XYPlot and adding the second dataset, but it does not work. DefaultOHLCDataset dataset = new DefaultOHLCDataset(symbol, items); DefaultOHLCDataset dataset2 = new DefaultOHLCDataset(symbol, evs); JFreeChart chart2 = ChartFactory.createHighLowChart( symbol, "minutes", "prices", dataset, true); chart2.getXYPlot()

JFreeChart - XYBarChart Show Separate Bars for Each Series

自作多情 提交于 2019-12-30 10:15:24
问题 I'm creating a XYBarChart using JFreeChart and adding multiple series to it. Currently for a given x-value and different Y-values from the series, all of them are getting stacked on top of each other. Would be possible to show each series as a different bar for a given x-value? Edit : I'm posting the relevant section of my code that is used to create the chart for your reference. Note that I cannot use CategoryDataset because this does not provide zooming capabilities on the Domain Axis. This

Making a Scatter Plot Using 2d array and JfreeChart

谁都会走 提交于 2019-12-29 08:53:04
问题 This is my First Month with Java, so I apologize for my stupid question in advance. I'm trying to make a simple program using Jfreechart. I want to display my 2D array on the scatter plot. here is the code: package myappthatusesjfreechart; import org.jfree.chart.ChartFactory; import org.jfree.chart.ChartFrame; import org.jfree.chart.JFreeChart; import org.jfree.chart.plot.PlotOrientation; import org.jfree.data.general.DefaultPieDataset; public class MyAppThatUsesJFreeChart { public static

How to wrap category labels in JfreeChart

此生再无相见时 提交于 2019-12-29 08:42:10
问题 I have Stacked Bar Chart created using JFreeChart. The labels of the category are quite big and they overlap with the label of the next Bar. I would like to wrap it to the next line. I did some searching and found that i have to use the below code. setMaximumCategoryLabelLines(2) in the CategoryAxis and still it doesn't wrap to the next line. Please suggest solutions. 回答1: Altering the BarChartDemo1 code as shown and using long category names, I see the chart below. It seems to work with