private XYDiagramPaneBase CheckAddPanel(StrategyDataItemInfo info) { XYDiagram diagram = (XYDiagram)Chart.Diagram; if (diagram == null) { return(null); } diagram.AxisY.WholeRange.AlwaysShowZeroLevel = false; if (info.PanelName == "Default") { return(diagram.DefaultPane); } XYDiagramPane pane = null; if (diagram.Panes[info.PanelName] != null) { pane = diagram.Panes[info.PanelName]; } IResizeableArray items = GetDataSource(info) as IResizeableArray; if (items != null && !(GetArgumentValue(info, items.GetItem(0)) is DateTime)) { if (info.PanelName == "Default") { } else { SecondaryAxisX axisX = new SecondaryAxisX(); axisX.Name = info.AxisXName; diagram.SecondaryAxesX.Add(axisX); } } if (pane == null || info.Reversed) { SecondaryAxisY axis = new SecondaryAxisY(); axis.Assign(diagram.AxisY); axis.Name = info.AxisYName; axis.Reverse = info.Reversed; diagram.SecondaryAxesY.Add(axis); } if (pane == null) { pane = new XYDiagramPane() { Name = info.PanelName }; diagram.Panes.Add(pane); Legend l = new Legend(); l.Assign(Chart.Legend); l.Name = info.PanelName; l.DockTarget = pane; Chart.Legends.Add(l); } if (!info.PanelVisible) { pane.Visibility = ChartElementVisibility.Hidden; } return(pane); }
private Series CreateLineSeries(StrategyDataItemInfo info) { Series s = new Series(); s.Name = info.Name; s.ArgumentDataMember = GetArgumentDataMember(info); s.ArgumentScaleType = GetArgumentScaleType(info); s.ValueDataMembers.AddRange(info.FieldName); s.ValueScaleType = ScaleType.Numerical; s.ShowInLegend = true; LineSeriesView view = info.ChartType == ChartType.StepLine? new StepLineSeriesView(): new LineSeriesView(); view.LineStyle.LineJoin = System.Drawing.Drawing2D.LineJoin.Bevel; view.Color = info.Color; view.LineStyle.Thickness = (int)(info.GraphWidth * DpiProvider.Default.DpiScaleFactor); view.AggregateFunction = SeriesAggregateFunction.Average; s.View = view; object dataSource = GetDataSource(info); IResizeableArray array = dataSource as IResizeableArray; if (array == null || array.Count < BigDataCount) { s.DataSource = dataSource; } else { s.Points.AddRange(CreateSeriesPoints(info)); } return(s); }
protected SeriesPoint[] CreateSeriesPoints(StrategyDataItemInfo info) { object dataSource = GetDataSource(info); IResizeableArray array = dataSource as IResizeableArray; SeriesPoint[] points = new SeriesPoint[array.Count]; PropertyInfo ap = array.GetItem(0).GetType().GetProperty(info.GetArgumentDataMember(), BindingFlags.Public | BindingFlags.Instance); PropertyInfo vp = array.GetItem(0).GetType().GetProperty(info.FieldName, BindingFlags.Public | BindingFlags.Instance); Func <object, object> af = MakeAccessor(array.GetItem(0).GetType(), ap.PropertyType, info.GetArgumentDataMember()); Func <object, object> vf = MakeAccessor(array.GetItem(0).GetType(), vp.PropertyType, info.FieldName); if (ap.PropertyType == typeof(DateTime)) { for (int i = 0; i < array.Count; i++) { object item = array.GetItem(i); points[i] = new SeriesPoint((DateTime)af(item), (double)vf(item)); } } else if (ap.PropertyType == typeof(double)) { for (int i = 0; i < array.Count; i++) { object item = array.GetItem(i); points[i] = new SeriesPoint((double)af(item), (double)vf(item)); } } return(points); }
protected virtual Series CreateBarSeries(StrategyDataItemInfo info) { Series s = new Series(); Chart.Series.Add(s); s.Name = info.Name; s.ArgumentDataMember = GetArgumentDataMember(info); s.ArgumentScaleType = GetArgumentScaleType(info); s.ValueDataMembers.AddRange(info.FieldName); s.ValueScaleType = ScaleType.Numerical; s.ShowInLegend = true; SideBySideBarSeriesView view = new SideBySideBarSeriesView(); s.View = view; view.EqualBarWidth = true; view.Color = info.Color; view.BarWidth = info.GraphWidth == 1 ? view.BarWidth : (int)(info.GraphWidth * DpiProvider.Default.DpiScaleFactor); view.FillStyle.FillMode = FillMode.Solid; view.Border.Visibility = DefaultBoolean.False; view.AggregateFunction = SeriesAggregateFunction.Maximum; object dataSource = GetDataSource(info); IResizeableArray array = dataSource as IResizeableArray; if (array == null || array.Count < BigDataCount) { s.DataSource = dataSource; } else { s.Points.AddRange(CreateSeriesPoints(info)); } return(s); }
protected virtual Series CreateAreaSeries(StrategyDataItemInfo info) { Series s = new Series(); s.Name = info.Name; s.ArgumentDataMember = GetArgumentDataMember(info); s.ArgumentScaleType = GetArgumentScaleType(info); s.ValueDataMembers.AddRange(info.FieldName); s.ValueScaleType = ScaleType.Numerical; s.ShowInLegend = true; AreaSeriesView view = null; if (info.ChartType == ChartType.Area) { view = new AreaSeriesView(); } else { view = new StepAreaSeriesView(); } view.Color = info.Color; s.View = view; object dataSource = GetDataSource(info); IResizeableArray array = dataSource as IResizeableArray; if (array == null || array.Count < BigDataCount) { s.DataSource = dataSource; } else { s.Points.AddRange(CreateSeriesPoints(info)); } return(s); }
protected virtual Series CreatePointSeries(StrategyDataItemInfo info) { Series s = new Series(); s.Name = info.Name; s.ArgumentDataMember = GetArgumentDataMember(info); s.ArgumentScaleType = GetArgumentScaleType(info); s.ValueDataMembers.AddRange(info.FieldName); s.ValueScaleType = ScaleType.Numerical; PointSeriesView view = new PointSeriesView(); view.Color = info.Color; view.PointMarkerOptions.Size = info.GraphWidth == 1 ? view.PointMarkerOptions.Size : (int)(info.GraphWidth * DpiProvider.Default.DpiScaleFactor); s.View = view; object dataSource = GetDataSource(info); IResizeableArray array = dataSource as IResizeableArray; if (array == null || array.Count < BigDataCount) { s.DataSource = dataSource; } else { view.PointMarkerOptions.BorderVisible = false; view.PointMarkerOptions.Kind = MarkerKind.Square; view.PointMarkerOptions.Size = ScaleUtils.ScaleValue(4); s.Points.AddRange(CreateSeriesPoints(info)); } return(s); }
private void InitializeTreeList() { if (TreeList == null) { return; } int index = 0; IResizeableArray data = GetItems(Visual); object first = data != null && data.Count > 0 ? data.GetItem(0) : null; for (int i = 0; i < Visual.DataItemInfos.Count; i++) { StrategyDataItemInfo info = Visual.DataItemInfos[i]; TreeListColumn column = new TreeListColumn(); column.Tag = info; bool isVisible = info.Visibility.HasFlag(DataVisibility.Table); column.Visible = isVisible; if (isVisible) { column.VisibleIndex = index; } RepositoryItem editor = CreateEditor(first, info); if (editor != null) { TreeList.RepositoryItems.Add(editor); column.ColumnEdit = editor; } column.FieldName = info.FieldName; column.Format.FormatType = GetFormatType(info.Type); column.Format.FormatString = info.FormatString; TreeList.Columns.Add(column); if (isVisible) { index++; } } for (int i = 0; i < Visual.DataItemInfos.Count; i++) { StrategyDataItemInfo info = Visual.DataItemInfos[i]; if (!string.IsNullOrEmpty(info.AnnotationText)) { TreeList.FormatRules.Add(CreateRule(TreeList.Columns[info.FieldName], true, info.Color, Color.FromArgb(0x20, info.Color))); } } //lock(Visual.Items) { //List<object> data = new List<object>(); //data.AddRange(Visual.Items); //TreeList.DataSource = data; TreeList.DataSource = data; //} TreeList.OptionsScrollAnnotations.ShowCustomAnnotations = DefaultBoolean.True; TreeList.CustomScrollAnnotation += OnCustomScrollAnnotations; }
private void OnNavigateItemCheckedChanged(object sender, ItemClickEventArgs e) { BarCheckItem item = (BarCheckItem)e.Item; StrategyDataItemInfo itemInfo = (StrategyDataItemInfo)item.Tag; NavigatableInfo = itemInfo; IResizeableArray array = itemInfo.DataSource as IResizeableArray; if (array != null) { this.beNavigate.EditValue = NavigatableIndex; } NavigatableArray = array; NavigatableIndex = 0; }
protected virtual Series CreateCandleStickSeries(StrategyDataItemInfo info) { Series s = new Series("Kline", ViewType.CandleStick); s.ArgumentDataMember = "Time"; s.ArgumentScaleType = ScaleType.DateTime; s.ValueDataMembers.AddRange("Low", "High", "Open", "Close"); s.ValueScaleType = ScaleType.Numerical; CandleStickSeriesView view = new CandleStickSeriesView(); view.LineThickness = (int)(info.GraphWidth * DpiProvider.Default.DpiScaleFactor); view.LevelLineLength = 0.25; view.ReductionOptions.ColorMode = ReductionColorMode.OpenToCloseValue; view.ReductionOptions.FillMode = CandleStickFillMode.AlwaysFilled; view.Color = DXSkinColors.ForeColors.Information; view.ReductionOptions.Color = DXSkinColors.ForeColors.Critical; view.ReductionOptions.Level = StockLevel.Open; view.ReductionOptions.Visible = true; view.AggregateFunction = SeriesAggregateFunction.Financial; view.LineThickness = (int)(1 * DpiProvider.Default.DpiScaleFactor); view.LevelLineLength = 0.25; s.View = view; s.CrosshairLabelPattern = "O={OV}\nH={HV}\nL={LV}\nC={CV}"; object dataSource = GetDataSource(info); IResizeableArray array = dataSource as IResizeableArray; if (array == null || array.Count < BigDataCount) { s.DataSource = dataSource; } else { SeriesPoint[] points = new SeriesPoint[array.Count]; PropertyInfo ap = array.GetItem(0).GetType().GetProperty(s.ArgumentDataMember, BindingFlags.Public | BindingFlags.Instance); PropertyInfo lp = array.GetItem(0).GetType().GetProperty("Low", BindingFlags.Public | BindingFlags.Instance); PropertyInfo hp = array.GetItem(0).GetType().GetProperty("High", BindingFlags.Public | BindingFlags.Instance); PropertyInfo op = array.GetItem(0).GetType().GetProperty("Open", BindingFlags.Public | BindingFlags.Instance); PropertyInfo cp = array.GetItem(0).GetType().GetProperty("Close", BindingFlags.Public | BindingFlags.Instance); Func <object, object> af = MakeAccessor(array.GetItem(0).GetType(), ap.PropertyType, s.ArgumentDataMember); Func <object, object> lf = MakeAccessor(array.GetItem(0).GetType(), lp.PropertyType, "Low"); Func <object, object> hf = MakeAccessor(array.GetItem(0).GetType(), lp.PropertyType, "High"); Func <object, object> of = MakeAccessor(array.GetItem(0).GetType(), lp.PropertyType, "Open"); Func <object, object> cf = MakeAccessor(array.GetItem(0).GetType(), lp.PropertyType, "Close"); if (ap.PropertyType == typeof(DateTime)) { for (int i = 0; i < array.Count; i++) { object item = array.GetItem(i); points[i] = new SeriesPoint((DateTime)af(item), new double[] { (double)lf(item), (double)hf(item), (double)of(item), (double)cf(item) }); } } s.Points.AddRange(points); } //s.DataSource = GetDataSource(info); return(s); }
protected virtual Series CreateSeries(StrategyDataItemInfo info) { CheckAddPanel(info); Series res = null; if (info.ChartType == ChartType.ConstantX || info.ChartType == ChartType.ConstantY) { CreateConstantLines(info); return(null); } if (info.ChartType == ChartType.CandleStick) { res = CreateCandleStickSeries(info); } if (info.ChartType == ChartType.Line || info.ChartType == ChartType.StepLine) { res = CreateLineSeries(info); } if (info.ChartType == ChartType.Bar) { res = CreateBarSeries(info); } if (info.ChartType == ChartType.Area || info.ChartType == ChartType.StepArea) { res = CreateAreaSeries(info); } if (info.ChartType == ChartType.Dot) { res = CreatePointSeries(info); } if (res != null) { if (res.Points != null && res.Points.Count > BigDataCount) { Chart.SelectionMode = ElementSelectionMode.None; Chart.RuntimeHitTesting = false; } res.DataSourceSorted = true; res.SeriesPointsSorting = SortingMode.None; } IResizeableArray array = res.DataSource as IResizeableArray; if (array != null && array.Count > BigDataCount) // optimization { PointSeriesView view2 = res.View as PointSeriesView; if (view2 != null) { view2.AggregateFunction = SeriesAggregateFunction.None; } } XYDiagramSeriesViewBase view = (XYDiagramSeriesViewBase)res.View; if (info.PanelName != "Default") { view.Pane = ((XYDiagram)Chart.Diagram).Panes[info.PanelName]; view.AxisY = ((XYDiagram)Chart.Diagram).SecondaryAxesY[info.AxisYName]; if (((XYDiagram)Chart.Diagram).SecondaryAxesX[info.AxisXName] != null) { view.AxisX = ((XYDiagram)Chart.Diagram).SecondaryAxesX[info.AxisXName]; } res.Legend = Chart.Legends[info.PanelName]; } else { } return(res); }