0

I'd like to create a HTML table similar to this as much as possible: enter image description here

Main 'features' would consist of:

  • tds colored based on values
  • bars in the background based on percentage
  • HTML and javascript/jQuery only (data is manually entered anyways)

Is it possible to do such a thing with HTML/js only, and what would you recommend for accomplishing this task?

5
  • It doesn't belong here... :) (many times, there are guys that even write it all for you, but it's still not the place) Commented Jun 1, 2012 at 14:18
  • 1
    I'm not sure this should be closed : that's clear, not trivial, he doesn't ask for complete solution and it's possible to respond correctly (Diodeus' answer seems OK). We should just remove the introduction. Commented Jun 1, 2012 at 14:23
  • yes... it can be done I would recommend just doing it... (seriously tho, do you just want someone to do it for you? there are consultants!) Commented Jun 1, 2012 at 14:27
  • Ahh, my first -1 :( I didn't ask for complete code at all... I'm just confused a bit is js aware of metrics (which I would use for bars) and coloring tds based on values... I mean, I could easily do this in python or php or something, but all I can use is html and js. I'm not even sure if all this is possible with only that... For example, Diodeus' and david's answers are just perfect pointers how could this be done... I know this place is not made for discussions, I need only few snippets to even start with this... Apologies one more time... Commented Jun 1, 2012 at 14:31
  • -2?! uh, really a terrible mistake :-/ Commented Jun 1, 2012 at 14:34

3 Answers 3

3

Put two DIVs in each TD, one absolutely-positioned to display the value, the other for the bar. Use a simple CSS3 gradient background on the bar.

Sign up to request clarification or add additional context in comments.

Comments

1

coloring the cells based on value should be pretty simple with js.

I have never seen the bars in an html table, but here is one possible direction: Each td contains an input for the user to enter a value and a floating div. When the user updates the value, use js to set the width of the floating div to the appropriate percentage.

Things to consider:

  • Set the Z-index of the input higher than the floating div
  • Make sure the floating div can be clearly and easily identified so js knows which to update

Comments

1

yes you can achieve this with html/css/js. I recommend you use jquery (as it is still js), you can get the numbers and calculate the percentages then add a class for the bars

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.