Foros del Web » Programando para Internet » ASPX (.net) »

Grafico de Lineas Asp.Net

Estas en el tema de Grafico de Lineas Asp.Net en el foro de ASPX (.net) en Foros del Web. Necesito dibujar un grafico de lineas que me pueda mostrar la cotizacion de una moneda durante un mes entre 2 fechas asignadas al usuario. Probe ...
  #1 (permalink)  
Antiguo 09/11/2007, 06:08
 
Fecha de Ingreso: noviembre-2004
Ubicación: Asuncion - Paraguay
Mensajes: 155
Antigüedad: 19 años, 5 meses
Puntos: 0
Grafico de Lineas Asp.Net

Necesito dibujar un grafico de lineas que me pueda mostrar la cotizacion de una moneda durante un mes entre 2 fechas asignadas al usuario.
Probe con Office WebComponents 11 pero no me funciona si quiero mostrar mas de 19 fechas.

Código:
        List<string> xline = new List<string>();
        List<string> yline1 = new List<string>();
        List<string> yline2 = new List<string>();
        DateTime fecha;
        string sValor;
        foreach (DataRow row in ds.Tables[0].Rows)
        {
            DateTime.TryParse(row["Fecha"].ToString(), out fecha);
            xline.Add(fecha.ToString("dd/MM/yyyy"));

            sValor = row["Compra"].ToString();
            yline1.Add(sValor);
            sValor = row["Venta"].ToString();
            yline2.Add(sValor);           
        }

        xValues = xline.ToArray();
        y1Values = yline1.ToArray();
        y2Values = yline2.ToArray();

        ChartSpaceClass chtModel = new ChartSpaceClass();
        chtModel.Charts.Add(0);
        chtModel.Charts[0].Type = ChartChartTypeEnum.chChartTypeLineMarkers;
        chtModel.Charts[0].Overlap = 0;
        chtModel.AllowGrouping = true;
                
        ChSeries c = chtModel.Charts[0].SeriesCollection.Add(0);
        c.Caption = "Compra";        
        c.SetData(ChartDimensionsEnum.chDimCategories, Convert.ToInt32(ChartSpecialDataSourcesEnum.chDataLiteral),
            string.Join("\t", xValues));
        c.SetData(ChartDimensionsEnum.chDimValues, Convert.ToInt32(ChartSpecialDataSourcesEnum.chDataLiteral),
            string.Join("\t", y1Values));

        c = chtModel.Charts[0].SeriesCollection.Add(1);
        c.Caption = "Venta";
        c.SetData(ChartDimensionsEnum.chDimCategories, Convert.ToInt32(ChartSpecialDataSourcesEnum.chDataLiteral),
            string.Join("\t", xValues));
        c.SetData(ChartDimensionsEnum.chDimValues, Convert.ToInt32(ChartSpecialDataSourcesEnum.chDataLiteral),
            string.Join("\t", y2Values));        
        
        chtModel.Charts[0].Axes[0].NumberFormat = "dd/MM/yyyy";
        chtModel.Charts[0].Axes[1].NumberFormat = "##,###";

        chtModel.Charts[0].Axes[0].TickMarkUnitType = ChartAxisUnitTypeEnum.chAxisUnitDay;
                
        chtModel.Charts[0].SeriesCollection[0].DataLabelsCollection.Add();
        chtModel.Charts[0].SeriesCollection[0].DataLabelsCollection[0].HasValue = true;
        chtModel.Charts[0].SeriesCollection[0].DataLabelsCollection[0].NumberFormat = "#,###";
        chtModel.Charts[0].SeriesCollection[0].DataLabelsCollection[0].Font.Color = "Blue";
        chtModel.Charts[0].SeriesCollection[0].DataLabelsCollection[0].Font.Size = 7;

        chtModel.Charts[0].SeriesCollection[1].DataLabelsCollection.Add();
        chtModel.Charts[0].SeriesCollection[1].DataLabelsCollection[0].HasValue = true;
        chtModel.Charts[0].SeriesCollection[1].DataLabelsCollection[0].NumberFormat = "#,###";
        chtModel.Charts[0].SeriesCollection[1].DataLabelsCollection[0].Font.Color = "Red";
        chtModel.Charts[0].SeriesCollection[1].DataLabelsCollection[0].Font.Size = 7;
  #2 (permalink)  
