473,507 Members | 2,441 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Graph code for Visual C#

1 New Member
Good day,

My name is Princess a jnr Programmer. I am busy trying to do a graph using Visual C#, I am really new at this. Can someone assist me, the graph derive its context from a web page, the web page has 6 records. The graph displays only the 6 records in the X-axis,
  • l will like to know how can l display extra 6 empty records when I am using a ArrayList, and
  • how do l get the graph plotting to start from zero.
Here is what I have already done, my suggetsted yet wrong attempt answers are in bold (with this added, when i refresh the web page, the graph does not appear anymore):

Expand|Select|Wrap|Line Numbers
  1. <%@ WebHandler Language="c#" Class="CapexMonitor.ChartGenerator_WebHandler" %>
  2.  
  3. using System;
  4. using System.Web;
  5. using System.Drawing;
  6. using System.IO;
  7. using NPlot;
  8.  
  9. namespace CapexMonitor
  10. {
  11.     public class ChartGenerator_WebHandler : IHttpHandler
  12.     {
  13.         public void ProcessRequest(HttpContext context)
  14.         {
  15.             // create a new bitmap plotsurface on which to construct the chart.
  16.             NPlot.Bitmap.PlotSurface2D plotSurface = new NPlot.Bitmap.PlotSurface2D(600, 360);
  17.  
  18.  
  19.             //Months line
  20.             System.Collections.ArrayList dates = new System.Collections.ArrayList();
  21.            dates.Add("12");
  22.             string[] sMonths = context.Request["months"].Split(Convert.ToChar(";"));
  23.       int[] Months = new int[sMonths.Length];
  24.  
  25.             for (int i = 1; i < Months.Length; ++i)
  26. Months[i] =Convert.ToDateTime(sMonths[i]).AddMonths(6);
  27. string[] sContractors = context.Request["contractors"].Split(Convert.ToChar(";"));
  28.             int[] contractors = new int[sContractors.Length];
  29.  
  30.             for (int i = 0; i < contractors.Length; ++i)
  31.                 contractors[i] = Convert.ToInt32(Math.Round(Convert.ToDouble(sContractors[i]), 0));
  32.  
  33.             // create a plot object for the data and add it to the plot surface.
  34.             LinePlot lpContractors = new LinePlot();
  35.             //Array.ForEach< <HttpRequest> 
  36.             lpContractors.DataSource = contractors;
  37.             lpContractors.Color = Color.Yellow;
  38.             lpContractors.Label = "Contract Est";
  39.             //lpContractors.Shadow = true;
  40.             lpContractors.Pen = new Pen(Color.Yellow, 2);
  41.           //lpContractors.AbscissaData = sMonths;
  42.             plotSurface.Add(lpContractors);
  43.  
  44.             //Forecast line
  45.             string[] sForecast = context.Request["forecast"].Split(Convert.ToChar(";"));
  46.             int[] Forecast = new int[sForecast.Length];
  47.             for (int i = 0; i < Forecast.Length; ++i)
  48.                 Forecast[i] = Convert.ToInt32(Math.Round(Convert.ToDouble(sForecast[i]), 0));
  49.  
  50.             // create a plot object for the data and add it to the plot surface.
  51.             LinePlot lpForecast = new LinePlot();
  52.             lpForecast.DataSource = Forecast;
  53.             lpForecast.Color = Color.Black;
  54.             lpForecast.Label = "Forecast";
  55.             //lpForecast.Shadow = true;
  56.             lpForecast.Pen = new Pen(Color.Black, 2);
  57.             //lpForecast.AbscissaData = dates;
  58.             plotSurface.Add(lpForecast);
  59.  
  60.             //Actual Expenditure line
  61.             string[] sActual = context.Request["actual"].Split(Convert.ToChar(";"));
  62.             int[] Actual = new int[sActual.Length];
  63.             for (int i = 0; i < Actual.Length; ++i)
  64.                 Actual[i] = Convert.ToInt32(Math.Round(Convert.ToDouble(sActual[i]), 0));
  65.  
  66.             // create a plot object for the data and add it to the plot surface.
  67.             LinePlot lpActual = new LinePlot();
  68.             lpActual.DataSource = Actual;
  69.             lpActual.Color = Color.Red;
  70.             lpActual.Label = "Actual";
  71.             //lpActual.Shadow = true;
  72.             lpActual.Pen = new Pen(Color.Red, 2);
  73.             //lpActual.AbscissaData = dates;
  74.             plotSurface.Add(lpActual);
  75.  
Feb 5 '08 #1
0 2740

Sign in to post your reply or Sign up for a free account.

Similar topics

25
3758
by: Magnus Lie Hetland | last post by:
Is there any interest in a (hypothetical) standard graph API (with 'graph' meaning a network, consisting of nodes and edges)? Yes, we have the standard ways of implementing graphs through (e.g.)...
0
2329
by: Angela | last post by:
I am using VS.NET 2003 and Crystal 9. I have been told by Crystal, as well as many co-workers who know Crystal really well, that I cannot create the particulat graph I need using Crystal Reports....
38
2889
by: Charles Law | last post by:
Am I going mad, or is there no control in .NET that will allow me to display a simple graph of a series of points held in an array? Please tell me I'm wrong. Charles
4
3085
by: enigma261 | last post by:
Hello, I am looking for graph layout algorithms. I am representing a process flow using a graph. I have the visual representation of nodes and connectors. I would like to use a graph layout...
1
1941
by: Sharon | last post by:
(Frustratingly), after unsuccessfully trying to use a picturebox control to paint a line graph based on serial communications with a remote device, it seems picturebox controls just won't work for...
1
4215
by: KPOJonesECC | last post by:
I am currently working on creating a visual calculator in an access form. The visual bit being a graph and the interactive bit (or what I would like) being that by moving sliders on a series of sub...
1
2072
by: gihope | last post by:
Hi, I wonder if someone could help me. I'm trying to develop a search algorithm as I need an engine that can determine the shortest route between two locations based on the number of stops. I...
2
4120
by: sriniwas | last post by:
Hi Frnd's, m using prefuse visulation,it's have one display class and this class have one saveImage(outPutStream, String jpg,double size);. now graph is converting ia jpg image properly.now my...
3
4690
by: The Frog | last post by:
Hi guys, I have never touched really on this area before with forms and reports, and now I would like to be able to incorporate some graphs / charts for a new little app I am building, and I...
0
7223
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7111
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7319
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7376
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7031
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
4702
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1542
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
760
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.