Solved

javascript simple horizontal bar graph

Posted on 2011-02-24
2
689 Views
Last Modified: 2012-05-11
Hi,
I have a grid table with data.
I want to add a column that shows horizontal bar graphs as in the picture.
I don't want a large library (I am already using "FusionChartsFree" for graphs).
I supose it can be dont with a simple script.
ScreenShot-4776.jpg
0
Comment
Question by:VapiSoft
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 40

Accepted Solution

by:
gurvinder372 earned 500 total points
ID: 34976838
something like this?
you can change the color if you want to:)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
	<script>
		function showGraph()
		{
			var innerDiv = document.getElementById("div1").getElementsByTagName("div")[0];
			innerDiv.style.backgroundColor = "pink";
			innerDiv.style.backgroundColor = "pink";
			innerDiv.style.width = innerDiv.innerHTML + "px";
			innerDiv.innerHTML = innerDiv.innerHTML + "%"


			var innerDiv = document.getElementById("div2").getElementsByTagName("div")[0];
			innerDiv.style.backgroundColor = "pink";
			innerDiv.style.backgroundColor = "pink";
			innerDiv.style.width = innerDiv.innerHTML + "px";
			innerDiv.innerHTML = innerDiv.innerHTML + "%"


			var innerDiv = document.getElementById("div3").getElementsByTagName("div")[0];
			innerDiv.style.backgroundColor = "pink";
			innerDiv.style.backgroundColor = "pink";
			innerDiv.style.width = innerDiv.innerHTML + "px";
			innerDiv.innerHTML = innerDiv.innerHTML + "%"


			var innerDiv = document.getElementById("div4").getElementsByTagName("div")[0];
			innerDiv.style.backgroundColor = "pink";
			innerDiv.style.backgroundColor = "pink";
			innerDiv.style.width = innerDiv.innerHTML + "px";
			innerDiv.innerHTML = innerDiv.innerHTML + "%"



		}
	</script>
	<style>
		body div
		{
			width:100px;
			height:30px;
			background-color:#fff;
			border:1px solid black;
		}
		div div
		{
			border:1px none black;
			border-right:1px solid black;
			height:100%;
		}

	</style>
</HEAD>

<BODY onload="showGraph()">
	<div id="div1"><div>60</div></div>
	<div id="div2"><div>40</div></div>
	<div id="div3"><div>60</div></div>
	<div id="div4"><div>80</div></div>
</BODY>
</HTML>

Open in new window

0
 

Author Closing Comment

by:VapiSoft
ID: 34976887
Exactly.
Thank you very much.
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question