Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
|
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 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 March 5th, 2008, 05:40 PM
Friend of Wrox
 
Join Date: Sep 2007
Posts: 169
Thanks: 7
Thanked 2 Times in 2 Posts
Default Need Help Making Charts.

Hi

I want to make some charts in C# and then display them on the web through asp.net

The chart I want to make is a bar chart that is stacked. For example I will have 3 fields.

Say they are a,b,c

So how this would look is a and b would be on top of each other where c would be alone right beside it.

I would be getting the values from a database so the data would always be different and static.

With this being said I don't even know where to begin to start and do this.

Thanks

 
Old March 5th, 2008, 05:57 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

You have a few of options, 2 of which I have used.

GDI+: This requires certain proficiency with GDI (obviously) but you could conceivably draw your charts based upon a given equation in your code. This actually isn't as hard as it sounds and have employed it in the past.

RDL(C) Files (Reports): Similar to Crystal or SQL Server Reporting Services. This is less intensive then GDI though it requires you to learn how to work with these report files, datasets, parameters, etc.

Dundas Charts: 3rd party component. I have never worked with it but from what I hear it is pretty comprehensive, albeit not free.

hth.

-Doug

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor / Author :.
Wrox Books 24 x 7
================================================== =========
 
Old March 5th, 2008, 06:22 PM
Friend of Wrox
 
Join Date: Sep 2007
Posts: 169
Thanks: 7
Thanked 2 Times in 2 Posts
Default

Quote:
quote:

 You have a few of options, 2 of which I have used.

GDI+: This requires certain proficiency with GDI (obviously) but you could conceivably draw your charts based upon a given equation in your code.��This actually isn't as hard as it sounds and have employed it in the past.

RDL(C) Files (Reports): Similar to Crystal or SQL Server Reporting Services.��This is less intensive then GDI though it requires you to learn how to work with these report files, datasets, parameters, etc.

Dundas Charts: 3rd party component.��I have never worked with it but from what I hear it is pretty comprehensive, albeit not free.

hth.

-Doug

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor / Author :.
Wrox Books 24 x 7
================================================== =========
Hmm both sound very interesting. I am not interested in "Dundas Charts" or any other chartings ones. Since my site is not going to be making any money really(if it does it probably be just enough to cover hosting costs).

So that gets rid of most of them since they all cost money and quite a bit.

I know there are some free charting ones but none of them have the kind of chart I want and are not very flexible and have poor documentation.

So I think I should learn how to do them myself. I get good learning experience from doing it.

So I am not sure which option would be better. I might do both but first I should start one at a time.

So which one should I do first?

Since you say you done both can you help me get started and stuff? Like where do I get tutorials from and how do I get started with them?

Thanks

Edit

On a side note with RDL you said it is similar to SQL Server Reporting Services. I was under the impression that it could not handle making dynamic charts. Like when I watched SQL Server Reporting video it seemed like you had to hard code the data in and then display it.

That would cause me problems since what my charts are going to do is they will be customized for each user and change change depending on what options what they want.

Like each user will be able to view the charts in 3 different views. Monthly,Weekly and Daily.

The data what will be displayed on the charts are correct,assistance needed, and wrong.

So as they do more quiz's the data will change for the charts and depending on the user.

So I don't know if this will cause any problems with this RDL stuff.

So I made a chart of how I want it too look like. The colors I just choose at random but thats all look and feel what would happen at the end.

http://img217.imageshack.us/img217/9...artcopyxe1.jpg

So Heres what happening.


