示例#1
0
        public Form1()
        {
            InitializeComponent();
            double consumed = Math.Round(new ReadingRepository().getConsumedPower() / 1000 / 60, 2);
            label3.ForeColor = Color.Green;
            label3.Text = "Consumed power from generated electricity: " + consumed + "KW";
            double battery = new ReadingRepository().getBatteryHealth();
            string batteryString = "";
            if (battery >= 12)
            {
                batteryString = "Battery is Good";
                label4.ForeColor = Color.Green;
            }
            else
            {
                batteryString = "Check your battery, it needs charging, or else replaced";
                label4.ForeColor = Color.Red;
            }
            label4.Text = batteryString;

            //---------------------- Bar Graph ---------------------------------------
            populateBarchart(DateTime.Now, DateTime.Now);
        }
示例#2
0
        private void barGraph(DateTime startDate, DateTime endDate)
        {
            double meter1 = new ReadingRepository().getLowestMeterReadingValue(1, startDate, endDate);
            double meter2 = new ReadingRepository().getLowestMeterReadingValue(2, startDate, endDate);
            double meter3 = new ReadingRepository().getLowestMeterReadingValue(3, startDate, endDate);

            double tmeter1 = new ReadingRepository().getMetersSum(1, startDate, endDate);
            double tmeter2 = new ReadingRepository().getMetersSum(2, startDate, endDate);
            double tmeter3 = new ReadingRepository().getMetersSum(3, startDate, endDate);

            List<double> cmeter1 = new List<double>(), cmeter2 = new List<double>(), cmeter3 = new List<double>();

            cmeter1.Add(tmeter1);
            cmeter2.Add(tmeter2);
            cmeter3.Add(tmeter3);
            //Vertical bar chart
            //create another area and add it to the chart
            ChartArea area2 = new ChartArea();
            chart1.ChartAreas.Add(area2);

            //Create the series using just the y data
            Series barSeries1 = new Series();
            barSeries1.Points.DataBindY(cmeter1);
            barSeries1.LegendText = new ReadingRepository().getMeterByID(1);

            Series barSeries2 = new Series();
            barSeries2.Points.DataBindY(cmeter2);
            barSeries2.LegendText = new ReadingRepository().getMeterByID(2);

            Series barSeries3 = new Series();
            barSeries3.Points.DataBindY(cmeter3);
            barSeries3.LegendText = new ReadingRepository().getMeterByID(3);

            //Set the chart type, column; vertical bars
            barSeries1.ChartType = SeriesChartType.Column;
            barSeries2.ChartType = SeriesChartType.Column;
            barSeries3.ChartType = SeriesChartType.Column;

            // barSeries2.ChartArea = "Second";

            //Add the series to the chart
            chart1.Series.Add(barSeries1);
            chart1.Series.Add(barSeries2);
            chart1.Series.Add(barSeries3);
            label5.Text = checkPanels(meter1, meter2, meter3);
            label6.Text = checkEfficiency(meter1, meter2, meter3);
        }