Here is the way you can complete the first part of the question.
Working example: http://jsfiddle.net/Twisty/03yuc3un/
HTML
<div id="progressbar"></div> <div class="form"> Add Funds: <input type="" id="funds" /> <button id="addBtn">Add</button> </div>
CSS
.form { padding: 20px; } .ui-progressbar-value { float: left; text-align: center; padding-top: .25em; } .form input { width: 4em; } #progressbar div.ui-progressbar-value.ui-widget-header:first-of-type { z-index: -1; display: none; } .color-1 { background: #FF0000; } .color-2 { background: #FFA500; } .color-3 { background: #FFFF00; } .color-4 { background: #00FF00; } .color-5 { background: #0000FF; } .color-6 { background: #FF00FF; }
JQuery
$(function() { var $pgbr = $("#progressbar").progressbar({ value: 0, max: 100, change: function(e, ui) { $(this).find(".ui-progressbar-value").eq(0).css("display", "none"); } }); $("#addBtn").button().click(function(e) { var funds = parseInt($("#funds").val()); var cValue = $pgbr.progressbar("value"); var sum = cValue + funds; if (sum > $pgbr.progressbar("option", "max")) { return false; } $pgbr.progressbar("value", sum); if (funds) { var $chunk = $("<div>", { class: "ui-progressbar-value ui-widget-header", width: ((funds / $pgbr.progressbar("option", "max")) * 100) + "%" }); var count = $("#progressbar .ui-progressbar-value").length; if (count == 0) { $chunk.addClass("ui-corner-left"); } if (count <= 6) { $chunk.addClass("color-" + count); } else { $chunk.addClass("color-" + count % 6); } $chunk.html(funds); $pgbr.append($chunk); } }); });
As you can see, there is no way to make partitions naturally using progressbar() . This example allows us to add amounts to the progress bar. If the target is 100 or 2000, this can be set to max during initialization. This example assumes that you are adding money collected per day to the goal. Examples of tests: 30 US dollars per day 1, 10 US dollars per day 2, 20 US dollars on the 3rd day.
When adding funds, one more div added with the width set in percentage. This will help to correctly evaluate the value of the goal. If the target is $ 100, the width will be 30%. If the target is $ 2000, the width will be 1.5%.
Using CSS, you can assign specific colors. I selected 6 colors and rotated them according to the number of sections already added. You can do this in several ways.
Now let's say that your stretch goal is $ 5000, and your minimum goal is $ 2000, initially it could be max of 2000 . If the amount collected exceeds $ 2000 ... there is a little logistical problem. You can iterate over each section and resize it to the appropriate percentage. Personally, I believe that it is best to reduce the width of the progress bar itself and create a second progress bar that can track the surplus.
Feel free to comment questions.