jfreechart

JFreeChart change data in an existing bar chart

江枫思渺然 提交于 2019-11-27 09:50:19
I want to change a bar chart data in a loop and I have no idea how to do that. My code: DefaultCategoryDataset barChartData = new DefaultCategoryDataset(); barChartData.setValue(0, "Values","1"); barChartData.setValue(0, "Values","2"); barChartData.setValue(0, "Values","3"); JFreeChart barChart = ChartFactory.createBarChart("Proxi", "Sensors", "Value", barChartData, PlotOrientation.VERTICAL, false, true, false); CategoryPlot barchrt = barChart.getCategoryPlot(); barchrt.setRangeGridlinePaint(Color.ORANGE); ChartPanel barPanel = new ChartPanel(barChart); barPanel.setBounds(0, 0, 731, 456);

JFreeChart: X Axis contains time stamps

徘徊边缘 提交于 2019-11-27 09:48:32
I need to change this code in such a way that X Axis contains time stamps in the format "H:M", e.g. 10:00. private static XYDataset createCategoryDataset(Map<Integer,List<Task>> staffLevels) { String series1 = "Task demand"; DefaultXYDataset dataset = new DefaultXYDataset(); double[][] data = new double[2][staffLevels.size()]; int min_per_hour = 60; for (int i=0; i<staffLevels.size(); i++) { int seconds = i*Parameters.MIN_TIME_UNIT*60; int hours = (i*Parameters.MIN_TIME_UNIT) / min_per_hour; int minutes = (seconds / min_per_hour) % min_per_hour; data[0][i] = hours + ":" + minutes; data[1][i] =

Add values to a specified series in a DynamicTimeSeriesCollection

心不动则不痛 提交于 2019-11-27 09:47:11
The program will receive data every second and draw them on time Series chart. However, once I create two series, I cannot add new value to it. It displays a straight line only. How do I append data to a specified series? I.e. YYY . Based on this example , here's what I'm doing: ... // Data set. final DynamicTimeSeriesCollection dataset = new DynamicTimeSeriesCollection( 2, COUNT, new Second() ); dataset.setTimeBase( new Second( 0, 0, 0, 1, 1, 2011 ) ); dataset.addSeries( gaussianData(), 0, "XXX" ); dataset.addSeries( gaussianData(), 1, "YYY" ); // Chart. JFreeChart chart = createChart(

How to use SwingWorker?

喜你入骨 提交于 2019-11-27 09:46:55
Friends, i am developing a java application. Thats for performance monitoring. on that i am getting values in one class and drawing a graph in another class. i want to use swingworker to perform those two class alternatively. ResultSet rs; Connection conn = null; conn = (Connection)getMySqlConnection(); Statement st = conn.createStatement(); rs = st.executeQuery("SHOW GLOBAL STATUS"); while(rs.next()) { Map_MySql.put(rs.getString(1), rs.getString(2)); } conn.close(); Above class for collecting server status and store it in hash map. this class called as "MySQLClass". System.out.println("Graph

add scrollbar to JFreeChart 3DBarChart

大城市里の小女人 提交于 2019-11-27 08:59:39
问题 Can I add a scroll bar to the JFreeChart that allows me horizontally move the bar ? JFreeChart chart = ChartFactory.createBarChart3D( title, "X", "Y", dataset, PlotOrientation.VERTICAL, true, false, false ); Because the dataset could be very long that there's not enough width to show the result... Can I use JSlide on it? or other methods? If possible, please show me some sample code. Thank you! 回答1: .Yes you can, if you have access to the JFreeChart demo code just modify

Change the Lines Style and colour of a JFreeChart

一世执手 提交于 2019-11-27 08:44:08
问题 I have 3 series: XYSeries s1 = new XYSeries("one"); s1.add(1,0); s1.add(2,1); XYSeries s2 = new XYSeries("two"); s1.add(3,0); s1.add(4,1); XYSeries s3 = new XYSeries("three"); s1.add(5,0); s1.add(6,1); Which i plot as a XYLineChart: XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(s1); dataset.addSeries(s2); dataset.addSeries(s3); JFreeChart chart = ChartFactory.createXYLineChart("title", "x", "y", dataset, PlotOrientation.VERTICAL, false, false, false); and add to a

Drawing Line chart in Java [closed]

走远了吗. 提交于 2019-11-27 08:40:19
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 4 years ago . I want to draw a graph on each point of which there will be a button. When I will click the button, it will do something. Here's a link; I want my graph to look like this. Can anybody suggest me how to do it? 回答1: Using JFreeChart, add a ChartMouseListener to your ChartPanel , as

How to plot color map in java?

*爱你&永不变心* 提交于 2019-11-27 08:27:16
问题 I have a dataset with 3 column, x, y, and value at (x,y). I want to plot map similar to bellow map. How to plot this type of figure in jfreechart or any library available for this kind of plot? 回答1: An XYBlockRenderer looks like a good match. You can use Color.getHSBColor(), like they show here, to make the PaintScale. image 回答2: Starting with this example and using this idea, you can use a SpectrumPaintScale to get a palette of colors as shown below. import java.awt.Color; import java.awt

JfreeChart Error in Linux/Unix environment

大兔子大兔子 提交于 2019-11-27 08:13:52
问题 I am getting this error in the Linux environment while displaying 3D pie charts on the web browser. It works perfectly fine in the windows environment. java.lang.NoClassDefFoundError: Could not initialize class org.jfree.chart.JFreeChart at org.jfree.chart.ChartFactory.createPieChart3D(ChartFactory.java:763) I have set the system property System.setProperty("java.awt.headless", "true"); in my java code. On checking the property, it has been set to true successfully. But still i am getting the

Code difference between jfreechart XYLineAndShaperanderer, XYDotRenderer and XYSplineRenderer?

我的未来我决定 提交于 2019-11-27 08:13:03
问题 I'm trying to create simple XYSplineRenderer, but code only work if I write XYDotRenderer a = new XYDotRenderer(); or XYLineAndShapeRenderer a = new XYLineAndShapeRenderer(); Can sameone tell what i do wrong? I'm just beginner in programming. Here is my code: package kubas; import org.jfree.chart.*; import org.jfree.chart.axis.*; import org.jfree.chart.plot.*; import org.jfree.chart.renderer.xy.XYSplineRenderer; import org.jfree.data.xy.*; import org.jfree.ui.ApplicationFrame; public class