jfreechart

how to listen for clicks in Java (JFreeChart) using events?

隐身守侯 提交于 2019-11-26 06:09:13
问题 This is the code I\'m currently using: @Override public void mouseExited(MouseEvent e) { System.out.println(\"detectado\"); } 回答1: You can use addChartMouseListener() to add a ChartMouseListener to your ChartPanel . For example, in BarChartDemo1, add the following: chartPanel.addChartMouseListener(new ChartMouseListener() { public void chartMouseClicked(ChartMouseEvent e) { System.out.println(e.getEntity()); } public void chartMouseMoved(ChartMouseEvent e) {} }); 回答2: To listen for clicks,

Changing shape of single point in JFreeChart XYPLot

孤街醉人 提交于 2019-11-26 06:07:58
问题 I am using JFreeChart XYPLot for plotting a XYData set with different labels . I have created different XYSeries objects for different labels so that I can have different colors for different labels . Now I need to require the change the shapes of specific points(test data) in each XYDataSeries as below . In the above plotting , there are two different XYSeries with blue and red color . Out of these two I need to change the shapes of some points(test data) to X instead of circle . Is it

Changing mercury color in thermometer in JFreeChart

我怕爱的太早我们不能终老 提交于 2019-11-26 05:28:03
I have created a thermometer chart with JFreeChart, but I want to change the mercury color in thermometer. How can I do this? Here is my code so far; please explain where to change this code: final DefaultValueDataset dataset = new DefaultValueDataset(new Double(10)); // create the chart... final ThermometerPlot plot = new ThermometerPlot(dataset); final JFreeChart chart = new JFreeChart("Thermometer Demo 2", // chart title JFreeChart.DEFAULT_TITLE_FONT, plot, // plot false); // include legend chart.setBackgroundPaint(new Color(241,250,224)); plot.setMercuryPaint(); final NumberAxis rangeAxis

Adding points to XYSeries dynamically with JfreeChart

心已入冬 提交于 2019-11-26 04:55:52
问题 I am facing problems in adding points to XYSeries. I have two classes. One is Sample (it has a main method) and the other class is JfreeChart (it has JfreeChart Code). In my Sample class I have a 2D array sample[row][2] which has initially 10 rows, and then I need to call the JfreeChart class and add them to XYSeries and display a scatter plot. I managed to do this, but the next time I call the Jfreechart class my Array has 25 rows. I need to add the values to XYSeries and plot them on a

JFreechart candlestick chart weird behaviour on drag

痴心易碎 提交于 2019-11-26 04:27:54
问题 This is a follow up question from this question. What happens is the following: When I launch the graph and I drag the graph around, something weird happens: at a certain interval, it seems every 7 periods, the candlesticks get smaller and smaller untill they are only a stripe. Then when I drag further, they become thicker again until they are normal size again. This seems to happen for every 7 periods. An example of this phenomenon is displayed on to the following 3 pictures: The following

Adding ChartPanel to JTabbedPane using JPanel

核能气质少年 提交于 2019-11-26 04:27:47
问题 I want to add JFreeChart to JPanel and then add JPanel to JTabbedPane . I managed to display JFreeChart on JFrame , but I want to add JFreeChart as a 4th tab of JTabbedPane . Code to display Chart: public class Chart extends javax.swing.JPanel { private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { JPanel jPanel1 = new JPanel(); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.setValue(60, \"Marks\", \"Student 1\"); dataset.setValue(40, \"Marks\", \

JFreechart series tool tip above shape annotation

家住魔仙堡 提交于 2019-11-26 03:44:46
问题 I have an XYPlot on which are series and a couple of dynamically added shape annotations with no fill (hence each of the series points are visible). Is it possible to display the series tool tips(that show the coordinate of the series point over which the mouse pointer is currently pointing to) over the annotations? Or how can I re-arrange the elements in order to make the tooltip visible. 回答1: I suspect you are adding the shape annotations to the plot, where they are drawn last. Instead, add

JFreeChart line chart with text at each point

与世无争的帅哥 提交于 2019-11-26 03:44:41
问题 I would like put text over each point I plotted in a line chart. This is what I can do: And this is what I need (names of point are in green): 回答1: The StandardXYItemLabelGenerator should work; there's an example here. Addendum: The labels you can see in the picture are in a separate string array. Such labels may be incorporated in the XYDataset , as shown in LabeledXYDataset below. Because none of the features of StandardXYItemLabelGenerator are used, a custom implementation of

Changing the shapes of points in scatter plot

南笙酒味 提交于 2019-11-26 03:28:42
问题 I have thousands of points to Plot on a JFreeChart scatter plot. The problem right now is that my program is plotting points with \"squares\", but I need some help on how to change the Shape of points from \"squares\" to \"dots/circles\". Any help would be appreciated. // * I am using ShapeUtilities,but its not changing the shape of point to \"DaigonalCross\" when I am Using for XYItemRenderer/XYDotRenderer--Any corrections please if anythng wrong in the code .. * /// import java.awt.Color;

Displaying a histogram of image data

大憨熊 提交于 2019-11-26 02:25:08
问题 I sometimes need to display a representation of image data in the form of a histogram. I\'m especially interested in ways to access the image data. I\'m familiar with JFreeChart , which includes histogram support, but I\'d consider other approaches. 回答1: The example below uses several techniques to create an RGB histogram of an arbitrary image: The Raster method getSamples() extracts the values of each color band from the BufferedImage . The HistogramDataset method addSeries() adds each band