Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 10th, 2007, 07:33 PM
Authorized User
 
Join Date: Sep 2006
Posts: 73
Thanks: 6
Thanked 0 Times in 0 Posts
Default MS Chart Question

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





Similar Threads
Thread Thread Starter Forum Replies Last Post
Trigger question for columns with text in MS sql s robtay SQL Server 2000 1 November 12th, 2006 03:21 PM
Create Excel.Chart and Save to MS Access OLE Obj kirkgomez Access VBA 1 December 29th, 2005 08:27 AM
Question on MS SharePoint Portal Server boksi .NET Web Services 0 March 17th, 2005 05:28 PM
VB App creating an Area Chart in MS Word mbyndas VB How-To 0 September 30th, 2003 08:18 AM
Drill Down from Bar Chart to another chart snowbird Crystal Reports 0 July 11th, 2003 01:53 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.