Solved

HTML5 Graphic Fill Percentage

Posted on 2014-04-23
3
554 Views
Last Modified: 2014-05-15
Hello,

I need to represent tank levels on my website, based off of live data.  I have access to the data, but need recommendations on what the best tool is to create this view.  

I'm using an Apache server, but I was thinking HTML5 might be the best approach.  I'd like to show a picture of a liquid tank (like an empty clipart pic of tank).  Something like this:  http://photo.oempromo.com/Prod_799/Stock-Shape-Collection-Big-Propane-Tank-Key-Tag_45839759.jpg

I'd like to show a fill color that fills based on a percentage.  Would it be best to layer the tank, and make the inside of the tank transparent, and overlay that on top of an HTML canvas box?  Any suggestions would be appreciated.

Thanks
0
Comment
Question by:compsol1993
3 Comments
 
LVL 9

Expert Comment

by:WebDevEM
ID: 40018215
I don't have the time right now to work up a demo (meetings all day!) but my thought would be to use a canvas, draw the tank on there (which basically drops your image file onto the canvas, no need to draw it manually), and draw a rectangle either on top of it or behind it (if you make the center transparent) based on your data.

I'm pretty new to HTML5, but I'm sure somebody more familiar could whip up a demo fairly quickly.  It'd take me a decent amount of time... I'd love to see the solution!

I hope this gets you started,

WebDevEM
0
 
LVL 35

Accepted Solution

by:
Robert Schutt earned 500 total points
ID: 40019451
Canvas is certainly possible but have a look here: http://schutt.nl/ee/Q_28418447/

For this I have re-used parts of an earlier solution I posted here on EE (that's where the colors come from, I don't suppose you have blue and pink liquids ;-)

The files I used are also attached below.
index.html
tankfill.js
tankfill.css
tanktrans.png
0
 

Author Closing Comment

by:compsol1993
ID: 40068178
Perfect, thanks!
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
Recently I spent hours debugging an issue in a Rails project where ActiveRecord was causing MySQL errors trying to create a User object of a class at the top level of a Single Table Inheritance model structure.  It turns out `.create` behaves differ…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

706 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now