Ejemplo n.º 1
0
        /// <summary>
        /// Metodo de graficación.
        /// </summary>
        /// <returns></returns>
        public Chart Draw(params string[] filtros)
        {
            // Create a new instance of Chart
            Chart chart = new Chart();

            chart.AnimationEnabled = true;
            // Create a new instance of Title
            Title title = new Title();
            // Set title property
            title.Text = "Switch Selling Efectivo";
            // Add title to Titles collection
            chart.Titles.Add(title);
            // Create a new instance of DataSeries
            DataSeries dataSeries = new DataSeries();
            // Set DataSeries property
            dataSeries.RenderAs = RenderAs.Line;
            // Create a new instance of DataSeries
            DataSeries dataSeries2 = new DataSeries();
            // Set DataSeries property
            dataSeries2.RenderAs = RenderAs.Line;
            #region configuracion eje X
            // Creating AxisX
            Axis axisX = new Axis();
            // Date time standard format
            axisX.ValueFormatString = "000000";
            // To avoid auto skip

            chart.AxesX.Add(axisX);
            #endregion
            // Create a DataPoint
            DataPoint dataPoint;
            #region consulta
            DataTable kpis;
            try
            {
                kpis = new DataTable();
                Consultas consulta = new Consultas();
                kpis = consulta.SelectKPI_SwitchSellingEfectivo(filtros).Tables[0];
                consulta = null;
                foreach (DataRow g in kpis.Rows)
                {
                    long? y = g["NbrSwitchSellingEffect"]!=DBNull.Value?(long?)g["NbrSwitchSellingEffect"]:null;
                    long? y2 = g["NbrSwitchSelling"]!=DBNull.Value?(long?)g["NbrSwitchSelling"]:null;
                    long x = (long)g["TimeId"];
                    // Create a new instance of DataPoint
                    dataPoint = new DataPoint();
                    // Set YValue for a DataPoint
                    if (x != null) dataPoint.AxisXLabel = x.ToString();
                    if (!ciclos.Contains(x.ToString()))  ciclos.Add(x.ToString());
                    dataPoint.YValue = System.Convert.ToDouble(y);
                    // Add dataPoint to DataPoints collection.
                    dataSeries.DataPoints.Add(dataPoint);
                    dataSeries.Name = "SS Efectivos";
                    // Create a new instance of DataPoint
                    dataPoint = new DataPoint();
                    // Set YValue for a DataPoint
                    if (x != null) dataPoint.AxisXLabel = x.ToString();
                    if (!ciclos.Contains(x.ToString()))  ciclos.Add(x.ToString());
                    dataPoint.YValue = System.Convert.ToDouble(y2);
                    // Add dataPoint to DataPoints collection.
                    dataSeries2.DataPoints.Add(dataPoint);
                    dataSeries2.Name = "Switch Selling";
                    dataSeries.MarkerType = Visifire.Commons.MarkerTypes.Circle;
                    dataSeries.SelectionEnabled = true;
                    dataSeries.LineThickness = 3;
                    dataSeries2.MarkerType = Visifire.Commons.MarkerTypes.Circle;
                    dataSeries2.SelectionEnabled = true;
                    dataSeries2.LineThickness = 3;
                }
            }
            catch (Exception Error)
            {
                throw (new Exception(Error.ToString()));
            }
            #endregion
            if (kpis.Rows.Count != 0)
            {
                // Add dataSeries to Series collection.
                chart.Series.Add(dataSeries);
                chart.Series.Add(dataSeries2);
            }
            return chart;
        }