I am working with MSChart. I took the example code off of Patric Johansson tutorial about MSChart and trying to make mine do the same thing. Here is a piece of his code:
-------------------------------------------------------------
axMSChart.ChartData = new Object[5, 4] {
{null, "Computer A","ComputerB", "Computer C"},
{"10:00 AM", 123131, 242142, 254353},
{"10:01 AM", 113121, 171345, 205432},
{"10:02 AM", 126323, 281876, 269743},
{"10:03 AM", 199833, 242122, 283445}};
--------------------------------------------------------------
What I want to do is get my arrays in the above format.
My results from the array will be (these are examples)
12-Jul-2007, 10:00 am, HGB, 10.5
12-Jul-2007, 10:00 am, HCT, 31.0
12-Jul-2007, 11:00 am, HGB, 12.0
12-Jul-2007, 11:00 am, HCT, 36.0
13-Jul-2007, 12:00 am, HGB, 12.5
13-Jul-2007, 12:00 am, HCT, 37.0
15-Aug-2007, 11:15 am, HGB, 14.0
15-Aug-2007, 11:15 am, HCT, 42.1
...and so on. They can have different dates, times and results.
I want it to look like:
{null, "HGB","HCT"},
{12-Jul-2007, "10:00 AM", "10.5", "31.0"},
{12-Jul-2007, "11:00 AM", "12.0", "36.0"},
{13-Jul-2007, "12:00 AM", "12.5", "37.0"},
{15-Jul-2007, "11:15 AM", "14.0", "42.1"}};
What I am trying to
achieve is a 3d bar chart with the date and time on the X-Axis, the
result on the Y-Axis and the tests, HGB and HCT on the Z-Axis. I can't
get it to work. What happens now is:
Each test (hgb and hct)
show up on a separate column with the date/time on the X-axis and the
result shows up on the Y-Axis. I can't get a Z-Axis with the two tests
on it.
My piece of code is below..
======================================
try
{
SqlCommand cmd = new SqlCommand(
"Select Count(*) " +
"From LabDB " +
"Where l.name in ('HGB', 'HCT') ",conn);
int arraySize = Convert.ToInt32(cmd.ExecuteScalar());
cmd.CommandText = "Select l.date as resultDate, " +
l.time as resultTime, " +
itemname = case " +
"when l.name = 'HGB' " +
"then 'Hemoglobin' " +
"when l.name = 'HCT' " +
"then 'Hematocrit' " +
"end, " +
"l.value as result " +
"From LabDB " +
"Where l.name in ('HGB', 'HCT') ",conn);
"Order by l.resultDate desc, itemname ";
SqlDataReader dr = cmd.ExecuteReader();
string [,] ptInfo = new string [arraySize, 4];
int i = 0;
if ( null != dr )
{
while (dr.Read() & i < arraySize)
{
ptInfo[i, 0] = dr["itemname"].ToString();
ptInfo[i, 1] = dr["resultDate"].ToString();
ptInfo[i, 2] = dr["resultTime"].ToString();
ptInfo[i, 3] = dr["result"].ToString();
axMSChart1.ChartData = ptInfo;
i += 1;
}
dr.Close();
}
}
=================================================
Can anyone help?
Thanks,
Tony