Friday, 15 January 2010

java - ChartPanel in a JScrollPane -



java - ChartPanel in a JScrollPane -

i'm trying add together chartpanel in jscrollpane , create horizontal scrollbar visible when needed. when there many columns in chart, want panel more wide frame , create horizontal scrollbar visible. want have minimum gap between bars in chart. post code, without scrollpane , without minimum gap between bars. questions are: how set precise gap between bars? how create visible horizontal scroll when there many bars represent on frame width?

package view; import java.text.simpledateformat; import java.util.calendar; import java.util.locale; import java.util.map; import java.util.map.entry; import javax.swing.springlayout; import org.jfree.chart.chartfactory; import org.jfree.chart.chartpanel; import org.jfree.chart.jfreechart; import org.jfree.chart.plot.plotorientation; import org.jfree.data.category.defaultcategorydataset; public class statisticspanel extends abstractcenterpanel { private static final long serialversionuid = 1l; private final chartpanel chartpanel; public statisticspanel(final map<calendar, integer> cashmap) { super(); final simpledateformat df = new simpledateformat("dd/mm", locale.italy); final defaultcategorydataset dataset = new defaultcategorydataset(); (entry<calendar, integer> e : cashmap.entryset()) { dataset.setvalue(e.getvalue(), "incasso", df.format(e.getkey().gettime())); } final jfreechart chart = chartfactory.createbarchart("andamento degli incassi", "data", "incasso (€)", dataset, plotorientation.vertical, false, true, false); this.chartpanel = new chartpanel(chart); final springlayout layout = new springlayout(); this.setlayout(layout); layout.putconstraint(springlayout.west, this.chartpanel, 0, springlayout.west, this); layout.putconstraint(springlayout.north, this.chartpanel, 0, springlayout.north, this); layout.putconstraint(springlayout.east, this.chartpanel, 0, springlayout.east, this); layout.putconstraint(springlayout.south, this.chartpanel, 350, springlayout.north, this); this.add(this.chartpanel); } }

java swing jfreechart

No comments:

Post a Comment