• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Creating Bar chart in jsp

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I hav created bar chart using table tag along with <div>.Currently i am not able to create coordinates with values 10,20,30 etc ....


Could anyone help me with creating bar chart or send me the sample code.

Thanks in advance.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you using some library to create charts? Or is it pure HTML? If the latter, post the HTML you have, and describe what it is missing.
 
Malarvizhi Nandakumar
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<table valign="center">

<td valign="bottom"> <div style='background-color:red;width=1;height=400'> </td>

<%
int HorX=10;
int chartwidth = 100;
int VerY[] = {100, 200, 800, 100};
int vmax=300;
int i=0;
int tdwd = chartwidth-(HorX*4)/HorX;
System.out.println("tdwd"+tdwd);

int h;
for(int len=0;len<4;len++)
{
System.out.println("ver"+VerY[len]);
h = VerY[i] / (vmax / 100);
System.out.println("h"+h);
%>

<td valign="bottom"> <div style='background-color:pink; width:"<%=(tdwd-5)%>";height: "<%=h%>"'> </td>

<%
i++;
}
%>

<tr>

<td></td>
<%
for (i=0;i<4;i++)
{
%>

<td> <div> <%=VerY[i]%> </div> </td>
<%
}
%>
</tr>


</table>
 
Malarvizhi Nandakumar
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<table valign="center">

<td valign="bottom"> <div style='background-color:red;width=1;height=400'> </td>

<%
int HorX=10;
int chartwidth = 100;
int VerY[] = {100, 200, 800, 100};
int vmax=300;
int i=0;
int tdwd = chartwidth-(HorX*4)/HorX;
System.out.println("tdwd"+tdwd);

int h;
for(int len=0;len<4;len++)
{
System.out.println("ver"+VerY[len]);
h = VerY[i] / (vmax / 100);
System.out.println("h"+h);
%>

<td valign="bottom"> <div style='background-color:pink; width:"<%=(tdwd-5)%>";height: "<%=h%>"'> </td>

<%
i++;
}
%>

<tr>

<td></td>
<%
for (i=0;i<4;i++)
{
%>

<td> <div> <%=VerY[i]%> </div> </td>
<%
}
%>
</tr>


</table>

This is the HTML code i hav used and i want the X and Y axis in the bar chart to be drawn along with the values.
 
Malarvizhi Nandakumar
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<table valign="center">

<td valign="bottom"> <div style='background-color:red;width=1;height=400'> </td>

<%
int HorX=10;
int chartwidth = 100;
int VerY[] = {100, 200, 800, 100};
int vmax=300;
int i=0;
int tdwd = chartwidth-(HorX*4)/HorX;
System.out.println("tdwd"+tdwd);

int h;
for(int len=0;len<4;len++)
{
System.out.println("ver"+VerY[len]);
h = VerY[i] / (vmax / 100);
System.out.println("h"+h);
%>

<td valign="bottom"> <div style='background-color:pink; width:"<%=(tdwd-5)%>";height: "<%=h%>"'> </td>

<%
i++;
}
%>

<tr>

<td></td>
<%
for (i=0;i<4;i++)
{
%>

<td> <div> <%=VerY[i]%> </div> </td>
<%
}
%>
</tr>


</table>

This is the HTML code i hav used and i want the X and Y axis in the bar chart to be drawn along with the values.
 
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can go for JFreeChart of souceforge

just search JFreeChart in google
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'll move this to the HTML forum, since it has nothing to do with JSP.

One way I could see this working is with a one-column table to the left of the graph where each cell has has balck background and is one pxiel wide. That would be for the Y axis.
Then another table below the graph that has one row, each cell one pixel high; that's for the X axis.

If you want tick marks then it gets more complicated.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic