Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 12th, 2009, 11:37 AM
van van is offline
Registered User
 
Join Date: Nov 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default FPDF in asp for bar chart

Hi all,

The previous posts on FPDF in asp were all very helpful.

I have a asp report that has dynamic barcharts in them which has to be converted to PDF using FPDF in asp. Is there any extension available for it?
Or How can I do it if I have to do it myself.

Thanks in advance,
 
Old November 12th, 2009, 05:21 PM
Friend of Wrox
 
Join Date: Dec 2006
Posts: 104
Thanks: 9
Thanked 1 Time in 1 Post
Default

Van,

I have had a good search for bar charts already but only found php examples so far

http://www.fpdf.de/downloads/addons/28/ php example

The only chart extention i have found is a pie chart, shown below:

pie_chart.asp

Code:
<%@language=javascript%>
<!--#include file="fpdf.asp"-->
<%
var pdf=new FPDF();
pdf.CreatePDF();
pdf.SetPath("fpdf/");
pdf.LoadExtension("sectors")
pdf.Open();
pdf.SetFont('Arial','',12);
pdf.Open();
pdf.AddPage();
xc=105;
yc=55;
r=40;
pdf.SetFillColor(120,120,255);
pdf.Sector(xc,yc,r,20,120);
pdf.SetFillColor(120,255,120);
pdf.Sector(xc,yc,r,120,250);
pdf.SetFillColor(255,120,120);
pdf.Sector(xc,yc,r,250,20);
pdf.Output();
%>
sectors.ext

this.Sector=function Sector(xxc , xyc , xr , xa , xb , xstyle , xcw , xo)
{
if (arguments.length<6) {xstyle="FD"};
if (arguments.length<7) {xcw=true};
if (arguments.length<8) {xo=90};

if(xcw)
{
xd=xb;
xb=xo-xa;
xa=xo-xd;
}
else
{
xb+=xo;
xa+=xo;
}
xa=(xa%360)+360;
xb=(xb%360)+360;
if(xa>xb)xb+=360;
xb=xb/360*2*Math.PI;
xa=xa/360*2*Math.PI;
xd=xb-xa;
if(xd==0)xd=2*Math.PI;
xk=this.k;
xhp=this.h;
if(xstyle=="F")xop="f";
else if(xstyle=="FD" || xstyle=="DF")xop="b";
else {xop="s";}
if(Math.sin(xd/2))xMyArc=4/3*(1-Math.cos(xd/2))/Math.sin(xd/2)*xr;
this._out(lib.sprintf("%.2f %.2f m",(xxc)*xk,(xhp-xyc)*xk));
this._out(lib.sprintf("%.2f %.2f l",(xxc+xr*Math.cos(xa))*xk,((xhp-(xyc-xr*Math.sin(xa)))*xk)));
if(xd<Math.PI/2)
{
this._Arc(xxc+xr*Math.cos(xa)+xMyArc*Math.cos(Math .PI/2+xa),xyc-xr*Math.sin(xa)-xMyArc*Math.sin(Math.PI/2+xa),xxc+xr*Math.cos(xb)+xMyArc*Math.cos(xb-Math.PI/2),xyc-xr*Math.sin(xb)-xMyArc*Math.sin(xb-Math.PI/2),xxc+xr*Math.cos(xb),xyc-xr*Math.sin(xb));
}
else
{
xb=xa+xd/4;
xMyArc=4/3*(1-Math.cos(xd/8))/Math.sin(xd/8)*xr;
this._Arc(xxc+xr*Math.cos(xa)+xMyArc*Math.cos(Math .PI/2+xa),xyc-xr*Math.sin(xa)-xMyArc*Math.sin(Math.PI/2+xa),xxc+xr*Math.cos(xb)+xMyArc*Math.cos(xb-Math.PI/2),xyc-xr*Math.sin(xb)-xMyArc*Math.sin(xb-Math.PI/2),xxc+xr*Math.cos(xb),xyc-xr*Math.sin(xb));
xa=xb;
xb=xa+xd/4;
this._Arc(xxc+xr*Math.cos(xa)+xMyArc*Math.cos(Math .PI/2+xa),xyc-xr*Math.sin(xa)-xMyArc*Math.sin(Math.PI/2+xa),xxc+xr*Math.cos(xb)+xMyArc*Math.cos(xb-Math.PI/2),xyc-xr*Math.sin(xb)-xMyArc*Math.sin(xb-Math.PI/2),xxc+xr*Math.cos(xb),xyc-xr*Math.sin(xb));
xa=xb;
xb=xa+xd/4;
this._Arc(xxc+xr*Math.cos(xa)+xMyArc*Math.cos(Math .PI/2+xa),xyc-xr*Math.sin(xa)-xMyArc*Math.sin(Math.PI/2+xa),xxc+xr*Math.cos(xb)+xMyArc*Math.cos(xb-Math.PI/2),xyc-xr*Math.sin(xb)-xMyArc*Math.sin(xb-Math.PI/2),xxc+xr*Math.cos(xb),xyc-xr*Math.sin(xb));
xa=xb;
xb=xa+xd/4;
this._Arc(xxc+xr*Math.cos(xa)+xMyArc*Math.cos(Math .PI/2+xa),xyc-xr*Math.sin(xa)-xMyArc*Math.sin(Math.PI/2+xa),xxc+xr*Math.cos(xb)+xMyArc*Math.cos(xb-Math.PI/2),xyc-xr*Math.sin(xb)-xMyArc*Math.sin(xb-Math.PI/2),xxc+xr*Math.cos(xb),xyc-xr*Math.sin(xb));
}
this._out(xop);
}
this._Arc=function _Arc(xx1 , xy1 , xx2 , xy2 , xx3 , xy3)
{
xh=this.h;
this._out(lib.sprintf("%.2f %.2f %.2f %.2f %.2f %.2f c",xx1*this.k,(xh-xy1)*this.k,xx2*this.k,(xh-xy2)*this.k,xx3*this.k,(xh-xy3)*this.k));
}

Cheers Aspless
 
Old November 13th, 2009, 02:07 PM
van van is offline
Registered User
 
Join Date: Nov 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

aspless,
Thank you very much for piechart code. It worked. I will try to see if i can do something similar for bar charts. Meantime if someone has the extensions for bar charts please guide me.

Thanks again





Similar Threads
Thread Thread Starter Forum Replies Last Post
Bar Chart Properties Neal Crystal Reports 0 May 25th, 2007 05:04 AM
Bar Chart eilob C# 1 May 20th, 2007 09:48 PM
Bar Chart Problem.? megana Crystal Reports 0 July 21st, 2006 02:53 PM
Bar Chart with Item names beside bar jmurdock BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 0 July 23rd, 2004 01:05 PM
Drill Down from Bar Chart to another chart snowbird Crystal Reports 0 July 11th, 2003 01:53 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.