Hi
I want to generate the same chart as Yahoo Finance uses for stock quote. JFreeChart works pretty well. I have just one problem. The margin around the chart is to large and it takes too much of my web page space. How can I change it? The font of the title looks like bold, how can I make it plain?
here is my code:
Thanks,
John
private JFreeChart createTimesChart(String zip, String range) {
XYDataset dataset = createDataset();
JFreeChart chart = ChartFactory.createTimeSeriesChart(
zip,
"",
"",
dataset,
false,
false,
false
);
// chart.setBackgroundPaint(Color.white);
chart.setAntiAlias(true);
return chart;
}
Yahoo Finance Like Chart
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
Re: Yahoo Finance Like Chart
These things will help a little:homecurr wrote:I want to generate the same chart as Yahoo Finance uses for stock quote. JFreeChart works pretty well. I have just one problem. The margin around the chart is to large and it takes too much of my web page space. How can I change it?
Code: Select all
TextTitle title = chart.getTitle();
title.setSpacer(new Spacer(Spacer.ABSOLUTE, 0.0, 0.0, 0.0, 0.0));
XYPlot plot = (XYPlot) chart.getPlot();
plot.setInsets(new Insets(0, 0, 0, 0));
ValueAxis domainAxis = plot.getDomainAxis();
domainAxis.setLabelInsets(new Insets(0, 0, 0, 0));
ValueAxis rangeAxis = plot.getRangeAxis();
rangeAxis.setLabelInsets(new Insets(0, 0, 0, 0));
Get the title:homecurr wrote:The font of the title looks like bold, how can I make it plain?
http://www.jfree.org/jfreechart/javadoc ... l#getTitle()
Set the font:
http://www.jfree.org/jfreechart/javadoc ... .awt.Font)
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader

