Forum Moderators: mack

Message Too Old, No Replies

Using tables or divs to draw bar graph

anyone ever tried this? good or bad idea

         

KeithDouglas

1:05 pm on May 4, 2005 (gmt 0)

10+ Year Member



I have some numerical information I would like to present graphically, as bar charts.

The information is sort of like this:

Chicago: 120,000
New York: 175,000
Denver: 98,000
Atlanta: 140,000

I was thinking of using a table with two tables cells on each row. The first cell would contain the name of the data item (city name, in this example). The second cell would be a <div> with a background color and a width that would correspond to the value (say, 120 pixels wide to represent 120,000).

Is this a good idea? Has anyone else used HTML to graphically display data in this manner?

bartainer

8:50 pm on May 4, 2005 (gmt 0)

10+ Year Member



How about applying a class to the TD tag?

td.name_of_city { background-color:?; width:?;}
td.number { background-color:?; width:?;}

limbo

10:37 am on May 6, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Personally I'd use a graphic for speed. But you could achieve it using CSS too. If you do use CSS then I'd not use tables as well. You could float a series of coloured divs horizonzally and use padding to position the column headers and other info.

<afterthought> thinking about it, it is probably semantically correct to display a bar chart using tables, giving the header columns a title and the table a summary description, your choice...</afterthought>

treeline

3:29 am on May 15, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It works very well to use a simple .gif file and stretch it to the appropriate size. Very fast too.

Chicago: height=120
New York: height=175
Denver: height=98
Atlanta: height=140