jfreechart

How to remove space betwwen bars on a category in iReport?

核能气质少年 提交于 2019-12-10 11:58:20
问题 I have a graph with two bars on each category value. How can we remove sapce beween bar on a category value. Space between bar of of with different category value should not be removed. 回答1: I worked on this case using java customizer as follow: public class BarChartCustomizerExIm implements JRChartCustomizer{ @Override public void customize(JFreeChart chart, JRChart jasperChart) { BarRenderer barRenderer = (BarRenderer)plot.getRenderer(); barRenderer.setItemMargin(0); } } Put jar for this

Is there a workaround to make DateAxis draw tick from the first day of the week?

强颜欢笑 提交于 2019-12-10 10:44:27
问题 I bumped into this problem when I created a chart that need a axis with week period. When I set up tick unit of DateAxis with new DateTickUnit(DateTickUnitType.Day, 7) , it display tick mark every 7 days. However, the date of tick mark does not start from the first day of the week. You can observer this behavior in the screenshot. Cyan color line 05-01 w18(May. 1, Week 18) is below the w18(Week 18) tick mark, this is because the date of tick mark w18 are actually May 2, which is Wednesday.

JFreeChart interactive chart editing handling ChartMouseEvent

感情迁移 提交于 2019-12-10 10:36:18
问题 I'm trying to intercept ChartMouseEvent in order to modify an XYSeries of a JFreeChart object created with ChartFactory.createXYLineChart method (and displayed using a JDialog). I retrieve successfully the coordinate of the mouse event this way: public void chartMouseMoved(ChartMouseEvent arg0) { int x = arg0.getTrigger().getX(); int y = arg0.getTrigger().getY(); The origin of the coordinate system (0,0) is located at the red square in the picture. Now, I would like to calculate in which

Mapping JFreeChart Series Name to Series Index

徘徊边缘 提交于 2019-12-10 04:23:00
问题 I'm plotting a TimeTableXYDataset using a StackedXYBarRenderer . Unfortunately the colours of each series change on refresh. I know how to set colours using the setSeriesPaint method of the renderer, but that takes an integer series index as the argument. I create my datapoints using a string as the series name: ds.add(new SimpleTimePeriod(us.getDate(), new Date(us.getDate().getTime() + 1000*60)), us.getTotal(), us.getName())); How do I discover the mapping between series name and series

Change font-size of domain axis label and range axis label for jfreechart

不羁的心 提交于 2019-12-10 01:27:02
问题 My goal is to increase the size of "Revenue ($) " and "Years" . But I do not know how. I am able to increase the "Apples, Durians,Oranges" and "2012, 2013". Below are my codes. JFreeChart chart = ChartFactory.createBarChart3D("", // chart title "Years", // domain axis label "Revenue ($)", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation false, // include legend false, // tooltips false); CategoryPlot plot = chart.getCategoryPlot(); CategoryAxis axis = plot

JfreeChart customize ticket labels

喜夏-厌秋 提交于 2019-12-09 20:31:42
问题 I'm using JFreechart to plot a graph inside a report generated with JasperReports (actually I'm using DynamicReports which uses JasperReports). I'm plotting a barchart and I want to have custom strings on the labels on the axis. A picture will explain everything better. Now I've got this: I want to obtain this: Some suggestions? 回答1: Here is the solution to your problem. You need to provide a new Axis with text for each value String[] grade = new String[6]; grade[0] = "String0"; grade[1] =

Jfreechart: Is it possible to change the bar color?

给你一囗甜甜゛ 提交于 2019-12-09 15:53:20
问题 Is it possible to change the bar color? I have coded a simple program for counting. I want to implement one more thing: if the count number is greater than 200, use blue color to draw the bar. If not, use yellow color to do so. Currently, all bar color is in red. So, I would like to ask, is it possible to change the bar color? If yes, can someone give me some guide to realize? Thanks in advance! attached is my coding: <%@page contentType="text/html"%> <%@page import="java.io.*" %> <%@page

Jfreechart - can we set a shape for a datapoint in StackedAreaChart?

半城伤御伤魂 提交于 2019-12-09 03:44:24
I am using Jfreechart to make a stacked area chart. I am using the class StackedXYAreaChart. I wanted to know if we could draw shapes at data points for the StackedAreaChart, (it a line chart we can denote each data point by setting the SetSeriesShapes()). The method setSeriesShape() doesn't seem to work. Anyone have any idea ? Here's what I have tried till now (Please do not comment that I have an empty dataset. I am plotting a dynamic graph and the series would be filled later ): incomingData = new TimeTableXYDataset(); final JFreeChart incomingDataChart = ChartFactory

Add a JFreeChart in to JPanel

寵の児 提交于 2019-12-09 02:36:25
问题 if i have a my Jpanel and a my JFreeChart. How can I add this Chart in to the JPanel? XYSeries series = new XYSeries("XYGraph"); series.add(1, 1); series.add(1, 2); series.add(2, 1); series.add(3, 9); series.add(4, 10); // Add the series to your data set XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series); // Generate the graph JFreeChart chart = ChartFactory.createXYLineChart( "XY Chart", // Title "x-axis", // x-axis Label "y-axis", // y-axis Label dataset, //

JFreeChart get mouse coordinates

纵饮孤独 提交于 2019-12-08 23:10:14
问题 Is there a way in JFreeChart to determine from a ChartMouseEvent that x,y coordinates (in plot space) the mouse is over? I've tried using the domain crosshair value but that seems inaccurate and lags the actual mouse event. thanks, Jeff 回答1: Mouse coordinates from getTrigger() are relative to ChartPanel so you need to convert them: Point2D p = chartPanel.translateScreenToJava2D(mouseChartEvent.getTrigger().getPoint()); Rectangle2D plotArea = chartPanel.getScreenDataArea(); XYPlot plot =