jfreechart

Listening for zoom reset event in JFreeChart

北城以北 提交于 2019-12-02 01:41:56
How can I listen to JFreeChart's zoom reset event? I did it using this: ChartPanel DCP=new ChartPanel(DailyChart){ @Override public void restoreAutoBounds(){ super.restoreAutoDomainBounds(); super.restoreAutoRangeBounds(); XYPlot plot=(XYPlot)getChart().getPlot(); Calendar Cal=Calendar.getInstance(); String dayName=Cal.getDisplayName(Calendar.DAY_OF_WEEK,Calendar.SHORT,new Locale("en", "us")).toLowerCase(); String tmp[]=((String)Configurations.getWeeklyWorkingSchedule().get(dayName).get("start")).split(":"); Cal.set(Calendar.HOUR_OF_DAY, Integer.parseInt(tmp[0])); Cal.set(Calendar.MINUTE,

Plotting BarGraph according to month days dynamically using java

梦想的初衷 提交于 2019-12-02 01:38:55
i've created a BarChart using jfreechart in java. The bar is plotted according to the days in a month. for example this month March contains 31 days, so there will be 31 bars . The problem is that when i click the next button the month changes to April which contains 30 days, ie 30 bars. How can we change the BarChart according to the days in a month on button click. Can anyone please tell me how to do that. trashgod You need to update your dataset with each change. I've added an updateDataset() method and called it in several key places. private void updateDataset() { dataset.clear(); for

How to display only “last 24 hours” from a “last 72 hours” JFreeChart TimeSeries

て烟熏妆下的殇ゞ 提交于 2019-12-02 01:38:35
I wrote these 2 lines of code to create a chart using an XYDataset : final XYDataset dataset = new TimeSeriesCollection(myInfo.getSeries()); JFreeChart timechart = ChartFactory.createTimeSeriesChart(myInfo.getName() + " CPU (last 72h)", "", "CPU %", dataset, false, false, false); These lines created this nice "last 72h" chart: This is how I added the information to build this chart (this piece of code can run multiple times): SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd H:mm:ss"); Date date = simpleDateFormat.parse(dateAsStringToParse); Second second = new Second(date);

JFreeChart XYSplineRenderer Demo

别来无恙 提交于 2019-12-02 01:37:17
Would someone please point me to a working example JFreeChart's XYSplineRenderer? Although I've never seen the example, XYSplineRendererDemo1.java is one that may be found among the demos . All the demos are included with the developer guide † , which I recommend highly. If you want to assay an example of your own, note that XYSplineRenderer is an XYLineAndShapeRenderer , so start with a matching ChartFactory . It looks like they all take an XYDataset . † Disclaimer: Not affiliated with Object Refinery Limited; just a satisfied customer and very minor contributor. 来源: https://stackoverflow.com

JFreeChart tick label cut off

五迷三道 提交于 2019-12-02 01:32:12
问题 When rendering a chart using JFreeChart, if there is a tick label near to the end of the horizontal axis the label is partially cut off at the border of the image, eg: | | +----------+------------------+- 01 Jun 11 01 Jul <--- missing year Is there any way that I can prevent this? It is possible to add some kind of margin or similar? Thanks 回答1: Assuming a DateAxis, the parent ValueAxis method setUpperMargin() may suffice. 来源: https://stackoverflow.com/questions/7851540/jfreechart-tick-label

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

给你一囗甜甜゛ 提交于 2019-12-02 01:21:56
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(FinalArayOfOptpar[s][i + 3])), Math.abs(FinalArayOfOptpar[s][i + 2] * 2.0), Math.abs(FinalArayOfOptpar[s][i + 3] * 2

JFreeChart Bar Chart Production

浪尽此生 提交于 2019-12-02 01:15:56
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.createBarChart3D("Summary", "Name", "Scores", barChartDataset, PlotOrientation.VERTICAL, false, true, false); The data

How can I include a JFreeChart servlet image in a JSP

大兔子大兔子 提交于 2019-12-02 01:07:29
I have seen several examples of using a Servlet to dynamically generate a chart using JFreeChart, and subsequently including that image in a JSP using an img tag. For example: <img src="/MyChartServlet" width="400" height="300" border="0" alt="" /> My servlet which generates the image using JFreeChart works great, and I can see the image if I call it directly in the browser as in: http:/myurl/MyChartServlet?id=274 The problem is that my JSP does not display the image. In fact, the JSP is not even invoking the servlet. I know this because I do not see the debug entries in the log that appear

JasperReports: How to mask or filter the labels at the chart's axis

ぐ巨炮叔叔 提交于 2019-12-02 01:00:29
问题 I´m using a simple area chart based on a simple Dataset like this: DateTime(sql.timestamp) |Value(Integer) 2012-02-17 00:02:02 |100 2012-02-17 00:02:08 |110 2012-02-17 00:02:20 |90 2012-02-17 00:02:35 |10 2012-02-17 00:02:40 |130 2012-02-17 00:04:22 |14 2012-02-17 00:04:33 |45 2012-02-17 00:05:02 |60 ... DateTime is used by Category Axis, Value is used by Range Axis. In the Dataset are ~1000 Records In the Labels of the Category Axis will every DateTime Value be shown. But that is with 1000

Customize bar colors in XYJfree chart

点点圈 提交于 2019-12-01 23:56:39
问题 how to paint different bars in different colors, I tried to use renderer, here is my sample code: public IntervalXYDataset createDataset() throws InterruptedException { parseFile(); final XYSeries series = new XYSeries("Analysis"); int i=0; while(parsedArray[i]!=0) { series.add(xaxisArray[i], yaxisArray[i]); i++; } final XYSeriesCollection dataset = new XYSeriesCollection(series); dataset.setIntervalWidth(0.15);//set width here return dataset; } and this is how I am drawing the graph: public