jfreechart

JFreeChart axis label in Hours

霸气de小男生 提交于 2019-12-11 05:55:32
问题 I have data e.g. (1,3600), (2,4400), ... (33,15000) Where in (1,3000) -> 1 is a number -> 3600 is seconds If put in chart, the axis would show the "second" as number. I have set a code to show axis label in 1 hour interval. // Create an NumberAxis NumberAxis xAxis = new NumberAxis(); xAxis.setTickUnit(new NumberTickUnit(3600)); // Assign it to the chart xyPlot.setDomainAxis(xAxis); So now the axis labels are: 0 ... 3600 ... 7200 ... 10.800 ... How to make the axis labels show in hours? (0 ...

How can I get a values from the line chart in java?

风格不统一 提交于 2019-12-11 05:49:00
问题 public class createLineChartForSandSoil { static JFreeChart chart; public static XYSeries series; public static void createLineChartForSandSoil(Document document) throws DocumentException, BadElementException, IOException { Paragraph wordDegreeOfHeterogeneity = new Paragraph("Визначаємо ступінь неоднорідності піску:", smallFont); document.add(wordDegreeOfHeterogeneity); ChartPanel chartPanel = createChartPanel(); int width = 450; int height = 350; XYPlot plot = chart.getXYPlot();

Check if point belongs to the plot

孤者浪人 提交于 2019-12-11 05:42:51
问题 I'm using JFreeChart to draw XYPlot. What I'm currently trying to do: User clicks on the plot and the app gives him back the coordinates of the chosen point; I think that I've got it right. Here is some code: public void chartMouseClicked(ChartMouseEvent arg0) { Rectangle2D plotArea = chPanel.getScreenDataArea(); XYPlot plot = (XYPlot) chart.getPlot(); double chartX = plot.getDomainAxis().java2DToValue(arg0.getTrigger().getPoint().getX(), plotArea, plot.getDomainAxisEdge()); double chartY =

Using values from a for loop in a function outside of it

两盒软妹~` 提交于 2019-12-11 05:30:08
问题 I need to take values that I find from inside a for loop to use in a function that isn't inside the loop, and I can't figure out how to do this. What I am hoping to accomplish is to extract values from a key in a hashmap to then plot in a JTable only if that row is selected (using a ListSelectionListener ). This way, I can avoid graphing a hundred tables which would save a lot of time. Also I am using DefaultTableModel . This is my for loop: tableMaker(model); for(Map.Entry<String

Creating an area graph below a XYDifference(Renderer) graph

亡梦爱人 提交于 2019-12-11 05:28:50
问题 I have been trying for the last week to find a way to make JFreeChart display something similar to the image below. Basically you are looking at three series (upper, middle, lower) with a fill inbetween. And underneath there is a (light green) fill color, or an area chart as some would perhaps call it - no meaning, just for looks. The only thing really missing from what I have come up with is the last part: the fill underneath / area chart: I even tried to subclass XYDifferenceRenderer and

Java JFreeChart with dynamic data

大兔子大兔子 提交于 2019-12-11 05:21:32
问题 I am facing some problems with JFreeChart with Java. I am retriving data from remote database to make them display in a Panel from my application. The problem: when I get the data, it does not display directly on the panel. I have to minimize and maximize the form to make the data being loaded. I need this data to be refreshing every minute. I was thinking about a Timer but I don't really know how to integrate it. Here is part of the code: import java.io.BufferedReader; import java.net.Socket

JFreechart - getting the Min and Max of the current displayed dataset for auto-adjusting the y-axis

回眸只為那壹抹淺笑 提交于 2019-12-11 05:03:48
问题 I have problem with the movement navigation of the chart I created using JFreeChart. From the example as included in the library source code, when we do a zoom, or move on the chart, the graph can be moved freely. But what I am currently trying to do is to have similar behavior like the actual trading platform, let's say Metatrader (MT4). When the chart is move left/right, the min/max of the dataset is changing, so the y-axis of the chart is updated accoringly. Basically I have idea on how to

JFreeChart scatter chart with varying point colours and sizes

三世轮回 提交于 2019-12-11 04:48:01
问题 I want to plot some data on a scatter plot: x against y where each point in the series has a point size and a color . Is this possible? say for example int[] x = {1,2,3,4,5}; int[] y = {2,4,6,8,10}; int[] pointSize = {10,20,40,15,25}; //pixels Color[] colors = {rgb1,rgb2,rgb3,rgb4,rgb5}; I'm quite new to JFree so if you could post some example code that would be perfect :D 回答1: You can override XYShapeRenderer#XYShapeRenderer and XYShapeRenderer#getItemShape final Shape[] pointSize =

JFreeChart StackedBarChart

∥☆過路亽.° 提交于 2019-12-11 04:47:00
问题 I am drawing a stackedbarchart. Now for the x-axis i have labels which are auto generated based on CategoryDataset. I want to show these labels with intervals because otherwise they are overlapped in case i have large number of values for the dataset. But I am not able to understand how to achieve this. For example i have this following code. CategoryDataset dataset = getDataset(); final JFreeChart chart = ChartFactory.createStackedBarChart( graphTitle, xAxisTitle, yAxisTitle, dataset,

XYPlot without vertical axis and horizontal line grid?

帅比萌擦擦* 提交于 2019-12-11 04:36:58
问题 Can I draw only vertical data axis (without axis line( in XYPlot and only horizontal line in grid lines (I know the hack - draw them by white color, that is coincident with background color, may be, there is more pure way) ? 回答1: You can specify currency formatting on the range axis using setNumberFormatOverride() , as shown here. NumberFormat currency = NumberFormat.getCurrencyInstance(); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setNumberFormatOverride(currency);