Using the Chart class to create scatter plot with trendline

PDF pdf = new PDF();
Font f1 = new Font(pdf, "Helvetica-Bold");
Font f2 = new Font(pdf, "Helvetica-Bold");
Font f3 = new Font(pdf, "Helvetica-Bold");
Font f4 = new Font(pdf, "Helvetica");
// Please note:
// All font and image objects must be created
// before the first page object.

Page page = new Page(pdf, Letter.PORTRAIT);
f1.setSize(10);
f2.setSize(8);
f3.setSize(7);
f4.setSize(7);

Chart chart = new Chart(f1, f2);
chart.SetTitle("World View - Communications");
chart.SetXAxisTitle("Cell phones per capita");
chart.SetYAxisTitle("Internet users % of the population");

chart.SetData(getData("data/world-communications.txt", "|"));
addTrendLine(chart);

chart.SetPosition(70, 50);
chart.SetSize(500, 300);
chart.DrawOn(page);

addTableToChart(page, chart, f3, f4);

pdf.Wrap();
pdf.Save("Example_09.pdf");
Example_09.cs Example_09.pdf

© 2007 Innovatics Inc.