c#使用timeXaxis来制作时间与数据的图表(超级图表:inffragistics)

本文关键字:inffragistics 数据 timeXaxis 使用 时间 | 更新日期: 2023-09-27 18:15:53

我想用ultrachart, inffragistics来做一个数据的时间函数图。

我找到了这个样本:DataTable Recap = MarketData.Tables.Add("Recap");

        // on ajoute des column a recap ne pas oublier de typer les colonnes
        Recap.Columns.Add("Date", typeof(DateTime));
        Recap.Columns.Add("Move Ticker price", typeof(double));
        Recap.Columns.Add("Move Index price", typeof(double));
        Recap.Columns.Add("Alpha",typeof (double));

        // on remplie recap
        for (int i = 0; i < TickerPrice.Rows.Count; i++)
        {
            DataRow destRow = Recap.NewRow();
            destRow["Move Ticker price"] = TickerPrice.Rows[i]["CHG_PCT_1D"];
            destRow["Move Index price"] = IndexPrice.Rows[i]["CHG_PCT_1D"];
            destRow["Date"] = TickerPrice.Rows[i]["Date"];
            Recap.Rows.Add(destRow);
        }
        // calcul du alpha
        foreach (DataRow dr in Recap.Rows)
            dr["Alpha"] = ((double)dr["Move Index price"]) * 1.5 - (double)dr["Move Ticker price"];
        // remplir le feed alpha
        FeedAlpha.DataSource = Recap;

        // faire un plot 
        ChartPureAlpha.ChartType = Infragistics.UltraChart.Shared.Styles.ChartType.Composite;
        ChartArea myChartArea = new ChartArea();
        ChartPureAlpha.CompositeChart.ChartAreas.Add(myChartArea);
        // Defines axes
        AxisItem axisX = new AxisItem();
        axisX.DataType = Infragistics.UltraChart.Shared.Styles.AxisDataType.Numeric;
        axisX.Labels.ItemFormatString = "<DATA_VALUE:0.00>";
        axisX.SetLabelAxisType = SetLabelAxisType.ContinuousData;
        axisX.OrientationType = Infragistics.UltraChart.Shared.Styles.AxisNumber.X_Axis;
        axisX.RangeType = AxisRangeType.Custom;
        axisX.RangeMin = -1;
        axisX.RangeMax = 1;
        myChartArea.Axes.Add(axisX);

        AxisItem axisY = new AxisItem();
        axisY.DataType = Infragistics.UltraChart.Shared.Styles.AxisDataType.Numeric;
        axisY.Labels.ItemFormatString = "<DATA_VALUE:0.00>";
        axisY.Labels.HorizontalAlign = StringAlignment.Far;
        axisY.SetLabelAxisType = SetLabelAxisType.ContinuousData;
        axisY.OrientationType = Infragistics.UltraChart.Shared.Styles.AxisNumber.Y_Axis;
        axisY.RangeType = AxisRangeType.Custom;
        axisY.RangeMin = -1;
        axisY.RangeMax = 1;
        myChartArea.Axes.Add(axisY);

        // Create and add series
        XYSeries BPLseries = new XYSeries();
        BPLseries.Label = "Blood L";
        for (int i = 0; i < Recap.Rows.Count; i++)
            BPLseries.Points.Add(new XYDataPoint((double)(Recap.Rows[i][2]), (double)Recap.Rows[i][1], "", false));

        // Add a chartLayerAppearance
        ChartLayerAppearance myScatterLayer = new ChartLayerAppearance();
        myScatterLayer.ChartType = Infragistics.UltraChart.Shared.Styles.ChartType.ScatterChart;
        myScatterLayer.ChartArea = myChartArea;
        myScatterLayer.AxisX = axisX;
        myScatterLayer.AxisY = axisY;
        myScatterLayer.Series.Add(BPLseries);

        ScatterChartAppearance sca1 = new ScatterChartAppearance();
        sca1.ConnectWithLines = true;
        sca1.Icon = SymbolIcon.None;
        myScatterLayer.ChartTypeAppearance = sca1;

        ChartPureAlpha.Series.Add(BPLseries);
        ChartPureAlpha.CompositeChart.ChartLayers.Add(myScatterLayer);

        CompositeLegend myLegend = new CompositeLegend();
        myLegend.ChartLayers.Add(myScatterLayer);
        myLegend.Bounds = new Rectangle(88, 2, 11, 15);
        myLegend.BoundsMeasureType = MeasureType.Percentage;
        myLegend.PE.ElementType = PaintElementType.Gradient;
        myLegend.PE.FillGradientStyle = GradientStyle.ForwardDiagonal;
        myLegend.PE.Fill = Color.CornflowerBlue;
        myLegend.PE.FillStopColor = Color.Transparent;
        myLegend.Border.CornerRadius = 10;
        myLegend.Border.Thickness = 1;
        ChartPureAlpha.CompositeChart.Legends.Add(myLegend);

如果我有数据vs数据,但我想要的是时间(dd/mm/yyy) vs (double)。如果你有什么想法请告诉我。

谢谢

c#使用timeXaxis来制作时间与数据的图表(超级图表:inffragistics)

您可以使用以下代码来获取时间与数据的关系图:

using Infragistics.Win.UltraWinChart;
using Infragistics.UltraChart.Resources.Appearance;
DataTable dt = new DataTable();
dt.Columns.Add("Value", typeof(double));
dt.Columns.Add("Date", typeof(DateTime));
dt.Rows.Add(1.0, DateTime.Parse("04/20/2012"));
dt.Rows.Add(0.5, DateTime.Parse("04/21/2012"));
dt.Rows.Add(0.25, DateTime.Parse("04/22/2012"));
dt.Rows.Add(0.125, DateTime.Parse("04/23/2012"));
dt.Rows.Add(0.0625, DateTime.Parse("04/24/2012"));
dt.Rows.Add(0.03125, DateTime.Parse("04/25/2012"));
dt.Rows.Add(0.015625, DateTime.Parse("04/26/2012"));
dt.Rows.Add(0.0, DateTime.Parse("04/27/2012"));
NumericTimeSeries series = new NumericTimeSeries();
series.DataBind(dt, "Date", "Value");
UltraChart ultraChart = new UltraChart();
ultraChart.Data.SwapRowsAndColumns = true;
ultraChart.Dock = DockStyle.Fill;
ultraChart.ChartType = Infragistics.UltraChart.Shared.Styles.ChartType.LineChart;
ultraChart.DataSource = dt;
this.Controls.Add(ultraChart);