Here is my current code. The bars are showing a blank image if the
value is the same as the maxvalue which makes since since 60/60 = 0.
The maxHieght is a constant of 120. The other graphs don't size
correctly to the data value 4 value / 60 maxValue * 120 = 8 but the
image is close to the top of the cell. Image width is a constant of
30.
private void PaintPlacements (DataTable dtPlacements)
{
DataRow[] rows = dtPlacements.Se lect();
double maxPlacements = Double.Parse(dt Placements.Comp ute
("Max(PLACEMENT S_NBR)", "").ToString()) ;
double maxPerformer = Double.Parse(dt Placements.Comp ute
("Max(BEST_PERF ORMER_NBR)", "").ToString()) ;
double[] maxValue = {maxPlacements, maxPerformer};
tblPlacements.R ows.Add(AddPlac ementGraphs(row s, maxValue,
ScorecardData.I mageWidth));
}
private TableRow AddPlacementGra phs(DataRow[] rows, double[] maxValue,
int barWidth)
{
double graphData;
double graphHeight;
TableRow tr = new TableRow();
foreach(DataRow row in rows)
{
TableCell tc = new TableCell();
graphData = Double.Parse(ro w["PLACEMENTS_NBR "].ToString());
graphHeight = (graphData / maxValue[0] *
ScorecardData.M aximumHeight);
tc.Text = "<img border=0 src=../images/spacer1.gif" +
" height=" + Math.Round(grap hHeight, 0) +
" width=" + barWidth + ">";
tc.BackColor = Color.FromName( "Blue");
tc.VerticalAlig n = VerticalAlign.T op;
tr.Cells.Add(tc );
tc = null;
tc = new TableCell();
graphData = Double.Parse(ro w["BEST_PERFORMER _NBR"].ToString());
graphHeight = (graphData / maxValue[1] *
ScorecardData.M aximumHeight);
tc.Text = "<img border=0 src=../images/spacer1.gif" +
" height=" + Math.Round(grap hHeight, 0) +
" width=" + barWidth + ">";
tc.BackColor = Color.FromName( "CornflowerBlue ");
tc.VerticalAlig n = VerticalAlign.T op;
tr.Cells.Add(tc );
tc = null;
}
return tr;
}
Mark R. Dawson wrote:
Are rowValue and maxRowValue both integer values? You need to make sure at
least on of those values is a floating point number otherwise you are just
going to end up with 0's.
When you say not being sized correctly, what exactly do you mean?
Mark.
--
http://www.markdawson.org