In the top I just wanted to stress that each chart is dependent on who the user is(of course in the chart I wont' show this "Weekly View - For User 0000-0000-0000-000")

See I will have a dropdown list with

Weekly View
Daily View
Month View

When the user clicks on any of them I will grab there UserID(the one they where given when they signed up for an account).

Once I have grabbed there UserID I will look at what View they want and call a stored procedure that will do a certain query depending on which View they choose.

I have almost finished the stored procedure. The only thing it does not do is display the range dates. Otherwise it grabs all the right data and stuff.

On the left there are numbers(I was not sure what to call this) and basically it just so they can look at it and find how many correct they got, wrong they got and assistance needed.

As you can see assistance needed is on top of correct basically the formula is.

Correct - Assistance needed.

So if they had 10 correct and 5 Assistance needed.

The chart would show correct and 5 and assistance needed on top of it as another 5.

This is done since assistance needed when clicked in the quiz gives you the answer. They then have to type it in to get to the next question so they get that as correct when really they needed help.

Finally on the bottom is just showing the user what range of data that the chart goes from.

So I hope now we both are on the same page and we can decide which options I can use and how to proceed.

I been looking up this GDI and I am wondering can I use this with on a a "website"(file-new-website)

Or is this only for windows applications?
 
Old March 5th, 2008, 07:45 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Let me keep my post in context. I am a web developer by trade and, based on your comments about hosting fees and site, I assume that is the medium you are targeting as well.

First in so far as me helping you, yes I can help you but only so far as problems you post here on the forum, I don't have time to give you one on one training.

Where you want to start is completely up to you but ultimately you will be heading to google! =]

GDI: This option is the most flexible but also the most involved. For example in my particular application the numbering of the chart never changed (the values along the right side) but the numbering across the bottom did. So what I did was I created a bitmap in photoshop of a blank chart and then drew on top of that bitmap with the GDI classes at run time to generate my final image and then added the necessary text across the bottom. This obviously saved me a bit of work since I already had a source bitmap to draw on. From the image you provided in your post it is not clear if you would benifit (of if its plausable) from doing something like this.

RDLC: Your chart will always be based off the data from your dataset. Bare in mind there is a difference between an RDL (Server) report and an RDLC (Client) report. In the case of the latter the report is generated at the client and there is no connection to the Reporting Service and I think this article will help you along: http://www.koffeekoder.com/ArticleDetails.aspx?id=339

Does this help you?

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor / Author :.
Wrox Books 24 x 7
================================================== =========
 
Old March 5th, 2008, 09:25 PM
Friend of Wrox
 
Join Date: Sep 2007
Posts: 169
Thanks: 7
Thanked 2 Times in 2 Posts
Default



I was thinking more of the lines of if you know any good tutorials that can help me get started.

I been looking at gdi and I everything I found so far seems to only be with windows applications not websites.

Like I was looking at this "practical C# graphs and charts" books sample chapter and they talk about using the GDI but there stuff works only for windows applications like for instance in the book they tried to override the OnPaint method but when I tried to do that in the website it just came back with errors.

So I am probably not using the right search stuff.

I also been looking at that link you gave with the Reporting and I can see what you mean its not as flexible. I think I will have to use the GDI since they don't have the graph I want and I did not see where I can change it.

With that said though I am want to fully understand how to use it since I can see myself using this for other thing. Like if I got to make a simple bar chart this makes it pretty straight forward and faster to do then writing it by hand.

So I got some questions about that.

Question 1.

When you are in the rdlc design mode you can click on the chart and all these new field come up like(Drop category field Here,etc - See you link Figure-7 for all the other fields).

So what do you put in these fields? I don't really get the purpose of them.

Question 2.

In STEP 2. Creating an rdlc file

step 2.5

" So under the Web Data Sources, Find the DataSet that you have just created earlier and drag the fields that you want to display into a specific area. Just be careful in locating a data field into the chart. The data field should fit on each area to get the proper result."

I can't find this Web Data Sources and I am not really sure what there talking about(I am using vs2008 don't know if that makes a difference).

Question 3.

I don't get how to take my data from my database and bind it together.

Like when I set it up I used "use existing stored procedure".

Now I am not sure how to bind my stored procedure data to the graph.

Like I used stored procedures before but not sure how to do the data binding it to the report.

There code does not make too much sense to me since they don't show all there code and its different from mine and all the drop list methods are useless to be since mine are hardcoded in and not coming from a database.

This is what done so far.

1. I made a DataSet1.xsd
2. dragged in a table adaptor
3. chose my datasource
4. chose "use existing stored procedure"
5. Under the select column I choose my stored procedure and hit next
6. left "fill a data table" and "return a datatable" checked
7. added a report file.
8. added a chart(left all default stuff on)
9. went to my default.aspx page and added a dropdownlist and MicrosoftReportViewer onto the page.
10. hardcoded values for the dropdownlist
11. Went to code behind and wrote this so far


