Ver Mensaje Individual
  #1 (permalink)  
Antiguo 09/11/2007, 06:08
JocDev
 
Fecha de Ingreso: noviembre-2004
Ubicación: Asuncion - Paraguay
Mensajes: 155
Antigüedad: 19 años, 6 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;