Я хотел бы сделать график с функцией времени данных с помощью ультрачарта, Infragistics.
Я нашел этот образец:
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);
Работает нормально, если у меня есть данные против данных, но мне нужно время (дд / мм / ггг) против (двойное).
Пожалуйста, дайте мне знать, если у вас есть идеи.
Спасибо