Code:
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page 
{
    Guid providerUserKey;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (User.Identity.IsAuthenticated == true)
        {
            MembershipUser mu = Membership.GetUser();
            providerUserKey = (Guid)mu.ProviderUserKey;
        }
    }
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
       string option = DropDownList1.SelectedValue;
       makeChart(option);
    }
    protected void makeChart(string option)
    {
        SqlCommand newcommand = new SqlCommand("getChartInfo", getConnection());
        newcommand.CommandType = CommandType.StoredProcedure;

        newcommand.Parameters.Add("@UserID", SqlDbType.UniqueIdentifier);
        newcommand.Parameters["@UserID"].Value = providerUserKey;

        newcommand.Parameters.Add("@option", SqlDbType.VarChar);
        newcommand.Parameters["@option"].Value = option;

        newcommand.Connection.Open();
        newcommand.ExecuteNonQuery();

        /* probably would have to do some reader here or something to read out the data */


        newcommand.Connection.Close();

    }
    protected SqlConnection getConnection()
    {
        /* Declares the connections for the database */
        SqlConnection conn;
        /*Grabs the connection string */
        string connectionString = ConfigurationManager.ConnectionStrings["Japanese"].ConnectionString;
        conn = new SqlConnection(connectionString);
        return conn;
    }

}
Now I am stuck I am not sure how to do the binding.

Here is my stored procedure.

Code:
ALTER PROCEDURE [dbo].[getChartInfo]
(
    @UserID uniqueidentifier,
    @option varchar(10)
)
AS
BEGIN
IF @option = 'months'
    BEGIN
        SELECT userID, SUM(Correct) AS CORRECT, SUM(Wrong) as Wrong, SUM(AssitanceNeeded) AS AssitanceNeeded
        FROM Charts
        WHERE TimeDateStamp between
        dateadd(month, -11, DATEADD(mm, DATEDIFF(mm,0,getdate()), 0))
        AND
        dateadd(ss,-1, DATEADD(mm, DATEDIFF(mm,0,getdate()) + 1, 0)) 
        GROUP BY UserID, month(TimeDateStamp)
    END
IF @option = 'weeks'
    BEGIN
        SELECT UserID,DATEDIFF(d,TimeDateStamp,getdate())/7 AS WeekNo,SUM(Correct) AS Correct,SUM(Wrong) AS Wrong,SUM(AssitanceNeeded) AS AssitanceNeeded
        FROM Charts
        WHERE TimeDateStamp >= DATEADD(d,-27,DATEDIFF(d,0,getdate())) AND TimeDateStamp <= getdate() AND UserID = @UserID 
        GROUP BY UserID,DATEDIFF(d,TimeDateStamp,getdate())/7, day(TimeDateStamp) 
        ORDER BY DATEDIFF(d,TimeDateStamp,getdate())/7 DESC
    END
IF @option = 'day'
    BEGIN
        SELECT userID, SUM(Correct) AS CORRECT, SUM(Wrong) as Wrong, SUM(AssitanceNeeded) AS AssitanceNeeded, day(TimeDateStamp)
        FROM Charts
        WHERE TimeDateStamp 
        BETWEEN DATEADD(d,-7,DATEDIFF(d,0,getdate() + 1))
        AND
        DATEADD(ss,-1,DATEADD(d,DATEDIFF(d,0,getdate())+ 1 , 0))
        GROUP BY UserID,day(TimeDateStamp)
    END
END
 
Old March 5th, 2008, 09:59 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

I just saw this and am getting ready to turn in for the night so I will answer your questions more directly tomorrow.

With regard to GDI, there wasn't a tutorial that I followed to create the graph code that I used in my application. For some tutorials on working with GDI in webforms take a look here: http://www.google.com/search?hl=en&q=asp.net+-+GDI%2B

I will give you a more elaborate answer tomorrow.

-Doug

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor / Author :.
Wrox Books 24 x 7
================================================== =========
 
Old March 6th, 2008, 09:46 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Ok, I can support the link that I sent you as it was wrote by someone other than myself so anything directly related to that, you will need to try to get ahold of the person that wrote the article.

1. Category Fields: from your image this would be the dates. Series Fields: This would be the legend from your image. Data Fields: obviously the values you want to represent.

2.In VS2K8 I am not sure if the DataSource pane appears or not. In VS2K5 when I open a report file, the data source pane automatically appears for me. Based on the MSDN documentation found here: http://msdn2.microsoft.com/en-us/library/ms252123.aspx this should also happen in 2K8


3. This code binds data to the report:
        //A method that populates the ReportViwer control
        StocksCls result = new StocksCls ();
        DataTable dt = result.getItemsPerCategory(DropDownList1.SelectedI tem.Text);
        ReportDataSource rds = new ReportDataSource("DataSet1_DataTable1", dt);
        ReportViewer1.LocalReport.DataSources.Clear();
        ReportViewer1.LocalReport.DataSources.Add(rds);
        ReportViewer1.LocalReport.Refresh();

You will need to fill the DataTable with the data you want passed to the report this well then bind data to your report.

hth.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor / Author :.
Wrox Books 24 x 7
================================================== =========
 
Old March 6th, 2008, 04:31 PM
Friend of Wrox
 
Join Date: Sep 2007
Posts: 169
Thanks: 7
Thanked 2 Times in 2 Posts
Default

Quote:
quote:Originally posted by dparsons
 Ok, I can support the link that I sent you as it was wrote by someone other than myself so anything directly related to that, you will need to try to get a hold of the person that wrote the article.

1. Category Fields: from your image this would be the dates. Series Fields: This would be the legend from your image. Data Fields: obviously the values you want to represent.

2.In VS2K8 I am not sure if the DataSource pane appears or not. In VS2K5 when I open a report file, the data source pane automatically appears for me. Based on the MSDN documentation found here: http://msdn2.microsoft.com/en-us/library/ms252123.aspx this should also happen in 2K8


3. This code binds data to the report:
        //A method that populates the ReportViwer control
        StocksCls result = new StocksCls ();
        DataTable dt = result.getItemsPerCategory(DropDownList1.SelectedI tem.Text);
        ReportDataSource rds = new ReportDataSource("DataSet1_DataTable1", dt);
        ReportViewer1.LocalReport.DataSources.Clear();
        ReportViewer1.LocalReport.DataSources.Add(rds);
        ReportViewer1.LocalReport.Refresh();

You will need to fill the DataTable with the data you want passed to the report this well then bind data to your report.

hth.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor / Author :.
Wrox Books 24 x 7
================================================== =========
I am still confused with number 1. Like

"Category Fields: from your image this would be the dates. Series Fields: This would be the legend from your image. Data Fields: obviously the values you want to represent."

So say for category Fields I want to put dates in there. How do I bind it to this? Like I won't know the dates until later on after they chosen an option and other information. So I have to do this I guess in code behind.

Not sure if you can do that in code behind or how.

For Series Fields. Would I cut out my legend out and paste the image in there. Or do I have to make this in code behind too?


For Data Fields are you talking about the actual content that will get binded later on from my database.

I still don't get this piece of code

        //A method that populates the ReportViwer control
        StocksCls result = new StocksCls ();
        DataTable dt = result.getItemsPerCategory(DropDownList1.SelectedI tem.Text);
        ReportDataSource rds = new ReportDataSource("DataSet1_DataTable1", dt);
        ReportViewer1.LocalReport.DataSources.Clear();
        ReportViewer1.LocalReport.DataSources.Add(rds);
        ReportViewer1.LocalReport.Refresh();

/* I do not have my own class so this does nothing for me*/
StocksCls result = new StocksCls ();

/* This seems to be using a method from the above class. So this is
useless to be since again no class and my DDL stuff is hardcoded */
DataTable dt = result.getItemsPerCategory(DropDownList1.SelectedI tem.Text);

/* this I sort of get. I think this is finding the DataSet and binding it with the DDL. Not sure how where they got DataTable1 from.*/
ReportDataSource rds = new ReportDataSource("DataSet1_DataTable1", dt);

/* makes sure that the one of the page is cleared */
ReportViewer1.LocalReport.DataSources.Clear();
/* adds the new stuff on it */
ReportViewer1.LocalReport.DataSources.Add(rds);
/* refreshes the viewer */
ReportViewer1.LocalReport.Refresh();

Now with me I don't know I am going to get all the values and bind them together. I thinking I have to use the dataReader after my SP goes off and filters all the rows. But its what I have to do in the dataReader to bind them to the controls is what I am confused on.

 
Old March 6th, 2008, 04:41 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

You need to realize that the person that wrote that article did not intend for it to be a canned solution.

/* I do not have my own class so this does nothing for me*/
StocksCls result = new StocksCls ();

/* This seems to be using a method from the above class. So this is
useless to be since again no class and my DDL stuff is hardcoded */
DataTable dt = result.getItemsPerCategory(DropDownList1.SelectedI tem.Text);

While you do not have a class that exposes the above method, I am sure you have some sort of code that goes to the database, gets values, and returns them back to your app. That is what hte above code is demonstrating. The datatable should be filled with the results from the stored procedure that you used to create the DataSet. You then provide that datatable to the Report which then takes the data and binds it to the necessary places within the report.

So the report handles the Binding as long as you provide it the data.

In so far as the field question goes, no, all you would need to do is provide fields from you datasource that represent these elements and the report itself would handle generating it.

-Doug

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor / Author :.
Wrox Books 24 x 7
================================================== =========
 
Old March 7th, 2008, 03:50 AM
Friend of Wrox
 
Join Date: Sep 2007
Posts: 169
Thanks: 7
Thanked 2 Times in 2 Posts
Default

We will come back to Reporting since I am still confused with it but it won’t help me out for what I want to do currently want to do. Even though I want to come back to this later on since this is will be very useful in the future for me(a lot easier making standard charts then GD+).

I also think this will help see why I might be confused since it shows how I usually do get values out of a database and use them.

So I been going through some tutorials and I come up with this:

http://img160.imageshack.us/my.php?image=chartvh2.jpg

So this is how my day view would look like.

This is where you get the last 7 days back. I also have a weekly view (you would see 4 groups of these columns) and monthly where you basically see the last 12 months or 12 groups of columns.

So now for my problems

1. I am having problems with figuring away to resize my columns when I get to much data.

Like for example

04/03/08 on the picture(4) has this Correct= 500, Wrong = 100, assistance = 100;

If you look you won’t see any asstiance at all since my column went off the chart.

So I need away to resize the columns so they look good. Like I just can’t think if a way. At first I though well if it goes over a certain number I will divide it all my 10 but then I run into trouble that my other groups will be too small.

Like if you look 05/03/08 on the picture(5). It would be small you might not even be able to see much of it if I divided it by ten.

2. My second problem is how do I make a scale that will be relevant to the size of the columns. Like for instance one week a user could have done tons of quiz’s and go high numbers like 500 so I need the scale to go up by like 50 but then the next week the guy could have only got numbers in the 50’s so then the scale would have to be by 5’s.

These are my 2 main problems right now. I got other problems but these are the mega ones that need to be dealt with first.

Here my code.

Code:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Drawing;
using System.Drawing.Imaging;
using System.Data.SqlClient;
using System.Drawing.Drawing2D;
using System.Drawing.Text;

public partial class _Default : System.Web.UI.Page
{


