File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

reducing space in graph with FreeWebLineChart4J

 
samart mateo
Ranch Hand
Posts: 37
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
helo,
i'm doing a graph in jsp. i had succeeded to display the graph with data from the db. but some how, when i enlarge my graph size (width), the empty space on the right hand side of the picture(graph) also increases. i'd like to reduce the empty space. could someone show me which code should i alter? i tried some but it didnt work out. here's my line of codes..

------------------------------------------------------------------------

<%@ page import = "net.comrom.chart.*" %>
<%@ page import = "net.comrom.chart.gc.*" %>

String encode="jpeg";
//String uri=request.getRequestURI();
//String myurl="http://"+request.getHeader("Host")+uri.substring(0,uri.length()-12); //12 ist the length of my page name


response.setContentType("image/jpeg");
response.setDateHeader ("Expires",0);
// get output stream
java.io.OutputStream outb=response.getOutputStream();

// size of the chart image
int w=1200;
int h=600;

// data (looping)--------------
double[] d1= new double [noR.size()];

for (int i=0; i<noR.size(); i++){
%><%
String amik = (String)noR.elementAt(i);
double amik1 = Double.parseDouble(amik);
%><%
d1[i] = amik1; }

//----------------------------------------------------
LineDataSerie data1= new LineDataSerie(d1,new LineStyle(1f,GraphicsProvider.getColor(ChartColor.BLACK),LineStyle.LINE_DOTS));
data1.valueFont=GraphicsProvider.getFont("Arial",ChartFont.BOLD,10);
data1.valueColor=GraphicsProvider.getColor(ChartColor.BLUE);
//data1.valueFont=GraphicsProvider.getFont("Arial",ChartFont.BOLD,10);

// create title
Title title=new Title("WIP for <"+pjkID+"> on <"+tarikh+">");
title.color=GraphicsProvider.getColor(ChartColor.MAGENTA);

// create axis
Axis XAxis=new Axis(Axis.HORIZONTAL,new Scale());
Axis YAxis=new Axis(Axis.VERTICAL,new Scale());
XAxis.tickAtBase=true; // draw also first tick
XAxis.ceroAxis=Axis.CEROAXIS_NO;
YAxis.ceroAxis=Axis.CEROAXIS_NO;
YAxis.scale.min=0;
YAxis.DescColor=GraphicsProvider.getColor(ChartColor.BLUE); //warna legend paksi y
YAxis.scaleTickInterval=20;//skala utk paksi y
XAxis.scaleTickInterval=1;
XAxis.bigTickInterval=1;
XAxis.DescColor=GraphicsProvider.getColor(ChartColor.BLUE); //warna legend paksi y

//String[] lbls={"1995","1996a","1997","1998","1999","2000","2001"};
// label paksi-x (from db-vector)
String[] lbls = new String [stationNameR.size()];

for (int j=0; j<stationNameR.size(); j++){

String test = (String)stationNameR.elementAt(j);
lbls[j] = test;
}

//String[] lbls = new String [pjkIDR.size()];
//pjkIDR.copyInto(String [] lbls);
//----------------------------------------

XAxis.tickLabels=lbls;
XAxis.style =new LineStyle(0.2f,GraphicsProvider.getColor(ChartColor.BLACK),LineStyle.LINE_NORMAL);
YAxis.style =new LineStyle(0.2f,GraphicsProvider.getColor(ChartColor.BLACK),LineStyle.LINE_NORMAL);
YAxis.gridStyle=new LineStyle(1,GraphicsProvider.getColor("0xC0C0C0"),LineStyle.LINE_NORMAL);
XAxis.gridStyle=new LineStyle(1,GraphicsProvider.getColor("0xC0C0C0"),LineStyle.LINE_NORMAL);
XAxis.axisFrame=true;
YAxis.axisFrame=true;

HAxisLabel XLabel= new HAxisLabel("Workcenter",GraphicsProvider.getColor(ChartColor.BLACK),GraphicsProvider.getFont("Arial",ChartFont.BOLD,12));
VAxisLabel YLabel= new VAxisLabel("No of panels",GraphicsProvider.getColor(ChartColor.BLACK),GraphicsProvider.getFont("Arial",ChartFont.BOLD,12));

// plotter
LinePlotter plot=new LinePlotter();

// create chart
Chart chart=new Chart(title,plot,XAxis,YAxis);
chart.XLabel=XLabel;
chart.YLabel=YLabel;
chart.addSerie(data1);
chart.back=new FillStyle(GraphicsProvider.getColor(ChartColor.LAVENDER));
chart.setSize(w,h);
chart.saveToFile(outb,"jpeg");
outb.close();
//-----------------------------------------------------------------------

Thank you.
[ May 15, 2006: Message edited by: Bear Bibeault ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64196
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Might it not be helpful to mention which charting package you are using?
 
samart mateo
Ranch Hand
Posts: 37
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry. nway i'm using the JFreeWebLineChart that could be retrieve from
http://www.javaresources.biz/line.jsp
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64196
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moved to the Other Open Source Projects forum.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic