You know, I often get asked, “What’s everyone’s fascination with gauges?” I never know what to say really because I’m crazy over gauges myself. For me, I just believe they are a concise and familiar way to share data with people who care!
Gauges are familiar
I think familiarity really is the key here. Think about it for a second…We use gauges every single day. You have gauges in your car. You have a gauge on your wrist. You may even have a gauge on your stove.
Intimate, everyday experiences and you all experience them with a gauge. Driving is critical. Knowing the right time is critical. Making sure your dinner is cooked is critical. So sharing business critical information in a gauge is not only a natural progression, it just makes sense.
Refactoring the accelerate method
One feature request in particular has been getting much support among the customer base: The ability to control which MPH/KPH the Accelerate method stops at.
Here is the result of the refactoring…
Original accelerate method
Originally, I only envisioned this method to be used for demo purposes. The scope was to have the gauge needle move from rest to the last value of the speedometer gauge:
Think of the Timer as simulated data points. In production, those data points (mph/kph) should come from a real data source via Ajax using JSON. That data source can be anything you can consume. So grab your favorite scripting language and hook your model up to your favorite data store (PostgreSQL, MySQL, MongoDB, SQLite, HTML5 Local Storage).
As you can see, the previous implementation was also limited to the MPH markings only. For demo purposes it got the job done. But many people had different expectations. Many people wanted to set the MPH and still have the easing effect.
Well, I believe I have a solution that’s going to solve all your problems.
Refactored accelerate method
For now, I’m happy with the results of the refactored version. First, it’s closer to customer expectation. Second, it’s flexible as you can use it for both MPH and KPH. Finally, performance has increased immensely:
Now you have the ability to set either the MPH or the KPH and still get the easing effect that made you fall in love with the accelerate method.
Also, you will get a lot more CPU cycles in since stopTime has been implemented. The timer is being shut off once you reach your targeted MPH/KPH - no more wasted CPU cycles.
Thanks to random timer labels, you can continue to place as many gauge instances as you wish without one colliding with the other.
It’s a lot of fun making and supporting the Gauge Suite. Please do check out the Business package for a Commercial License and six months of support. In addition, you’ll find a spectacular set of bonus gauges and one year of support in the Enterprise package.
Have fun, take care and be awesome!