0
Answer

C# VS Web application error, problem with Interface implementation usage

Ask a question
Im really new one here, because I thought I`ll manage to solve any problem just by looking for them on these blogs but havent encautered anything similar, hence required help :
I got this C# code in one class:
public class PageLoad
    {
        public interface IPlotDataSource     // interface  that declares all the methods / properties I want a data source for the plot to have
        {


            List<ChartPoint> GetData(string[] tags, DateTime start, DateTime end);


        }


        public class RandomPlotDataSource : IPlotDataSource  // class which implements the interface that will generate random plot data
        {


            public List<ChartPoint> GetData(string[] tags, DateTime start, DateTime end)
            {
                List<ChartPoint> listDataSource = new List<ChartPoint>();
                int c =500;
                for (int i = 1; i < c; i++)
                {
                    listDataSource.Add(new ChartPoint(i, i));
                }


                return listDataSource;                
            }
        }


      /*  public class ProfecyPlotDataSource : IPlotDataSource    //a class that implements the interface that will retrieve the data from Profecy
        {
            public List<ChartPoint> GetData(string[] tags, DateTime start, DateTime end)
            {
                //query profecy for tag data here 
            }
             //return; 
        }*/


        public static void DoPlot(IPlotDataSource dataSource, string[] tags, DateTime start, DateTime end, Chart chart)  //plotting class
        {
            //my dataSource parameter can be an instance of any class that implements the IPlotDataSource
            //interface either an instance of RandomPlotDataSource or ProfecyPlotDataSource


            var points = dataSource.GetData(tags, start, end);


            var c = points.Count;


            var plottingTool = new PlottingTool();
            double colorCounter = 250;    // double can be null
            double step = colorCounter / c;
            foreach (var point in points)
            {
                plottingTool.AddNewSeries(point, chart, Color.FromArgb(Convert.ToInt32(colorCounter), Convert.ToInt32(colorCounter), Convert.ToInt32(colorCounter)));
                colorCounter -= step;
            }


            chart.Width = 800;
            chart.Height = 500;


            chart.ChartAreas["ChartArea1"].AxisX.Maximum = 700;
            chart.ChartAreas["ChartArea1"].AxisX.Minimum = 0;
            chart.ChartAreas["ChartArea1"].AxisX.Interval = 100;
            chart.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = false;


            chart.ChartAreas["ChartArea1"].AxisY.Maximum = 600;
            chart.ChartAreas["ChartArea1"].AxisY.Minimum = 150;
            chart.ChartAreas["ChartArea1"].AxisY.Interval = 50;
            chart.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = false;


            chart.ChartAreas["ChartArea1"].AxisX.Title = "Flow";
            chart.ChartAreas["ChartArea1"].AxisY.Title = "Total Head";


        }
    }




 this is the class which defines interface. and everything is fine with it , but then in my main class i try to call RandomPlotDataSource  to get my random x,y points and then pass it to function DoPlot with code below :


 public static void Page_Load(object sender, System.EventArgs e)
        {


            Pump_Monitor.PageLoad.IPlotDataSource datasource = new Pump_Monitor.PageLoad.RandomPlotDataSource();   //create a new instance
            datasource.GetData(tags, start, end);
            PageLoad.DoPlot(datasource, tags, start, end, chart);
       
        }




but nothing really happens.
Please any help will be apreciated.
Thank You , Neil.