jfreechart

JFreeChart format Y-axis to show values in Power

筅森魡賤 提交于 2019-11-29 17:14:27
How to format y-axis to show values as 5*10^5, 1*10^6, 2*10^6... instead of 500,000,1,000,000, 2,000,000... and which are divisible by 5 or 10? trashgod A LogAxis with the default tick units seems to work. This related example uses integer tick units. import java.awt.Dimension; import java.awt.EventQueue; import javax.swing.JFrame; import org.jfree.chart.ChartPanel; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.LogAxis; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; import org.jfree.data.xy

Change the unit of x axis in JFreeChart Gantt chart

て烟熏妆下的殇ゞ 提交于 2019-11-29 17:08:40
I'm a beginner in JFreeChart . I want to change the x axis values of this chart to milliseconds, with 5 ms intervals. I've tried axis.setTickUnit(new DateTickUnit(DateTickUnitType.MILLISECOND, 5)); but I keep having a compilation error. I found somme suggestions in the net, but nothing worked for me. Also, is there any way to set a maximum value for the x axis, like 300 ms. import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import org.jfree.chart.ChartFactory; import org.jfree.chart.ChartPanel; import org.jfree.chart.JFreeChart;

Adding ChartPanel to CardLayout

爷,独闯天下 提交于 2019-11-29 17:02:49
I have a pretty basic GUI organized with a GridBagLayout . The most complex portion is the bottom where West is populated with ScrollPane and the right is a panel with a CardLayout that has multiple ChartPanels so I can switch between a few graphs. My issue comes when I start the program. The resizing issue goes away after I resize the frame in any direction. I have confirmed the chartpanel is the issue because not adding this to the CardLayout panel fixes it. I create a blank ChartPanel and populate it later after some action is taken but this is what I've done: public class Tester { public

I have a bar chart which I want to update and I tried the revalidate and repaint methods but with no success

老子叫甜甜 提交于 2019-11-29 16:57:38
class GraphGenerator1 extends JPanel { ChartPanel chartPanel, sbc; void generator(int t, int Value1, int Value2) { if (t == 1) { DefaultCategoryDataset gData = new DefaultCategoryDataset(); gData.setValue(Value1, "What you saved", ""); gData.setValue(Value2, "What you paid", ""); JFreeChart chart = ChartFactory.createBarChart("", "", "", gData, PlotOrientation.VERTICAL, false, false, false); chart.setBackgroundPaint(Color.WHITE); BarRenderer br = (BarRenderer) chart.getCategoryPlot() .getRenderer(); br.setBarPainter(new StandardBarPainter()); br.setSeriesPaint(0, Color.decode("#97d95c")); br

Combining XYPlot and TimeSeries elements in JFreeChart

笑着哭i 提交于 2019-11-29 16:55:19
I am interested in making a sort of hybrid between an XY Chart and Time Series in JFreeChart, where the x-axis is some SimpleDateFormat element (say, "yyyy-MM-dd HH:mm:ss.SSS"), with a respective start and end in the domain that is in this format, and the y-axis are levels, say LOW, MEDIUM, and HIGH. For each specific date/time, I would like to plot one of these three levels. How might I go about doing this? You'll need to combine several elements to get the desired effect: Start with ChartFactory.createXYBarChart() , as shown below and here . Use a DateAxis for the domain axis, as shown here

StackedBarChart row key is not added to DefaultCategoryDataSet

旧城冷巷雨未停 提交于 2019-11-29 16:50:35
I have two entity Classes: A and B. A has B entities, and I have a Map defined in the following format: Map<A, List<B> . I want to add all map data to DefaultCategoryDataset with following code. For example, if have 5 A and each A has 4 B, I want to have 25 row keys. (A entity number * (A entityNumber + B entity number in each A). A Row key that stores A class must be same width; all other rows that store B entities must have same width. To succeed in this, I am giving the same values while adding A row keys((double) 1 / (1 + bResultList .size()), and giving smaller values while adding A row

JFreeChart using Large Numbers as Values

醉酒当歌 提交于 2019-11-29 16:32:36
I am currently working on a project using JFreeChart. I got everything working except when I start using large numbers, it goes all funny. DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addValue(1000, "Cars", "2015"); dataset.addValue(5000, "Bikes", "2015"); return dataset; Output from above works perfect, but when I do this: DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addValue(999999999, "Cars", "2015"); dataset.addValue(999999999, "Bikes", "2015"); return dataset; The 999999999 is converted to something like 1E7, 2E7, etc, etc. How do I

how can I implement a XYLine jfreechart in java

 ̄綄美尐妖づ 提交于 2019-11-29 16:25:48
I am new to jfreechart.I want to display a chart based on values from my data base table Table is dns_time with fileds dns_lookup_time,update_time. I want update_time on x-axis and dns_lookup_time on y-axis.And the curve should be displayed according to the values from the database.I am using hibernate and postgresql.Can any one help me how to achieve this.Thank you. You might look at JDBCXYDataset , which can detect a time series based on metadata. As noted in the API, "The first column will be the x-axis and remaining columns y-axis values." Click on the class name to see the corresponding

How to determine min and max value for ItemMargin property in StackedBarChart using jFreeChart

时光怂恿深爱的人放手 提交于 2019-11-29 16:20:14
I am using jFreeChart api to make one application such that on movement of slider the gap width in between the two bars gets increased or decreased according to the value of the slider. But I found with different charts and different data item margin property get varied. To demonstrate the problem I am attaching the following code:- import java.awt.BorderLayout; import java.awt.Container; import java.awt.Dimension; import javax.swing.BorderFactory; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JSlider; import javax.swing.event.ChangeEvent; import javax.swing.event

Update normal distribution graph using JTextField in JFreeChart

六眼飞鱼酱① 提交于 2019-11-29 16:18:45
I have a class that extends JPanel for JFreeChart . Inside of setMean() , I tried updating values of dataset or just the Function2D , but nothing changes on the graph even with repaint() . public class JFreeChartPanel extends JPanel { Function2D normal = new NormalDistributionFunction2D(0.0, 3.0); XYDataset dataset = DatasetUtilities.sampleFunction2D(normal, -5.0, 5.0, 100, "Normal"); double mean = 0.0, std = 1.0; public double getMean() { return mean; } public void setMean(double mean) { this.mean = mean; normal = new NormalDistributionFunction2D(mean,std); dataset = DatasetUtilities