Yahoo Finance Like Chart

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
homecurr
Posts: 4
Joined: Tue Apr 20, 2004 4:52 am

Yahoo Finance Like Chart

Post by homecurr » Tue Apr 20, 2004 5:02 am

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;
}

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Re: Yahoo Finance Like Chart

Post by david.gilbert » Tue Apr 20, 2004 10:28 am

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?
These things will help a little:

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)); 
homecurr wrote:The font of the title looks like bold, how can I make it plain?
Get the title:

http://www.jfree.org/jfreechart/javadoc ... l#getTitle()

Set the font:

http://www.jfree.org/jfreechart/javadoc ... .awt.Font)
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

Locked