Rather than try to reinvent the wheel, I'm hoping someone can shed some light on how to create a stacked/segmented bar or point me to an existing control. Here's what I need:
- Horizontal bar
- Standard html
- Each segment needs to be color coded from css
- Each segment needs to be a percentage of the total (i.e. if total value = 100, then a value of 10 for one of the segments would be smaller than a value of 50)
- Should be able to fit seamlessly into an html table cell
- Should not be an image
- Should only create a single bar with segments (not multiple bars/segmented bars)
- Server-side generated, no AJAX
This should be as simple as possible given x number of values, create x segments.
I'm looking for code examples or already-built controls.
EDIT: For completeness:
int[] segments = { 10, 5, 45, 20, 20 };
Panel horizontalBar = new Panel();
for(int segmentIndex = 0; segmentIndex < segments.Length; ++ segmentIndex)
{
horizontalBar.Controls.Add(new Panel() { ID = String.Format("segment-{0}", segmentIndex), Width = Unit.Percentage(segments[segmentIndex]), CssClass = "segment" });
}
this.Page.Form.Controls.Add(horizontalBar);