    Guid providerUserKey;

    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        /* dropdown with my options in */
        string option = DropDownList1.SelectedValue;
        makeChart(option);
    }
    protected void makeChart(string option)
    {
        /* stored procedure */
        SqlCommand newcommand = new SqlCommand("getChartInfo", getConnection());
        newcommand.CommandType = CommandType.StoredProcedure;

        SqlDataReader newReader;


        newcommand.Parameters.Add("@UserID", SqlDbType.UniqueIdentifier);
        newcommand.Parameters["@UserID"].Value = providerUserKey;

        newcommand.Parameters.Add("@option", SqlDbType.VarChar);
        newcommand.Parameters["@option"].Value = option;

        newcommand.Connection.Open();
        newcommand.ExecuteNonQuery();
        newReader = newcommand.ExecuteReader();


        Bitmap myImage;

        /* make my Bitmap 800 by 600 */
        myImage = new Bitmap(800, 600);

        // Get the graphics context for the bitmap.
        Graphics objGraphics = Graphics.FromImage(myImage);


        // Make sure you do not have          
        // smoothing problems
        objGraphics.SmoothingMode = SmoothingMode.HighQuality;
        objGraphics.TextRenderingHint = TextRenderingHint.AntiAlias;


        /* make sure the graph is white */
        objGraphics.Clear(Color.White);


        /* make my brushes one for each column */
        Brush blue = new SolidBrush(Color.Blue);
        Brush red = new SolidBrush(Color.Red);
        Brush green = new SolidBrush(Color.Green);

        int increment = 0;
        while (newReader.Read() == true)
        {
            /* go through and get the results from the SP */
            int correct = Convert.ToInt32(newReader["CORRECT"]);
            int wrong = Convert.ToInt32(newReader["Wrong"]);
            int assitance = Convert.ToInt32(newReader["AssitanceNeeded"]);
            string date = newReader["TimeDateStamp"].ToString();

            /* send it to be drawn */
            DrawBar(objGraphics, correct, wrong, assitance, date, increment, blue, red, green);
            increment++;
        }

        /* make it a jpg so it can be seen */
        Response.ContentType = "image/jpeg";

        /* saves it as Jpeg */
        myImage.Save(Response.OutputStream, ImageFormat.Jpeg);

    }
    protected SqlConnection getConnection()
    {
        /* Declares the connections for the database */
        SqlConnection conn;
        /*Grabs the connection string */
        string connectionString = ConfigurationManager.ConnectionStrings["Japanese"].ConnectionString;
        conn = new SqlConnection(connectionString);
        return conn;
    }
    private void DrawBar(Graphics objGraphics, int correct, int wrong, int assitance, string date,
        int BarNumber, Brush brush1, Brush brush2, Brush brush3)
    {
        /* find out how much real correct answers they got(IE how many they did not need help on */
        int newCorrect = correct - assitance;

        /* spaceing from the left */
        int intLeft = (BarNumber * 80) + 70;
        /* where the bottom is */
        int intBottom = 500;
        /* find out how high to make it */
        int intHeight = (2 * newCorrect); 

        /* draw the corret column bar */
        objGraphics.FillRectangle(brush1, intLeft, intBottom - intHeight, 25, intHeight);


        /* figured out the new bottom */
        intBottom = intBottom - intHeight;

        /* set the height for the next bar */
        intHeight = (1 * assitance);

        /* draw the bar */
        objGraphics.FillRectangle(brush3, intLeft,intBottom, 25, intHeight);


        /*  set up everything for the wrong bar */
        intLeft = ((BarNumber + 1) * 80) + 25;
        intBottom = 500;
        intHeight = (1 * wrong);


        /* draw the wrong bar */
        objGraphics.FillRectangle(brush2, intLeft, intBottom - intHeight, 25, intHeight);


        /* get the dates that will be drawn under the horizontal line */
        objGraphics.DrawString(date, new Font("Verdana", 8, FontStyle.Bold), Brushes.Black,this.Temp, 500);

        /* set the next dates postion */
        this.Temp = this.Temp + 90;

        /* set the veritical scale */
        objGraphics.DrawString("1000", new Font("Verdana", 8, FontStyle.Bold), Brushes.Black, 0,  480);


        // Draw the vertical line
        objGraphics.DrawLine(Pens.Brown, 40, 10, 40, 500);

        // draws the horizontal line
        objGraphics.DrawLine(Pens.Brown, 20, 501, 800, 501);    
    }

    /* get and set property */
    protected int holdKey = 90;
    protected int Temp
    {
        get
        {
            return holdKey;
        }
        set
        {
            holdKey = value;
        }
    }


}






Similar Threads
Thread Thread Starter Forum Replies Last Post
charts MunishBhatia ASP.NET 2.0 Professional 0 May 28th, 2007 11:52 AM
about charts MunishBhatia ASP.NET 2.0 Professional 1 May 11th, 2007 05:40 AM
Charts in Access lryckman Access VBA 5 December 11th, 2006 09:17 AM
charts s_gh Excel VBA 1 May 31st, 2006 09:53 AM
OWC making Excel with bar charts mondayisgreat Classic ASP Components 0 March 2nd, 2006 02:24 PM





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