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.
Expand|Select|Wrap|Line Numbers
- <%@ WebHandler Language="c#" Class="CapexMonitor.ChartGenerator_WebHandler" %>
- using System;
- using System.Web;
- using System.Drawing;
- using System.IO;
- using NPlot;
- namespace CapexMonitor
- {
- public class ChartGenerator_WebHandler : IHttpHandler
- {
- public void ProcessRequest(HttpContext context)
- {
- // create a new bitmap plotsurface on which to construct the chart.
- NPlot.Bitmap.PlotSurface2D plotSurface = new NPlot.Bitmap.PlotSurface2D(600, 360);
- //Months line
- System.Collections.ArrayList dates = new System.Collections.ArrayList();
- dates.Add("12");
- string[] sMonths = context.Request["months"].Split(Convert.ToChar(";"));
- int[] Months = new int[sMonths.Length];
- for (int i = 1; i < Months.Length; ++i)
- Months[i] =Convert.ToDateTime(sMonths[i]).AddMonths(6);
- string[] sContractors = context.Request["contractors"].Split(Convert.ToChar(";"));
- int[] contractors = new int[sContractors.Length];
- for (int i = 0; i < contractors.Length; ++i)
- contractors[i] = Convert.ToInt32(Math.Round(Convert.ToDouble(sContractors[i]), 0));
- // create a plot object for the data and add it to the plot surface.
- LinePlot lpContractors = new LinePlot();
- //Array.ForEach< <HttpRequest>
- lpContractors.DataSource = contractors;
- lpContractors.Color = Color.Yellow;
- lpContractors.Label = "Contract Est";
- //lpContractors.Shadow = true;
- lpContractors.Pen = new Pen(Color.Yellow, 2);
- //lpContractors.AbscissaData = sMonths;
- plotSurface.Add(lpContractors);
- //Forecast line
- string[] sForecast = context.Request["forecast"].Split(Convert.ToChar(";"));
- int[] Forecast = new int[sForecast.Length];
- for (int i = 0; i < Forecast.Length; ++i)
- Forecast[i] = Convert.ToInt32(Math.Round(Convert.ToDouble(sForecast[i]), 0));
- // create a plot object for the data and add it to the plot surface.
- LinePlot lpForecast = new LinePlot();
- lpForecast.DataSource = Forecast;
- lpForecast.Color = Color.Black;
- lpForecast.Label = "Forecast";
- //lpForecast.Shadow = true;
- lpForecast.Pen = new Pen(Color.Black, 2);
- //lpForecast.AbscissaData = dates;
- plotSurface.Add(lpForecast);
- //Actual Expenditure line
- string[] sActual = context.Request["actual"].Split(Convert.ToChar(";"));
- int[] Actual = new int[sActual.Length];
- for (int i = 0; i < Actual.Length; ++i)
- Actual[i] = Convert.ToInt32(Math.Round(Convert.ToDouble(sActual[i]), 0));
- // create a plot object for the data and add it to the plot surface.
- LinePlot lpActual = new LinePlot();
- lpActual.DataSource = Actual;
- lpActual.Color = Color.Red;
- lpActual.Label = "Actual";
- //lpActual.Shadow = true;
- lpActual.Pen = new Pen(Color.Red, 2);
- //lpActual.AbscissaData = dates;
- plotSurface.Add(lpActual);