Esempio n. 1
0
 public ChartOptions()
 {
     XAxis          = new XAxis();
     YAxis          = new YAxis();
     Series         = new SerieCollection();
     Appearance     = new Appearance.Appearance();
     Lang           = new Localization();
     Exporting      = new Exporting();
     Colors         = new ColorSet();
     Legend         = new Legend();
     AjaxDataSource = new AJAXSource();
     Tooltip        = new ToolTip();
     ClientId       = "";
 }
        private void Display_ChargingStatus_Faults(Chargers Charger, int WeekNumer, int YearNumer)
        {
            GetChartData gd = new GetChartData();
            DataTable dataTable = gd.Ct_GetWeeklyChargingFails(Charger.ChargingStationID, WeekNumer, YearNumer);

            //  string mainTitle = string.Format("Vehicle Efficiency  - {0}", dt.ToString("MM/dd/yy"));
            //  string subTitle = string.Format("{0} - {1}", v.CustomerName, v.Vin);
            string mainTitle = Charger.Location.ToUpper().ToString() + " - Charger Fails";
            string subTitle = "Week Number " + WeekNumer + ", " + YearNumer;

            hcFrutas.Title = new Title(mainTitle);
            hcFrutas.SubTitle = new SubTitle(subTitle);

            hcFrutas.Theme = "grid";
            hcFrutas.Legend = new Legend { align = Align.right, layout = Layout.vertical, verticalAlign = VerticalAlign.top, x = -10, y = 70, borderWidth = 0 };
            hcFrutas.Appearance = new Appearance { renderTo = "container", animation = false };
            //   hcFrutas.YAxis.Add(new YAxisItem { title = new Title("Time Percentage") });

            //Get point collection
            var pointCollectionVinEfficiency = new PointCollection();
            var pointCollectionCat = new PointCollection();
            //var pointCollectionSocMax = new PointCollection();
            //var pointCollectionSocDas = new PointCollection();

            List<string> buckets = new List<string>();

            // Add string using Add method

            Int32 totalArraySize = dataTable.Rows.Count;
            Object[] XAxisData = new object[totalArraySize];
            Object[] YAxisServices = new object[totalArraySize];
            int J = 0;
            foreach (DataRow drRow in dataTable.Rows)
            {

                YAxisServices[J] = new object[] { drRow[0].ToString(), Convert.ToInt32(drRow[1].ToString()) };
                J += 1;
            }

            SerieCollection series = new SerieCollection();
            Serie serieServices = new Serie();
            serieServices.size = 150;
            // serieServices.cumulative = -0.25;
            serieServices.data = YAxisServices;
            serieServices.type = RenderType.pie;
            serieServices.name = "";
            serieServices.showInLegend = false;
            series.Add(serieServices);

            hcFrutas.PlotOptions = new Highcharts.Core.PlotOptions.PlotOptionsPie
            {
                allowPointSelect = true,
                cursor = "pointer",

                startAngle = 60,
                dataLabels = new Highcharts.Core.PlotOptions.DataLabels { enabled = true, formatter = "this.point.name +': ['+ this.y  + ']'" },
                animation = false
            };

            hcFrutas.Tooltip = new ToolTip("this.point.name +': '+ this.y ");
            hcFrutas.DataSource = series;
            hcFrutas.DataBind();
            hcFrutas.Dispose();
        }
        private void ReportServices_DailyGrab_GenVehicleData_VinSpeed(Vehicles v, DateTime dt)
        {
            GetChartData gd = new GetChartData();
            DataTable dataTable = gd.Dt_DailyGrab_GetSoC(v.VinID, dt, Rounding);

            string mainTitle = string.Format("Vin Speed Daily - {0}", dt.ToString("MM/dd/yy"));
            string subTitle = string.Format("{0} - {1}", v.CustomerName, v.Vin);
            hcVendas.Title = new Title(mainTitle);
            hcVendas.SubTitle = new SubTitle(subTitle);

            hcVendas.Theme = "grid";
            hcVendas.Legend = new Legend { align = Align.right, layout = Layout.vertical, verticalAlign = VerticalAlign.top, x = -10, y = 70, borderWidth = 0 };
            hcVendas.Appearance = new Appearance { renderTo = "container", animation = false };
            hcVendas.YAxis.Add(new YAxisItem { title = new Title("Speed in MPH") });

            hcVendas.XAxis.Add(new XAxisItem { type = AxisDataType.datetime, dateTimeLabelFormats = new DateTimeLabelFormats { hour = "%H" }, title = new Title("Time in Hours") });

            hcVendas.Tooltip = new ToolTip("Highcharts.dateFormat('%H:%M', this.x) +': '+ this.y");

            //Get point collection
            var pointCollectionVinSpeed = new PointCollection();
            var pointCollectionCharging = new PointCollection();
            var pointCollectionScoopHeater = new PointCollection();

            foreach (DataRow row in dataTable.Rows)
            {
                pointCollectionVinSpeed.Add(new Point(Convert.ToInt64((DateTime.Parse(row["Time_Occur"].ToString()).Subtract(new DateTime(2015, 1, 1))).TotalMilliseconds), Convert.ToDouble(row["PCpt_int_Spd_mph"])));
                pointCollectionCharging.Add(new Point(Convert.ToInt64((DateTime.Parse(row["Time_Occur"].ToString()).Subtract(new DateTime(2015, 1, 1))).TotalMilliseconds), Convert.ToDouble(row["PCes_usi_ChargeEnable_xx"])));
                pointCollectionScoopHeater.Add(new Point(Convert.ToInt64((DateTime.Parse(row["Time_Occur"].ToString()).Subtract(new DateTime(2015, 1, 1))).TotalMilliseconds), Convert.ToDouble(row["PCbo_bo_ScoopHeaterOn"])));
                // pointCollection.Add(new Point(DateTime.Parse(row["Time_Occur"].ToString()), Convert.ToDouble(row["SocMin"])));
            }

            //Add data to serie

            var series = new SerieCollection();

            series.Add(new Serie { id = "VinSpeed", name = "VinSpeed", type = RenderType.spline, data = pointCollectionVinSpeed.ToArray() });
            series.Add(new Serie { id = "Charging", name = "Charging", color = "red", type = RenderType.spline, data = pointCollectionCharging.ToArray() });
            series.Add(new Serie { id = "ScoopHeater", name = "ScoopHeater", type = RenderType.spline, data = pointCollectionScoopHeater.ToArray() });

            hcVendas.PlotOptions = new PlotOptionsLine { marker = new Marker { enabled = false }, dataLabels = new DataLabels { enabled = false } };

            // var series = new Collection<Serie> { new Serie { name = "VinSpeed", data = pointCollectionVinSpeed.ToArray(), type = RenderType.scatter }, new Serie { name = "Charging", type = RenderType.scatter, data = pointCollectionCharging.ToArray() }, new Serie { name = "ScoopHeater", type = RenderType.scatter, data = pointCollectionScoopHeater.ToArray() } };

            // hcVendas.PlotOptions = new PlotOptionsScatter { marker = new Marker { enabled = false }, dataLabels = new DataLabels { enabled = false } };

            //Bind the control
            hcVendas.DataSource = series;
            hcVendas.DataBind();
        }