Antiguo 09/11/2007, 07:34
 
Fecha de Ingreso: noviembre-2004
Ubicación: Asuncion - Paraguay
Mensajes: 155
Antigüedad: 19 años, 5 meses
Puntos: 0
Re: Grafico de Lineas Asp.Net

Por fin me salio aca esta.
Código:
 ChartSpaceClass chtModel = new ChartSpaceClass();
        ChChart chart = chtModel.Charts.Add(0);
        chart.Type = ChartChartTypeEnum.chChartTypeLine;        
        chart.Axes[ChartAxisPositionEnum.chAxisPositionCategory].GroupingType = ChartAxisGroupingEnum.chAxisGroupingNone;
       
        //Compra
        ChSeries serie = chart.SeriesCollection.Add(0);
        serie.Marker.Style = ChartMarkerStyleEnum.chMarkerStyleNone;
        //serie.Line.DashStyle = ChartLineDashStyleEnum.chLineSquareDot;
        serie.Caption = "Compra";        
        serie.SetData(ChartDimensionsEnum.chDimCategories, Convert.ToInt32(ChartSpecialDataSourcesEnum.chDataLiteral),
            string.Join("\t", xValues));
        serie.SetData(ChartDimensionsEnum.chDimValues, Convert.ToInt32(ChartSpecialDataSourcesEnum.chDataLiteral),
            string.Join("\t", y1Values));

       //Venta 
        serie = chart.SeriesCollection.Add(1);
        serie.Marker.Style = ChartMarkerStyleEnum.chMarkerStyleNone;
        serie.Caption = "Venta";
        serie.SetData(ChartDimensionsEnum.chDimCategories, Convert.ToInt32(ChartSpecialDataSourcesEnum.chDataLiteral),
            string.Join("\t", xValues));
        serie.SetData(ChartDimensionsEnum.chDimValues, Convert.ToInt32(ChartSpecialDataSourcesEnum.chDataLiteral),
            string.Join("\t", y2Values));

        chart.HasTitle = true;
        chart.Title.Caption = "Cotizacion de Moneda Periodo: " + fechaDesde.ToString("dd/MM/yyyy") + " al " + fechaHasta.ToString("dd/MM/yyyy");
        chart.HasLegend = true;
        chart.Legend.Position = ChartLegendPositionEnum.chLegendPositionBottom;
        chart.HasAutoAspectRatio = true;
        chart.HasAutoChartDepth = true;
        chart.Border.Color = "#FFFBF0";
        chart.PlotArea.Interior.Color = "#FFFBF0";
                        
        chart.SeriesCollection[0].DataLabelsCollection.Add();
        chart.SeriesCollection[0].DataLabelsCollection[0].HasValue = false;
        chart.SeriesCollection[0].DataLabelsCollection[0].NumberFormat = "#,###";
        chart.SeriesCollection[0].DataLabelsCollection[0].Font.Color = "Blue";
        chart.SeriesCollection[0].DataLabelsCollection[0].Font.Size = 7;

        chart.SeriesCollection[1].DataLabelsCollection.Add();
        chart.SeriesCollection[1].DataLabelsCollection[0].HasValue = false;
        chart.SeriesCollection[1].DataLabelsCollection[0].NumberFormat = "#,###";
        chart.SeriesCollection[1].DataLabelsCollection[0].Font.Color = "Red";
        chart.SeriesCollection[1].DataLabelsCollection[0].Font.Size = 7;

        chtModel.Charts[0].Axes[1].NumberFormat = "##,###";
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta

SíEste tema le ha gustado a 1 personas




La zona horaria es GMT -6. Ahora son las 08:07.