示例#1
0
        public static void DoTest()
        {
            ChartControl chart = new ChartControl();
            chart.Width = 900;

            // Specify data members to bind the chart's series template.
            chart.SeriesDataMember = "Type";
            chart.SeriesTemplate.Label.Visible = false;
            chart.SeriesTemplate.ArgumentDataMember = "Hour";
            chart.SeriesTemplate.ArgumentScaleType = ScaleType.DateTime;
            chart.SeriesTemplate.ValueDataMembers.AddRange(new string[] { "Value" });

            XYDiagram diagram = chart.Diagram as XYDiagram;

            diagram.AxisX.DateTimeGridAlignment = DateTimeMeasurementUnit.Hour;
            diagram.AxisX.DateTimeMeasureUnit = DateTimeMeasurementUnit.Second;
            diagram.AxisX.GridSpacing = 1;

            diagram.AxisX.DateTimeOptions.Format = DateTimeFormat.Custom;
            diagram.AxisX.DateTimeOptions.FormatString = "HH:mm";

            // Specify the template's series view.
            chart.SeriesTemplate.View = new SideBySideBarSeriesView();

            // Specify the template's name prefix.
            chart.SeriesNameTemplate.BeginText = "";

            // Generate a data table and bind the chart to it.
            DataView dv = CreateChartData().DefaultView;
            dv.Sort = "Hour asc";

            chart.DataSource = dv;

            chart.ExportToImage("f:\\1.jpg", ImageFormat.Jpeg);
        }
示例#2
0
 public static void ChangeBarView(ChartControl chartControl)
 {
     foreach (Series series in chartControl.Series)
     {
         series.ChangeView(ViewType.Bar);
         series.PointOptions.ValueNumericOptions.Format = NumericFormat.General;
         series.PointOptions.ValueNumericOptions.Precision = 2;
     }
 }
示例#3
0
        public static ChartControl CreatPieChart(SolidColorBrush forecolor, string ChartTitle, List<ChartDataChartCommonData> dtchart)
        {
            mausac = 0;
            ChartControl abc = new ChartControl();
            SimpleDiagram2D dg1 = new SimpleDiagram2D();
            //liabc.Titles.Clear();
            //Tao Tile cho Chart
            Title nt = new Title();
            nt.Content = ChartTitle;
            nt.Foreground = forecolor;
            abc.Titles.Add(nt);
            //Tinh so Series
            List<string> countsr = (from p in dtchart group p by p.Series into g select g.Key).ToList();
            //Creat Diagram
            abc.Diagram = dg1;
            GridControl dtl = new GridControl();
            for (int i = 0; i < countsr.Count; i++)
            {
                PieSeries2D dgs1 = new PieSeries2D();
                dgs1.HoleRadiusPercent = 0;//Thiet lap khoang trong tu tam hinh tron den duong tron
                dgs1.ArgumentScaleType = ScaleType.Auto;
                foreach (ChartDataChartCommonData dr in dtchart)//Tao cac point
                {
                    if (dr.Series == countsr.ElementAt(i))
                    {
                        //Tao Series
                        SeriesPoint sr1 = new SeriesPoint();
                        sr1.Argument = dr.Agrument + ":" + dr.Value.ToString();
                        sr1.Value = dr.Value;
                        sr1.Tag = mausac.ToString();
                        dgs1.Points.Add(sr1);
                        mausac++;
                    }
                }
                dgs1.Label = new SeriesLabel();//Tao Label cho Diagram
                PieSeries.SetLabelPosition(dgs1.Label, PieLabelPosition.TwoColumns);
                dgs1.Label.RenderMode = LabelRenderMode.RectangleConnectedToCenter;
                dgs1.LabelsVisibility = true;//Hien thi Lablel cho tung vung
                PointOptions pn1 = new PointOptions();
                pn1.PointView = PointView.ArgumentAndValues;
                pn1.Pattern = "{A} ({V})";//Tao mau chu thich
                NumericOptions nbm1 = new NumericOptions();//Tao Kieu hien thi
                nbm1.Format = NumericFormat.Percent;
                pn1.ValueNumericOptions = nbm1;
                PieSeries2D.SetPercentOptions(pn1, new PercentOptions() { ValueAsPercent = true, PercentageAccuracy = 5 });//Quy dinh ty le phan tram chinh xac
                dgs1.PointOptions = pn1;
                dg1.Series.Add(dgs1);
                //Tao chu thich
                dgs1.LegendPointOptions = pn1;

            }
            abc.Legend = new Legend();
            //End tao chu thich
            //Set mau sac cho seriespont
            abc.CustomDrawSeriesPoint += abc_CustomDrawSeriesPoint;
            return abc;
        }
示例#4
0
        private void frmViewChart_Load(object sender, EventArgs e)
        {
            // Create an empty chart
            ChartControl barChart = new ChartControl();

            // Create the first side-by-side bar series and add points to it.
            Series series1 = new Series("Gross Amount Series ", ViewType.Bar);
            for (int i = 0; i <= ds_takeQryData.Tables[0].Rows.Count - 1; i++)
            {
                series1.Points.Add(new SeriesPoint(ds_takeQryData.Tables[0].Columns["GrossAmount"], ds_takeQryData.Tables[0].Rows[i]["GrossAmount"]));
            }
            //series1.Points.Add(new SeriesPoint("A", new double[] { 10 }));
            //series1.Points.Add(new SeriesPoint("B", new double[] { 12 }));
            //series1.Points.Add(new SeriesPoint("C", new double[] { 14 }));
            //series1.Points.Add(new SeriesPoint("D", new double[] { 17 }));

            // Create the second side-by-side bar series and add points to it.
            Series series2 = new Series("Unit Price Series ", ViewType.Bar);
            for (int i = 0; i <= ds_takeQryData.Tables[0].Rows.Count - 1; i++)
            {
                series2.Points.Add(new SeriesPoint(ds_takeQryData.Tables[0].Columns["UnitPrice"], ds_takeQryData.Tables[0].Rows[i]["UnitPrice"]));
            }
            //series2.Points.Add(new SeriesPoint("A", new double[] { 15 }));
            //series2.Points.Add(new SeriesPoint("B", new double[] { 18 }));
            //series2.Points.Add(new SeriesPoint("C", new double[] { 25 }));
            //series2.Points.Add(new SeriesPoint("D", new double[] { 33 }));

            // Create the second side-by-side bar series and add points to it.
            Series series3 = new Series("Net Amount Series ", ViewType.Bar);
            for (int i = 0; i <= ds_takeQryData.Tables[0].Rows.Count - 1; i++)
            {
                series3.Points.Add(new SeriesPoint(ds_takeQryData.Tables[0].Columns["NetAmount"], ds_takeQryData.Tables[0].Rows[i]["NetAmount"]));
            }
            // Add the series to the chart
            barChart.Series.Add(series1);
            barChart.Series.Add(series2);
            barChart.Series.Add(series3);

            // Hide the legend (if necessary).
            //sideBySideBarChart.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False;

            // Rotate the diagram (if necessary).
            //((XYDiagram)sideBySideBarChart.Diagram).Rotated = true;

            // Add a title to the chart (if necessary).
            ChartTitle chartTitle1 = new ChartTitle();
            chartTitle1.Text = "Babar Medicine Company Bar Chart";
            barChart.Titles.Add(chartTitle1);

            // Add the chart to the form.
            barChart.Dock = DockStyle.Fill;
            this.Controls.Add(barChart);
            barChart.BringToFront();
        }
示例#5
0
 public override void SetChargeUiControls(ChartControl chartControlChargeProportion,
     ChartControl feCuPropotionCtl, ChartControl chargePropotionChart, GridControl gridControl1,
     GridControl gridControl2, GridControl gridControl3, GridControl gridControl4, DocumentViewer documentView)
 {
     ChargeProportion = chartControlChargeProportion;
     Fe_CuPropotion = feCuPropotionCtl;
     ChargeChart = chargePropotionChart;
     gridCharge_1 = gridControl1;
     gridCharge_2 = gridControl2;
     gridCharge_3 = gridControl3;
     gridCharge_4 = gridControl4;
     documentViewer = documentView;
 }
示例#6
0
 private void init()
 {
     chartLayers = new ChartControl();
     tabPage1.Controls.Add(chartLayers);
     chartLayers.Interval = 1000;
     chartLayers.add("Session",new ChartDataLayer.UpdateFunction(mainTimetUpdate),true);
     chartLayers.Start();
     chartSortedData = new ChartControl();
     chartESimilarity = new ChartControl();
     chartSortedData.optionPanel = false;
     chartESimilarity.optionPanel = false;
     chartESimilarity.add("Relative Diference", true);
     chartSortedData.add("Sorted inter-arival times", true);
     splitEsimilarithGraphs.Panel1.Controls.Add(chartSortedData);
     splitEsimilarithGraphs.Panel2.Controls.Add(chartESimilarity);
 }
 protected override Image DoCreateChartImage()
 {
     using (var chart = new ChartControl())
     {
         var series1 = new Series("Series 1", ViewType.Line);
         series1.Points.AddRange(Parameters.SeriaData.Select(p => new SeriesPoint(p.Key,p.Value)).ToArray());
         chart.Series.Add(series1);
         chart.Width = Parameters.ChartWidth;
         chart.Height = Parameters.ChartHeight;
         using (var stream = new MemoryStream())
         {
             chart.ExportToImage(stream, ImageFormat.Png);
             return Image.FromStream(stream);
         }
     }
 }
        public TestForm()
        {
            InitializeComponent();

            List<TypeACopy> lst = new List<TypeACopy>()
                                      {
                                          new TypeACopy() {TypeName = "Tại thư viện", NoC = 66},
                                          new TypeACopy() {TypeName = "Đã được mượn", NoC = 3},
                                          new TypeACopy() {TypeName = "Đã mất", NoC = 20}
                                      };
            Series serie1 = new Series("Số lượng sách trong thư viện", ViewType.Pie);

            serie1.ArgumentDataMember = "TypeName";
            serie1.ValueDataMembers[0] = "NoC";
            //serie1.LegendPointOptions.ValueNumericOptions.Format = NumericFormat.Percent;
            serie1.LegendPointOptions.PointView = PointView.Argument;
            serie1.PointOptions.ValueNumericOptions.Format = NumericFormat.FixedPoint;
            ((PiePointOptions) serie1.PointOptions).PercentOptions.ValueAsPercent = false;

            ChartControl c = new ChartControl();
            c.Series.Add(serie1);
            c.DataSource = lst;
            c.ExportToImage("D:\\Demo.jpg", ImageFormat.Jpeg);

            GridControl gc = new GridControl();
            DataTable dt = new DataTable();

            SqlDataReader reader =
                LIB.Common.ConnectionManager.GetCommand("ReportOfRentalByUserId", new Dictionary<string, SqlDbType>() { {"@UserId", SqlDbType.NVarChar}},
                                                        new List<object>() {"admin"}).ExecuteReader();
            dt.Load(reader);

            gc.DataSource = dt;

            GridView view = new GridView();

            view.GridControl = gc;

            gridControl1.DataSource = dt;

            gridControl1.ExportToPdf("D:\\Demo.pdf");

            //cctlTestChart.Series.Add(serie1);
            //cctlTestChart.DataSource = lst;
        }
示例#9
0
文件: ViewRssi.cs 项目: x893/WDS
 private void InitializeComponent()
 {
     this.chartRssi = new ChartControl();
     base.SuspendLayout();
     this.chartRssi.BackgroundImageLayout = ImageLayout.None;
     this.chartRssi.ChartAreaMargins = new ChartMargins(5, 5, 5, 5);
     this.chartRssi.Dock = DockStyle.Fill;
     this.chartRssi.ElementsSpacing = 1;
     this.chartRssi.Legend.Location = new Point(0x189, 1);
     this.chartRssi.LegendsPlacement = ChartPlacement.Outside;
     this.chartRssi.Location = new Point(0, 0);
     this.chartRssi.Name = "chartRssi";
     this.chartRssi.PrimaryXAxis.DrawGrid = false;
     this.chartRssi.PrimaryXAxis.Inversed = true;
     this.chartRssi.PrimaryXAxis.IsVisible = false;
     this.chartRssi.PrimaryXAxis.LabelAlignment = StringAlignment.Near;
     this.chartRssi.PrimaryXAxis.Margin = true;
     this.chartRssi.PrimaryXAxis.RangePaddingType = ChartAxisRangePaddingType.None;
     this.chartRssi.PrimaryYAxis.GridLineType.DashStyle = DashStyle.Dot;
     this.chartRssi.PrimaryYAxis.GridLineType.Width = 0.25f;
     this.chartRssi.PrimaryYAxis.InterlacedGrid = true;
     this.chartRssi.PrimaryYAxis.LineType.Width = 0.5f;
     this.chartRssi.PrimaryYAxis.Margin = true;
     this.chartRssi.PrimaryYAxis.RangePaddingType = ChartAxisRangePaddingType.None;
     this.chartRssi.PrimaryYAxis.Title = "dBm";
     this.chartRssi.Size = new Size(0x1d7, 0x17b);
     this.chartRssi.Spacing = 1f;
     this.chartRssi.SpacingBetweenPoints = 1f;
     this.chartRssi.SpacingBetweenSeries = 1f;
     this.chartRssi.TabIndex = 0;
     this.chartRssi.TextPosition = ChartTextPosition.Left;
     this.chartRssi.Title.Name = "Default";
     this.chartRssi.Title.Orientation = ChartOrientation.Vertical;
     this.chartRssi.Title.Position = ChartDock.Left;
     base.AutoScaleDimensions = new SizeF(6f, 13f);
     base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
     base.Controls.Add(this.chartRssi);
     base.Name = "ViewRssi";
     base.Size = new Size(0x1d7, 0x17b);
     base.Load += new EventHandler(this.ViewRssi_Load);
     base.ResumeLayout(false);
 }
示例#10
0
    public override Control Generete()
    {
        var grafico = new ChartControl();
        var pathbaseControlXml = string.Format(
            @"panel de control/basecontrol/{0}",
            XmlDocument.SelectSingleNode("control").Attributes["baseControl"].Value);
        grafico.LoadFromFile(Path.Combine(Application.StartupPath, pathbaseControlXml));

        grafico.Location = Location;
        grafico.Size = Size;
        //grafico.BackColor = Color.Transparent;

        grafico.Text = DatasourceDetail;
        var title = new ChartTitle { Text = this.Title };
        grafico.Titles.Add(title);
        title = new ChartTitle { Text = this.DatasourceDetail, Visible = false };
        grafico.Titles.Add(title);

        Control = grafico;
        return grafico;
    }
示例#11
0
 public static void _setScrollAndZoom(ChartControl chartControl)
 {
     if (chartControl.Diagram is Diagram3D)
     {
         Diagram3D diagram = (Diagram3D)chartControl.Diagram;
         diagram.RuntimeRotation = true;
         diagram.RuntimeZooming = true;
         diagram.RuntimeScrolling = true;
     }
     else if (chartControl.Diagram is XYDiagram)
     {
         XYDiagram diagram = (XYDiagram)chartControl.Diagram;
         diagram.EnableAxisXScrolling = true;
         diagram.EnableAxisYScrolling = true;
         diagram.EnableAxisXZooming = true;
         diagram.EnableAxisYZooming = true;
         diagram.ZoomingOptions.UseKeyboard = true;
         diagram.ZoomingOptions.UseKeyboardWithMouse = true;
     }
     else if (chartControl.Diagram is XYDiagram2D)
     {
         XYDiagram2D diagram = (XYDiagram2D)chartControl.Diagram;
         diagram.EnableAxisXScrolling = true;
         diagram.EnableAxisYScrolling = true;
         diagram.EnableAxisXZooming = true;
         diagram.EnableAxisYZooming = true;
         diagram.ZoomingOptions.UseKeyboard = true;
         diagram.ZoomingOptions.UseKeyboardWithMouse = true;
     }
     else if (chartControl.Diagram is XYDiagram3D)
     {
         XYDiagram3D diagram = (XYDiagram3D)chartControl.Diagram;
         diagram.RuntimeZooming = true;
         diagram.RuntimeScrolling = true;
         diagram.RuntimeRotation = true;
         diagram.ZoomingOptions.UseKeyboard = true;
         diagram.ZoomingOptions.UseKeyboardWithMouse = true;
     }
 }
示例#12
0
        private void InitialChart()
        {
            chart = defectMap;

            // 關閉十字瞄準游標
            chart.CrosshairEnabled = false;

            // 綁定事件
            //chart.CustomDrawSeriesPoint += chart_CustomDrawSeriesPoint;
            chart.MouseMove += chart_MouseMove;
            chart.MouseDoubleClick += chart_MouseDoubleClick;

            // 定義圖表類型
            XYDiagram2D diagram = new XYDiagram2D();

            // 設定坐標軸最小/最大值、格線類型及刻度
            diagram.AxisX = new AxisX2D();
            diagram.AxisX.Range = new AxisRange();
            diagram.AxisX.Range.MinValue = 0;
            //diagram.AxisX.Range.MaxValue = 60;
            diagram.AxisX.GridLinesLineStyle = new LineStyle();
            diagram.AxisX.GridLinesLineStyle.DashStyle = DashStyles.Dash;
            diagram.AxisX.GridSpacing = 1;
            diagram.AxisX.TickmarksMinorVisible = false;

            diagram.AxisY = new AxisY2D();
            diagram.AxisY.Range = new AxisRange();
            diagram.AxisY.Range.MinValue = 0;
            //diagram.AxisY.Range.MaxValue = 60;
            diagram.AxisY.GridLinesLineStyle = new LineStyle();
            diagram.AxisY.GridLinesLineStyle.DashStyle = DashStyles.Dash;
            diagram.AxisY.GridSpacing = 1;
            diagram.AxisY.TickmarksMinorVisible = false;

            chart.Diagram = diagram;
        }
示例#13
0
 public static void DefineSeries(ChartControl chartControl, string name)
 {
     TypeChart = 1;
     Series series = new Series(name, ViewType.Bar);
     chartControl.Series.Add(series);
 }
示例#14
0
 public virtual void SetChargeUiControls(ChartControl chartControlChargeProportion,
                                         ChartControl feCuPropotionCtl, ChartControl chargePropotionChart, GridControl gridControl1,
                                         GridControl gridControl2, GridControl gridControl3, GridControl gridControl4, DocumentViewer documentView)
 {
 }
示例#15
0
 public override bool IsVisibleOnChart(ChartControl chartControl, ChartScale chartScale, DateTime firstTimeOnChart, DateTime lastTimeOnChart)
 {
     return(true);
 }
示例#16
0
 public static void SetZoom(ChartControl chartControl,bool isZoom)
 {
     ((XYDiagram)chartControl.Diagram).EnableZooming = isZoom;
 }
示例#17
0
        private void CreateChartBar(ChartControl arg_chart, DataTable arg_dt, string arg_name)
        {
            // Create a new chart.
            arg_chart.Series.Clear();
            arg_chart.Titles.Clear();
            //  ((XYDiagram)arg_chart.Diagram).AxisX.CustomLabels.Clear();
            //DataSource
            string Now = DateTime.Now.ToString("yyyyMMdd");


            // Create two series.
            //Series series1 = new Series("Production Qty", ViewType.Bar);
            Series series2 = new Series("POD", ViewType.Bar);

            // DevExpress.XtraCharts.SplineSeriesView splineSeriesView1 = new DevExpress.XtraCharts.SplineSeriesView();
            DevExpress.XtraCharts.SideBySideBarSeriesView sideBySideBarSeriesView1 = new DevExpress.XtraCharts.SideBySideBarSeriesView();
            DevExpress.XtraCharts.PointSeriesLabel        pointSeriesLabel1        = new DevExpress.XtraCharts.PointSeriesLabel();
            //DevExpress.XtraCharts.BarWidenAnimation barWidenAnimation1 = new DevExpress.XtraCharts.BarWidenAnimation();
            //DevExpress.XtraCharts.ElasticEasingFunction elasticEasingFunction1 = new DevExpress.XtraCharts.ElasticEasingFunction();


            // DevExpress.XtraCharts.XYSeriesBlowUpAnimation xySeriesBlowUpAnimation1 = new DevExpress.XtraCharts.XYSeriesBlowUpAnimation();
            DevExpress.XtraCharts.XYSeriesUnwindAnimation xySeriesUnwindAnimation1 = new DevExpress.XtraCharts.XYSeriesUnwindAnimation();
            // DevExpress.XtraCharts.XYSeriesUnwrapAnimation xySeriesUnwrapAnimation1 = new DevExpress.XtraCharts.XYSeriesUnwrapAnimation();

            DevExpress.XtraCharts.PowerEasingFunction powerEasingFunction1 = new DevExpress.XtraCharts.PowerEasingFunction();
            DevExpress.XtraCharts.SineEasingFunction  sineEasingFunction1  = new DevExpress.XtraCharts.SineEasingFunction();

            DevExpress.XtraCharts.ConstantLine constantLine1 = new DevExpress.XtraCharts.ConstantLine();

            // Add points to them, with their arguments different.

            for (int i = 0; i < arg_dt.Rows.Count; i++)
            {
                //series1.Points.Add(new SeriesPoint(dt.Rows[i]["HMS"].ToString(), dt.Rows[i]["QTY"])); //GetRandomNumber(10, 50)
                series2.Points.Add(new SeriesPoint(arg_dt.Rows[i]["LB"].ToString().Replace("_", "\n"),
                                                   arg_dt.Rows[i]["POD"] == null || arg_dt.Rows[i]["POD"].ToString() == "" ? 0 : arg_dt.Rows[i]["POD"]));
                if ((arg_dt.Rows[i]["POD"] == null || arg_dt.Rows[i]["POD"].ToString() == "" ? 0 : Convert.ToDouble(arg_dt.Rows[i]["POD"])) > Convert.ToDouble(arg_dt.Rows[0]["TARGET"]))
                {
                    series2.Points[i].Color = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(176)))), ((int)(((byte)(240)))));
                }
                else
                {
                    series2.Points[i].Color = Color.Red;
                }
            }

            (series2.Label as SideBySideBarSeriesLabel).Position = DevExpress.XtraCharts.BarSeriesLabelPosition.Top;

            // series2 = splineSeriesView1;
            // Add both series to the chart.
            //chartControl1.Series.AddRange(new Series[] { series1, series2 });


            arg_chart.SeriesSerializable = new DevExpress.XtraCharts.Series[] { series2 };
            ((XYDiagram)arg_chart.Diagram).AxisY.Title.Text       = "POD";
            ((XYDiagram)arg_chart.Diagram).AxisY.Title.TextColor  = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(176)))), ((int)(((byte)(240)))));
            ((XYDiagram)arg_chart.Diagram).AxisY.Title.Visibility = DevExpress.Utils.DefaultBoolean.Default;
            ((XYDiagram)arg_chart.Diagram).AxisX.Title.Text       = "Date";
            ((XYDiagram)arg_chart.Diagram).AxisX.Title.Visibility = DevExpress.Utils.DefaultBoolean.Default;
            ((XYDiagram)arg_chart.Diagram).AxisX.Title.TextColor  = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(176)))), ((int)(((byte)(240)))));

            ((XYDiagram)arg_chart.Diagram).AxisX.Tickmarks.MinorVisible = true;


            sideBySideBarSeriesView1.ColorEach = false;
            series2.View = sideBySideBarSeriesView1;

            //title
            DevExpress.XtraCharts.ChartTitle chartTitle2 = new DevExpress.XtraCharts.ChartTitle();
            chartTitle2.Alignment = System.Drawing.StringAlignment.Near;
            chartTitle2.Font      = new System.Drawing.Font("Tahoma", 24F, System.Drawing.FontStyle.Bold);
            chartTitle2.Text      = arg_name;
            chartTitle2.TextColor = System.Drawing.Color.Blue;
            arg_chart.Titles.AddRange(new DevExpress.XtraCharts.ChartTitle[] { chartTitle2 });


            series2.LabelsVisibility = DevExpress.Utils.DefaultBoolean.True;
            xySeriesUnwindAnimation1.EasingFunction = sineEasingFunction1; //powerEasingFunction1;
            //splineSeriesView1.SeriesAnimation = xySeriesUnwindAnimation1;//xySeriesBlowUpAnimation1;//xySeriesUnwindAnimation1; // xySeriesUnwrapAnimation1;

            arg_chart.Legend.Direction = LegendDirection.LeftToRight;

            //Constant line
            //constantLine1.ShowInLegend = false;
            constantLine1.AxisValueSerializable = arg_dt.Rows[0]["TARGET"].ToString();
            constantLine1.Color         = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(176)))), ((int)(((byte)(80)))));
            constantLine1.Name          = "Target";
            constantLine1.ShowBehind    = false;
            constantLine1.Title.Visible = false;
            //constantLine1.Title.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            //constantLine1.Title.Text = "Target";
            constantLine1.LineStyle.Thickness = 2;
            constantLine1.Title.Alignment     = DevExpress.XtraCharts.ConstantLineTitleAlignment.Far;
            ((XYDiagram)arg_chart.Diagram).AxisY.ConstantLines.Clear();
            ((XYDiagram)arg_chart.Diagram).AxisY.ConstantLines.AddRange(new DevExpress.XtraCharts.ConstantLine[] { constantLine1 });



            //((XYDiagram)arg_chart.Diagram).AxisX.NumericScaleOptions.AutoGrid = false;
            //((XYDiagram)arg_chart.Diagram).AxisX.VisualRange.Auto = false;
            //((XYDiagram)arg_chart.Diagram).AxisX.VisualRange.AutoSideMargins = false;
            //((XYDiagram)arg_chart.Diagram).AxisX.Label.Angle = 90;
            //((XYDiagram)arg_chart.Diagram).AxisX.Label.ResolveOverlappingOptions.AllowHide = false;
            //((XYDiagram)arg_chart.Diagram).AxisX.Label.ResolveOverlappingOptions.AllowStagger = true;
            ((XYDiagram)arg_chart.Diagram).AxisX.Tickmarks.MinorVisible = false;
            ((XYDiagram)arg_chart.Diagram).AxisX.GridLines.Visible      = false;

            ((XYDiagram)arg_chart.Diagram).AxisX.Label.Font = new System.Drawing.Font("Tahoma", 10, System.Drawing.FontStyle.Bold);
            //((XYDiagram)arg_chart.Diagram).AxisY.NumericScaleOptions.ScaleMode = DevExpress.XtraCharts.ScaleMode.Continuous;
            //((XYDiagram)_chartControl1.Diagram).AxisY.NumericScaleOptions.ScaleMode = DevExpress.XtraCharts.ScaleMode.Automatic;
            //((XYDiagram)arg_chart.Diagram).AxisX.
            ((XYDiagram)arg_chart.Diagram).AxisY.Label.Font = new System.Drawing.Font("Tahoma", 10, System.Drawing.FontStyle.Bold);

            ((XYDiagram)arg_chart.Diagram).AxisX.Title.Font = new System.Drawing.Font("Tahoma", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            ((XYDiagram)arg_chart.Diagram).AxisY.Title.Font = new System.Drawing.Font("Tahoma", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));



            pn_body.Controls.Add(arg_chart);
        }
示例#18
0
        protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
        {
            if (IsInHitTest)
            {
                return;
            }

            int    lastBar   = ChartBars.ToIndex;
            int    firstBar  = ChartBars.FromIndex;
            double highPrice = 0;
            double lowPrice  = double.MaxValue;

            SharpDX.Direct2D1.Brush brushDown = BarDownBrush.ToDxBrush(RenderTarget);
            SharpDX.Direct2D1.Brush lineBrush = LineBrush.ToDxBrush(RenderTarget);
            SharpDX.Direct2D1.Brush brushUp   = BarUpBrush.ToDxBrush(RenderTarget);
            brushDown.Opacity = (float)(Opacity / 100.0);
            brushUp.Opacity   = (float)(Opacity / 100.0);

            for (int idx = firstBar; idx <= lastBar && idx >= 0; idx++)
            {
                highPrice = Math.Max(highPrice, Bars.GetHigh(idx));
                lowPrice  = Math.Min(lowPrice, Bars.GetLow(idx));
            }

            int    volumeBarCount = BarCount;
            double priceRange     = highPrice - lowPrice;
            double priceBoxSize   = priceRange / volumeBarCount;
            double volumeMax      = 0;

            // Pass 1: Fill all VolumeInfo structures with appropriate data
            for (int i = 0; i < volumeBarCount; i++)
            {
                double priceUpper = lowPrice + priceBoxSize * (i + 1);
                double priceLower = lowPrice + priceBoxSize * i;

                double priceVolumeUp   = 0;
                double priceVolumeDown = 0;

                for (int idx = firstBar; idx <= lastBar; idx++)
                {
                    double checkPrice;

                    PriceSeries series = (Inputs[0] as PriceSeries);

                    switch (series.PriceType)
                    {
                    case PriceType.Open:            checkPrice = Bars.GetOpen(idx); break;

                    case PriceType.Close:           checkPrice = Bars.GetClose(idx); break;

                    case PriceType.High:            checkPrice = Bars.GetHigh(idx); break;

                    case PriceType.Low:                     checkPrice = Bars.GetLow(idx); break;

                    case PriceType.Median:          checkPrice = (Bars.GetHigh(idx) + Bars.GetLow(idx)) / 2; break;

                    case PriceType.Typical:         checkPrice = (Bars.GetHigh(idx) + Bars.GetLow(idx) + Bars.GetClose(idx)) / 3; break;

                    case PriceType.Weighted:        checkPrice = (Bars.GetHigh(idx) + Bars.GetLow(idx) + 2 * Bars.GetClose(idx)) / 4; break;

                    default:                                        checkPrice = Bars.GetClose(idx); break;
                    }

                    if (checkPrice >= priceLower && checkPrice < priceUpper)
                    {
                        if (Bars.GetOpen(idx) < Bars.GetClose(idx))
                        {
                            priceVolumeUp += Bars.GetVolume(idx);
                        }
                        else
                        {
                            priceVolumeDown += Bars.GetVolume(idx);
                        }
                    }
                }

                volumeInfo[i].up    = priceVolumeUp;
                volumeInfo[i].down  = priceVolumeDown;
                volumeInfo[i].total = priceVolumeUp + priceVolumeDown;

                volumeMax = Math.Max(volumeMax, volumeInfo[i].total);
            }

            // Pass 2: Paint the volume bars
            for (int i = 0; i < Math.Min(volumeBarCount, lastBar - firstBar + 1); i++)
            {
                double priceUpper   = lowPrice + priceBoxSize * (i + 1);
                double priceLower   = lowPrice + priceBoxSize * i;
                int    yUpper       = Convert.ToInt32(chartScale.GetYByValue(priceUpper)) + BarSpacing;
                int    yLower       = Convert.ToInt32(chartScale.GetYByValue(priceLower));
                int    barWidthUp   = (int)((chartScale.Height / 2) * (volumeInfo[i].up / volumeMax));
                int    barWidthDown = (int)((chartScale.Height / 2) * (volumeInfo[i].down / volumeMax));

                SharpDX.RectangleF rect = new SharpDX.RectangleF(ChartPanel.X, yUpper, barWidthUp, Math.Abs(yUpper - yLower));
                RenderTarget.FillRectangle(rect, brushUp);
                RenderTarget.DrawRectangle(rect, brushUp);

                SharpDX.RectangleF rect2 = new SharpDX.RectangleF(ChartPanel.X + barWidthUp, yUpper, barWidthDown, Math.Abs(yUpper - yLower));
                RenderTarget.DrawRectangle(rect2, brushDown);
                RenderTarget.FillRectangle(rect2, brushDown);

                if (DrawLines)
                {
                    RenderTarget.DrawLine(new SharpDX.Vector2(ChartPanel.X, yLower), new SharpDX.Vector2(ChartPanel.X + ChartPanel.W, yLower), lineBrush);
                    if (i == volumeBarCount - 1)
                    {
                        RenderTarget.DrawLine(new SharpDX.Vector2(ChartPanel.X, yUpper), new SharpDX.Vector2(ChartPanel.X + ChartPanel.W, yUpper), lineBrush);
                    }
                }
            }

            lineBrush.Dispose();
            brushDown.Dispose();
            brushUp.Dispose();
        }
示例#19
0
 public static void SetBeginTextSeries(ChartControl chartControl, string text)
 {
     chartControl.SeriesNameTemplate.BeginText = text;
 }
示例#20
0
 private void bindingchart2(DataTable dt, ChartControl _chart)
 {
     _chart.DataSource = dt;
     _chart.Series[0].ArgumentDataMember = "SHIFT";
     _chart.Series[0].ValueDataMembers.AddRange(new string[] { "PO_QTY" });
 }
示例#21
0
        public MainWindow()
        {
            RadioNodeInterfaces = new List <RadioNodeGroupBox>();

            bigChart = new ChartControl(null, "Big Chart")
            {
                Dock = DockStyle.Fill,
            };
            bigChart.Legends.Clear();
            bigChart.Legends.Add(new Legend()
            {
                Enabled = true,
                IsDockedInsideChartArea = true,
                DockedToChartArea       = "ChartArea",
                Docking = Docking.Top | Docking.Left,
                Name    = "LeftLegend",
            });
            bigChart.Legends.Add(new Legend()
            {
                Enabled = true,
                IsDockedInsideChartArea = true,
                DockedToChartArea       = "ChartArea",
                Docking = Docking.Top | Docking.Right,
                Name    = "RightLegend",
            });
            bigChart.ChartArea.AxisX.MajorGrid.LineDashStyle  = ChartDashStyle.Dash;
            bigChart.ChartArea.AxisY.MajorGrid.LineDashStyle  = ChartDashStyle.Dash;
            bigChart.ChartArea.AxisY2.MajorGrid.LineDashStyle = ChartDashStyle.Dot;
            bigChart.ChartArea.AxisX.Enabled             = AxisEnabled.True;
            bigChart.ChartArea.AxisY.Enabled             = AxisEnabled.True;
            bigChart.ChartArea.AxisY2.Enabled            = AxisEnabled.True;
            bigChart.ChartArea.AxisX.LabelStyle.Enabled  = true;
            bigChart.ChartArea.AxisY.LabelStyle.Enabled  = true;
            bigChart.ChartArea.AxisY2.LabelStyle.Enabled = true;
            bigChart.ChartArea.AxisX.LabelStyle.Format   = "HH:mm:ss";
            bigChart.ChartArea.Position.Auto             = true;
            bigChart.MaxPoints = 100;

            FlowLayout = new FlowLayoutPanel
            {
                AutoSize      = true,
                AutoSizeMode  = AutoSizeMode.GrowAndShrink,
                FlowDirection = FlowDirection.TopDown,
                Margin        = new Padding(0),
                Name          = "FlowLayout",
            };

            TableLayout = new TableLayoutPanel
            {
                AutoSize    = true,
                ColumnCount = 2,
                Dock        = DockStyle.Fill,
                RowCount    = 2,
                Padding     = new Padding(3),
                Name        = "TableLayout",
            };

            Controls.Add(TableLayout);
            TableLayout.Controls.Add(FlowLayout);
            TableLayout.Controls.Add(bigChart);
            TableLayout.SetRowSpan(bigChart, 2);

            InitializeComponent();

            Application.ApplicationExit += new EventHandler(OnFormExit);
        }
示例#22
0
 public void BuildSeries(ChartControl chart)
 {
     candleSeries.Data.Clear();
     LoadData();
     DrawBounds();
 }
示例#23
0
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     this.components = new System.ComponentModel.Container();
     System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
     this.timer1        = new System.Windows.Forms.Timer(this.components);
     this.label3        = new System.Windows.Forms.Label();
     this.checkBox1     = new System.Windows.Forms.CheckBox();
     this.label2        = new System.Windows.Forms.Label();
     this.label1        = new System.Windows.Forms.Label();
     this.textBox2      = new System.Windows.Forms.TextBox();
     this.textBox1      = new System.Windows.Forms.TextBox();
     this.panel1        = new System.Windows.Forms.Panel();
     this.comboBox1     = new System.Windows.Forms.ComboBox();
     this.checkBox2     = new System.Windows.Forms.CheckBox();
     this.label7        = new System.Windows.Forms.Label();
     this.checkBox3     = new System.Windows.Forms.CheckBox();
     this.label5        = new System.Windows.Forms.Label();
     this.chartControl1 = new Syncfusion.Windows.Forms.Chart.ChartControl();
     this.panel1.SuspendLayout();
     this.SuspendLayout();
     //
     // timer1
     //
     this.timer1.Interval = 200;
     this.timer1.Tick    += new System.EventHandler(this.timer1_Tick);
     //
     // label3
     //
     this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                                                                 | System.Windows.Forms.AnchorStyles.Left)
                                                                | System.Windows.Forms.AnchorStyles.Right)));
     this.label3.AutoSize  = true;
     this.label3.FlatStyle = System.Windows.Forms.FlatStyle.System;
     this.label3.Font      = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this.label3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(66)))), ((int)(((byte)(66)))));
     this.label3.Location  = new System.Drawing.Point(38, 279);
     this.label3.Name      = "label3";
     this.label3.Size      = new System.Drawing.Size(191, 21);
     this.label3.TabIndex  = 5;
     this.label3.Text      = "Window Width in seconds";
     //
     // checkBox1
     //
     this.checkBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                                                                    | System.Windows.Forms.AnchorStyles.Left)
                                                                   | System.Windows.Forms.AnchorStyles.Right)));
     this.checkBox1.AutoSize  = true;
     this.checkBox1.FlatStyle = System.Windows.Forms.FlatStyle.System;
     this.checkBox1.Font      = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this.checkBox1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(66)))), ((int)(((byte)(66)))));
     this.checkBox1.Location  = new System.Drawing.Point(39, 387);
     this.checkBox1.Name      = "checkBox1";
     this.checkBox1.Size      = new System.Drawing.Size(96, 26);
     this.checkBox1.TabIndex  = 1;
     this.checkBox1.Text      = "Scrolling";
     //
     // label2
     //
     this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                                                                 | System.Windows.Forms.AnchorStyles.Left)
                                                                | System.Windows.Forms.AnchorStyles.Right)));
     this.label2.AutoSize  = true;
     this.label2.FlatStyle = System.Windows.Forms.FlatStyle.System;
     this.label2.Font      = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this.label2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(66)))), ((int)(((byte)(66)))));
     this.label2.Location  = new System.Drawing.Point(39, 133);
     this.label2.Name      = "label2";
     this.label2.Size      = new System.Drawing.Size(134, 21);
     this.label2.TabIndex  = 7;
     this.label2.Tag       = "";
     this.label2.Text      = "Minimum Y Value";
     //
     // label1
     //
     this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                                                                 | System.Windows.Forms.AnchorStyles.Left)
                                                                | System.Windows.Forms.AnchorStyles.Right)));
     this.label1.AutoSize  = true;
     this.label1.FlatStyle = System.Windows.Forms.FlatStyle.System;
     this.label1.Font      = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this.label1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(66)))), ((int)(((byte)(66)))));
     this.label1.Location  = new System.Drawing.Point(39, 65);
     this.label1.Name      = "label1";
     this.label1.Size      = new System.Drawing.Size(136, 21);
     this.label1.TabIndex  = 6;
     this.label1.Tag       = "";
     this.label1.Text      = "Maximum Y Value";
     //
     // textBox2
     //
     this.textBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                                                                   | System.Windows.Forms.AnchorStyles.Left)
                                                                  | System.Windows.Forms.AnchorStyles.Right)));
     this.textBox2.Font         = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this.textBox2.ForeColor    = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(66)))), ((int)(((byte)(66)))));
     this.textBox2.Location     = new System.Drawing.Point(39, 160);
     this.textBox2.Name         = "textBox2";
     this.textBox2.Size         = new System.Drawing.Size(179, 29);
     this.textBox2.TabIndex     = 5;
     this.textBox2.Text         = "0";
     this.textBox2.TextChanged += new System.EventHandler(this.textBox2_TextChanged);
     //
     // textBox1
     //
     this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                                                                   | System.Windows.Forms.AnchorStyles.Left)
                                                                  | System.Windows.Forms.AnchorStyles.Right)));
     this.textBox1.Font         = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this.textBox1.ForeColor    = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(66)))), ((int)(((byte)(66)))));
     this.textBox1.Location     = new System.Drawing.Point(39, 95);
     this.textBox1.Name         = "textBox1";
     this.textBox1.Size         = new System.Drawing.Size(179, 29);
     this.textBox1.TabIndex     = 4;
     this.textBox1.Text         = "1000";
     this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
     //
     // panel1
     //
     this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                                                                | System.Windows.Forms.AnchorStyles.Right)));
     this.panel1.BackColor = System.Drawing.Color.WhiteSmoke;
     this.panel1.Controls.Add(this.comboBox1);
     this.panel1.Controls.Add(this.label3);
     this.panel1.Controls.Add(this.checkBox1);
     this.panel1.Controls.Add(this.checkBox2);
     this.panel1.Controls.Add(this.label7);
     this.panel1.Controls.Add(this.checkBox3);
     this.panel1.Controls.Add(this.label2);
     this.panel1.Controls.Add(this.label1);
     this.panel1.Controls.Add(this.label5);
     this.panel1.Controls.Add(this.textBox2);
     this.panel1.Controls.Add(this.textBox1);
     this.panel1.Location = new System.Drawing.Point(700, 0);
     this.panel1.Name     = "panel1";
     this.panel1.Size     = new System.Drawing.Size(260, 585);
     this.panel1.TabIndex = 7;
     //
     // comboBox1
     //
     this.comboBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                                                                    | System.Windows.Forms.AnchorStyles.Left)
                                                                   | System.Windows.Forms.AnchorStyles.Right)));
     this.comboBox1.Font              = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this.comboBox1.ForeColor         = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(66)))), ((int)(((byte)(66)))));
     this.comboBox1.FormattingEnabled = true;
     this.comboBox1.Items.AddRange(new object[] {
         "5",
         "10",
         "20",
         "30",
         "60"
     });
     this.comboBox1.Location              = new System.Drawing.Point(38, 311);
     this.comboBox1.Name                  = "comboBox1";
     this.comboBox1.Size                  = new System.Drawing.Size(179, 29);
     this.comboBox1.TabIndex              = 7;
     this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
     //
     // checkBox2
     //
     this.checkBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                                                                    | System.Windows.Forms.AnchorStyles.Left)
                                                                   | System.Windows.Forms.AnchorStyles.Right)));
     this.checkBox2.AutoSize        = true;
     this.checkBox2.Checked         = true;
     this.checkBox2.CheckState      = System.Windows.Forms.CheckState.Checked;
     this.checkBox2.FlatStyle       = System.Windows.Forms.FlatStyle.System;
     this.checkBox2.Font            = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this.checkBox2.ForeColor       = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(66)))), ((int)(((byte)(66)))));
     this.checkBox2.Location        = new System.Drawing.Point(39, 352);
     this.checkBox2.Name            = "checkBox2";
     this.checkBox2.Size            = new System.Drawing.Size(122, 26);
     this.checkBox2.TabIndex        = 6;
     this.checkBox2.Text            = "Show Labels";
     this.checkBox2.CheckedChanged += new System.EventHandler(this.checkBox2_CheckedChanged);
     //
     // label7
     //
     this.label7.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                                                                 | System.Windows.Forms.AnchorStyles.Left)
                                                                | System.Windows.Forms.AnchorStyles.Right)));
     this.label7.AutoSize   = true;
     this.label7.Font       = new System.Drawing.Font("Segoe UI", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this.label7.ForeColor  = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(66)))), ((int)(((byte)(66)))));
     this.label7.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
     this.label7.Location   = new System.Drawing.Point(34, 243);
     this.label7.Name       = "label7";
     this.label7.Size       = new System.Drawing.Size(139, 25);
     this.label7.TabIndex   = 130;
     this.label7.Text       = "Horizontal Axis";
     this.label7.TextAlign  = System.Drawing.ContentAlignment.MiddleRight;
     //
     // checkBox3
     //
     this.checkBox3.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                                                                    | System.Windows.Forms.AnchorStyles.Left)
                                                                   | System.Windows.Forms.AnchorStyles.Right)));
     this.checkBox3.AutoSize        = true;
     this.checkBox3.Checked         = true;
     this.checkBox3.CheckState      = System.Windows.Forms.CheckState.Checked;
     this.checkBox3.FlatStyle       = System.Windows.Forms.FlatStyle.System;
     this.checkBox3.Font            = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this.checkBox3.ForeColor       = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(66)))), ((int)(((byte)(66)))));
     this.checkBox3.Location        = new System.Drawing.Point(41, 200);
     this.checkBox3.Name            = "checkBox3";
     this.checkBox3.Size            = new System.Drawing.Size(122, 26);
     this.checkBox3.TabIndex        = 8;
     this.checkBox3.Text            = "Show Labels";
     this.checkBox3.CheckedChanged += new System.EventHandler(this.checkBox3_CheckedChanged);
     //
     // label5
     //
     this.label5.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                                                                 | System.Windows.Forms.AnchorStyles.Left)
                                                                | System.Windows.Forms.AnchorStyles.Right)));
     this.label5.AutoSize   = true;
     this.label5.Font       = new System.Drawing.Font("Segoe UI", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this.label5.ForeColor  = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(66)))), ((int)(((byte)(66)))));
     this.label5.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
     this.label5.Location   = new System.Drawing.Point(35, 30);
     this.label5.Name       = "label5";
     this.label5.Size       = new System.Drawing.Size(115, 25);
     this.label5.TabIndex   = 128;
     this.label5.Text       = "Vertical Axis";
     this.label5.TextAlign  = System.Drawing.ContentAlignment.MiddleRight;
     //
     // chartControl1
     //
     this.chartControl1.ChartArea.CursorLocation = new System.Drawing.Point(0, 0);
     this.chartControl1.ChartArea.CursorReDraw   = false;
     this.chartControl1.ChartAreaMargins         = new Syncfusion.Windows.Forms.Chart.ChartMargins(10, 5, 20, 10);
     this.chartControl1.DataSourceName           = "";
     this.chartControl1.IsWindowLess             = false;
     //
     //
     //
     this.chartControl1.Legend.Location       = new System.Drawing.Point(581, 26);
     this.chartControl1.Localize              = null;
     this.chartControl1.Location              = new System.Drawing.Point(0, 0);
     this.chartControl1.Name                  = "chartControl1";
     this.chartControl1.PrimaryXAxis.Crossing = double.NaN;
     this.chartControl1.PrimaryXAxis.Margin   = true;
     this.chartControl1.PrimaryYAxis.Crossing = double.NaN;
     this.chartControl1.PrimaryYAxis.Margin   = true;
     this.chartControl1.Size                  = new System.Drawing.Size(700, 580);
     this.chartControl1.TabIndex              = 4;
     //
     //
     //
     this.chartControl1.Title.Name       = "Def_title";
     this.chartControl1.Title.Text       = "";
     this.chartControl1.ZoomOutIncrement = 1.5D;
     //
     // Form1
     //
     this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
     this.BackColor         = System.Drawing.Color.White;
     this.ClientSize        = new System.Drawing.Size(958, 584);
     this.Controls.Add(this.chartControl1);
     this.Controls.Add(this.panel1);
     this.Icon          = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
     this.MinimumSize   = new System.Drawing.Size(569, 448);
     this.Name          = "Form1";
     this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
     this.Text          = "Recorder Application";
     this.Load         += new System.EventHandler(this.Form1_Load);
     this.panel1.ResumeLayout(false);
     this.panel1.PerformLayout();
     this.ResumeLayout(false);
 }
示例#24
0
        public void BuildSeries(ChartControl chart)
        {
            series.Data.Clear();

            if (SeriesSources.Count == 0 || !(SeriesSources[0] is IPriceQuerySeries))
            {
                return;
            }
            var sources = (IPriceQuerySeries)SeriesSources[0];
            var candles = SeriesSources[0] is StockSeries ? ((StockSeries)SeriesSources[0]).Data.Candles : null;

            var count = SeriesSources[0].DataCount;

            if (count == 0 || Period == 0 || count <= (2 * Period))
            {
                return;
            }

            // границы - -100 ... 100
            seriesBounds.parts.Add(new PartSeries.Polyline(new PartSeriesPoint(1, -100M),
                                                           new PartSeriesPoint(count, -100M)));
            seriesBounds.parts.Add(new PartSeries.Polyline(
                                       new PartSeriesPoint(1, 100M),
                                       new PartSeriesPoint(count, 100M)));
            seriesBounds.parts.Add(new PartSeries.Polyline(
                                       new PartSeriesPoint(1, 0),
                                       new PartSeriesPoint(count, 0)));

            // пустое начало графика
            for (var i = 0; i < Period + Period; i++)
            {
                series.Data.Add(0);
            }

            // заполнить массив медианных цен (TP)
            var tpArray = new float[count];

            for (var i = 0; i < count; i++)
            {
                tpArray[i] = candles == null
                    ? (sources.GetPrice(i) ?? 0)
                    : (candles[i].high + candles[i].low + candles[i].close) / 3f;
            }

            // заполнить массив МА
            var maArray = new float[count];

            for (var i = 0; i < Period; i++)
            {
                maArray[i] = tpArray[i];
            }
            for (var i = Period; i < count; i++)
            {
                // получить MA
                var ma = 0f;
                for (var j = 0; j < Period; j++)
                {
                    ma += tpArray[i - j];
                }
                ma        /= Period;
                maArray[i] = ma;
            }

            // посчитать индикатор
            for (var i = Period + Period; i < count; i++)
            {
                var minDev = 0f;
                for (var j = 0; j < Period; j++)
                {
                    minDev += Math.Abs(tpArray[i - j] - maArray[i - j]);
                }
                minDev /= Period;
                float cci;
                if (minDev != 0)
                {
                    cci = (tpArray[i] - maArray[i]) / (0.015f * minDev);
                }
                else
                {
                    cci = 0;
                }
                series.Data.Add(cci);
            }
        }
示例#25
0
 public static void DefineXY(ChartControl chartControl,DataSet ds, string valueX, string valueY)
 {
     chartControl.Series[0].DataSource = ds.Tables[0];
     chartControl.Series[0].ArgumentDataMember = valueX;
     chartControl.Series[0].ValueDataMembers.AddRange(new string[] {valueY});
 }
示例#26
0
 private void InitializeComponent()
 {
     System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
     this.panel1            = new System.Windows.Forms.Panel();
     this.label2            = new System.Windows.Forms.Label();
     this.checkBox1         = new System.Windows.Forms.CheckBox();
     this.ColTypeCombo      = new System.Windows.Forms.ComboBox();
     this.label7            = new System.Windows.Forms.Label();
     this.groupBox2         = new System.Windows.Forms.GroupBox();
     this.rbDefaultMode     = new System.Windows.Forms.RadioButton();
     this.rbFixedMode       = new System.Windows.Forms.RadioButton();
     this.rbRelativeMode    = new System.Windows.Forms.RadioButton();
     this.udSpacing         = new System.Windows.Forms.NumericUpDown();
     this.comboBoxChartType = new System.Windows.Forms.ComboBox();
     this.label1            = new System.Windows.Forms.Label();
     this.label3            = new System.Windows.Forms.Label();
     this.label5            = new System.Windows.Forms.Label();
     this.chartControl1     = new Syncfusion.Windows.Forms.Chart.ChartControl();
     this.panel1.SuspendLayout();
     this.groupBox2.SuspendLayout();
     ((System.ComponentModel.ISupportInitialize)(this.udSpacing)).BeginInit();
     this.SuspendLayout();
     //
     // panel1
     //
     this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                                                                | System.Windows.Forms.AnchorStyles.Right)));
     this.panel1.AutoScrollMargin = new System.Drawing.Size(0, 20);
     this.panel1.BackColor        = System.Drawing.Color.WhiteSmoke;
     this.panel1.Controls.Add(this.label2);
     this.panel1.Controls.Add(this.checkBox1);
     this.panel1.Controls.Add(this.ColTypeCombo);
     this.panel1.Controls.Add(this.label7);
     this.panel1.Controls.Add(this.groupBox2);
     this.panel1.Controls.Add(this.udSpacing);
     this.panel1.Controls.Add(this.comboBoxChartType);
     this.panel1.Controls.Add(this.label1);
     this.panel1.Controls.Add(this.label3);
     this.panel1.Controls.Add(this.label5);
     this.panel1.Location = new System.Drawing.Point(700, 0);
     this.panel1.Name     = "panel1";
     this.panel1.Size     = new System.Drawing.Size(260, 585);
     this.panel1.TabIndex = 4;
     //
     // label2
     //
     this.label2.AutoSize  = true;
     this.label2.Font      = new System.Drawing.Font("Segoe UI", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this.label2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(66)))), ((int)(((byte)(66)))));
     this.label2.Location  = new System.Drawing.Point(36, 351);
     this.label2.Name      = "label2";
     this.label2.Size      = new System.Drawing.Size(35, 25);
     this.label2.TabIndex  = 127;
     this.label2.Text      = "3D";
     //
     // checkBox1
     //
     this.checkBox1.AutoSize  = true;
     this.checkBox1.Font      = new System.Drawing.Font("Segoe UI", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this.checkBox1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(66)))), ((int)(((byte)(66)))));
     this.checkBox1.Location  = new System.Drawing.Point(40, 391);
     this.checkBox1.Name      = "checkBox1";
     this.checkBox1.Size      = new System.Drawing.Size(83, 24);
     this.checkBox1.TabIndex  = 15;
     this.checkBox1.Text      = "3D View";
     this.checkBox1.UseVisualStyleBackColor = true;
     this.checkBox1.CheckedChanged         += new System.EventHandler(this.checkBox1_CheckedChanged);
     //
     // ColTypeCombo
     //
     this.ColTypeCombo.DropDownStyle         = System.Windows.Forms.ComboBoxStyle.DropDownList;
     this.ColTypeCombo.Enabled               = false;
     this.ColTypeCombo.FlatStyle             = System.Windows.Forms.FlatStyle.System;
     this.ColTypeCombo.Font                  = new System.Drawing.Font("Segoe UI", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this.ColTypeCombo.ForeColor             = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(66)))), ((int)(((byte)(66)))));
     this.ColTypeCombo.FormattingEnabled     = true;
     this.ColTypeCombo.Location              = new System.Drawing.Point(39, 469);
     this.ColTypeCombo.Name                  = "ColTypeCombo";
     this.ColTypeCombo.Size                  = new System.Drawing.Size(168, 28);
     this.ColTypeCombo.TabIndex              = 14;
     this.ColTypeCombo.SelectedIndexChanged += new System.EventHandler(this.ColTypeCombo_SelectedIndexChanged);
     //
     // label7
     //
     this.label7.AutoSize  = true;
     this.label7.Font      = new System.Drawing.Font("Segoe UI", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this.label7.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(120)))), ((int)(((byte)(120)))), ((int)(((byte)(120)))));
     this.label7.Location  = new System.Drawing.Point(36, 439);
     this.label7.Name      = "label7";
     this.label7.Size      = new System.Drawing.Size(96, 20);
     this.label7.TabIndex  = 12;
     this.label7.Text      = "Column Type";
     //
     // groupBox2
     //
     this.groupBox2.Controls.Add(this.rbDefaultMode);
     this.groupBox2.Controls.Add(this.rbFixedMode);
     this.groupBox2.Controls.Add(this.rbRelativeMode);
     this.groupBox2.Font      = new System.Drawing.Font("Segoe UI", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this.groupBox2.ForeColor = System.Drawing.Color.Black;
     this.groupBox2.Location  = new System.Drawing.Point(40, 133);
     this.groupBox2.Name      = "groupBox2";
     this.groupBox2.Size      = new System.Drawing.Size(167, 128);
     this.groupBox2.TabIndex  = 11;
     this.groupBox2.TabStop   = false;
     //
     // rbDefaultMode
     //
     this.rbDefaultMode.Checked         = true;
     this.rbDefaultMode.FlatStyle       = System.Windows.Forms.FlatStyle.System;
     this.rbDefaultMode.Font            = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this.rbDefaultMode.ForeColor       = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(66)))), ((int)(((byte)(66)))));
     this.rbDefaultMode.Location        = new System.Drawing.Point(14, 12);
     this.rbDefaultMode.Name            = "rbDefaultMode";
     this.rbDefaultMode.Size            = new System.Drawing.Size(143, 35);
     this.rbDefaultMode.TabIndex        = 0;
     this.rbDefaultMode.TabStop         = true;
     this.rbDefaultMode.Text            = "Default";
     this.rbDefaultMode.CheckedChanged += new System.EventHandler(this.radioButtonWidthMode_CheckedChanged);
     //
     // rbFixedMode
     //
     this.rbFixedMode.FlatStyle       = System.Windows.Forms.FlatStyle.System;
     this.rbFixedMode.Font            = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this.rbFixedMode.ForeColor       = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(66)))), ((int)(((byte)(66)))));
     this.rbFixedMode.Location        = new System.Drawing.Point(14, 91);
     this.rbFixedMode.Name            = "rbFixedMode";
     this.rbFixedMode.Size            = new System.Drawing.Size(104, 30);
     this.rbFixedMode.TabIndex        = 1;
     this.rbFixedMode.Text            = "Fixed";
     this.rbFixedMode.CheckedChanged += new System.EventHandler(this.radioButtonWidthMode_CheckedChanged);
     //
     // rbRelativeMode
     //
     this.rbRelativeMode.FlatStyle       = System.Windows.Forms.FlatStyle.System;
     this.rbRelativeMode.Font            = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this.rbRelativeMode.ForeColor       = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(66)))), ((int)(((byte)(66)))));
     this.rbRelativeMode.Location        = new System.Drawing.Point(14, 53);
     this.rbRelativeMode.Name            = "rbRelativeMode";
     this.rbRelativeMode.Size            = new System.Drawing.Size(118, 32);
     this.rbRelativeMode.TabIndex        = 2;
     this.rbRelativeMode.Text            = "Relative";
     this.rbRelativeMode.CheckedChanged += new System.EventHandler(this.radioButtonWidthMode_CheckedChanged);
     //
     // udSpacing
     //
     this.udSpacing.Font      = new System.Drawing.Font("Segoe UI", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this.udSpacing.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(66)))), ((int)(((byte)(66)))));
     this.udSpacing.Increment = new decimal(new int[] {
         10,
         0,
         0,
         0
     });
     this.udSpacing.Location      = new System.Drawing.Point(40, 309);
     this.udSpacing.Name          = "udSpacing";
     this.udSpacing.ReadOnly      = true;
     this.udSpacing.Size          = new System.Drawing.Size(167, 27);
     this.udSpacing.TabIndex      = 0;
     this.udSpacing.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged);
     //
     // comboBoxChartType
     //
     this.comboBoxChartType.DropDownStyle         = System.Windows.Forms.ComboBoxStyle.DropDownList;
     this.comboBoxChartType.FlatStyle             = System.Windows.Forms.FlatStyle.System;
     this.comboBoxChartType.Font                  = new System.Drawing.Font("Segoe UI", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this.comboBoxChartType.ForeColor             = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(66)))), ((int)(((byte)(66)))));
     this.comboBoxChartType.Location              = new System.Drawing.Point(43, 62);
     this.comboBoxChartType.Name                  = "comboBoxChartType";
     this.comboBoxChartType.Size                  = new System.Drawing.Size(167, 28);
     this.comboBoxChartType.TabIndex              = 4;
     this.comboBoxChartType.SelectedIndexChanged += new System.EventHandler(this.comboBoxChartType_SelectedIndexChanged);
     //
     // label1
     //
     this.label1.Font      = new System.Drawing.Font("Segoe UI", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this.label1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(66)))), ((int)(((byte)(66)))));
     this.label1.Location  = new System.Drawing.Point(39, 30);
     this.label1.Name      = "label1";
     this.label1.Size      = new System.Drawing.Size(96, 26);
     this.label1.TabIndex  = 3;
     this.label1.Text      = "Chart Type";
     //
     // label3
     //
     this.label3.AutoSize  = true;
     this.label3.BackColor = System.Drawing.Color.Transparent;
     this.label3.Font      = new System.Drawing.Font("Segoe UI", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this.label3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(66)))), ((int)(((byte)(66)))));
     this.label3.Location  = new System.Drawing.Point(39, 106);
     this.label3.Name      = "label3";
     this.label3.Size      = new System.Drawing.Size(92, 20);
     this.label3.TabIndex  = 4;
     this.label3.Text      = "Width Mode";
     //
     // label5
     //
     this.label5.AutoSize  = true;
     this.label5.BackColor = System.Drawing.Color.Transparent;
     this.label5.Font      = new System.Drawing.Font("Segoe UI", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this.label5.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(66)))), ((int)(((byte)(66)))));
     this.label5.Location  = new System.Drawing.Point(36, 276);
     this.label5.Name      = "label5";
     this.label5.Size      = new System.Drawing.Size(62, 20);
     this.label5.TabIndex  = 6;
     this.label5.Text      = "Spacing";
     //
     // chartControl1
     //
     this.chartControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                                                                        | System.Windows.Forms.AnchorStyles.Left)
                                                                       | System.Windows.Forms.AnchorStyles.Right)));
     this.chartControl1.BackInterior             = new Syncfusion.Drawing.BrushInfo(Syncfusion.Drawing.GradientStyle.Vertical, System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(224)))), ((int)(((byte)(193))))), System.Drawing.Color.White);
     this.chartControl1.ChartArea.BackInterior   = new Syncfusion.Drawing.BrushInfo(Syncfusion.Drawing.GradientStyle.Vertical, System.Drawing.Color.Transparent, System.Drawing.Color.Transparent);
     this.chartControl1.ChartArea.CursorLocation = new System.Drawing.Point(0, 0);
     this.chartControl1.ChartArea.CursorReDraw   = false;
     this.chartControl1.ChartAreaMargins         = new Syncfusion.Windows.Forms.Chart.ChartMargins(6, 6, 15, 6);
     this.chartControl1.ChartInterior            = new Syncfusion.Drawing.BrushInfo(Syncfusion.Drawing.GradientStyle.Horizontal, System.Drawing.Color.Transparent, System.Drawing.Color.Transparent);
     this.chartControl1.DataSourceName           = "";
     this.chartControl1.ElementsSpacing          = 0;
     this.chartControl1.Font         = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this.chartControl1.IsWindowLess = false;
     //
     //
     //
     this.chartControl1.Legend.BackInterior     = new Syncfusion.Drawing.BrushInfo(Syncfusion.Drawing.GradientStyle.Vertical, System.Drawing.Color.Transparent, System.Drawing.Color.Transparent);
     this.chartControl1.Legend.Border.ForeColor = System.Drawing.Color.Transparent;
     this.chartControl1.Legend.Location         = new System.Drawing.Point(606, 41);
     this.chartControl1.Localize = null;
     this.chartControl1.Location = new System.Drawing.Point(0, 0);
     this.chartControl1.Name     = "chartControl1";
     this.chartControl1.Palette  = Syncfusion.Windows.Forms.Chart.ChartColorPalette.Pastel;
     this.chartControl1.PrimaryXAxis.Crossing = double.NaN;
     this.chartControl1.PrimaryXAxis.Margin   = true;
     this.chartControl1.PrimaryYAxis.Crossing = double.NaN;
     this.chartControl1.PrimaryYAxis.Margin   = true;
     this.chartControl1.Size     = new System.Drawing.Size(700, 580);
     this.chartControl1.TabIndex = 5;
     this.chartControl1.Text     = "Essential Chart";
     //
     //
     //
     this.chartControl1.Title.Name = "Def_title";
     this.chartControl1.Title.Text = "Essential Chart";
     this.chartControl1.Titles.Add(this.chartControl1.Title);
     //
     // Form1
     //
     this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
     this.BackColor         = System.Drawing.Color.White;
     this.ClientSize        = new System.Drawing.Size(958, 584);
     this.Controls.Add(this.chartControl1);
     this.Controls.Add(this.panel1);
     this.Icon          = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
     this.MinimumSize   = new System.Drawing.Size(626, 428);
     this.Name          = "Form1";
     this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
     this.Text          = "Column";
     this.Load         += new System.EventHandler(this.Form1_Load);
     this.panel1.ResumeLayout(false);
     this.panel1.PerformLayout();
     this.groupBox2.ResumeLayout(false);
     ((System.ComponentModel.ISupportInitialize)(this.udSpacing)).EndInit();
     this.ResumeLayout(false);
 }
示例#27
0
        public static void PrintPreview(ChartControl chartControl, GridControl grid)
        {
            chartControl.OptionsPrint.SizeMode = DevExpress.XtraCharts.Printing.PrintSizeMode.Zoom;
            CompositeLink composLink = new CompositeLink(new PrintingSystem());
            PrintableComponentLink pcLink1 = new PrintableComponentLink();
            PrintableComponentLink pcLink2 = new PrintableComponentLink();
            Link linkMainReport = new Link();

            linkMainReport.CreateDetailArea += new CreateAreaEventHandler(linkMainReport_CreateDetailArea);
            Link linkGrid1Report = new Link();
            linkGrid1Report.CreateDetailArea += new CreateAreaEventHandler(linkGrid1Report_CreateDetailArea);
            Link linkGrid2Report = new Link();
            linkGrid2Report.CreateDetailArea += new CreateAreaEventHandler(linkChartReport_CreateDetailArea);

            pcLink1.Component = grid;
            pcLink2.Component = chartControl;

            composLink.Links.Add(linkGrid2Report);
            composLink.Links.Add(pcLink2);
            composLink.Links.Add(linkGrid1Report);
            composLink.Links.Add(pcLink1);
            composLink.Links.Add(linkMainReport);
            composLink.ShowPreviewDialog();
        }
示例#28
0
        public void GetChartReport(ChartControl chartMain, bool first)
        {
            string chartField1 = _data.DrTable["ChartField1"].ToString(); //.ToUpper();
            string chartField2 = _data.DrTable["ChartField2"].ToString(); //.ToUpper();
            string chartField3 = _data.DrTable["ChartField3"].ToString(); //.ToUpper();

            if (chartField1 == string.Empty && chartField2 == string.Empty && chartField3 == string.Empty)
            {
                return;
            }
            _data.GetDataForReport();

            string[] sss = chartField3.Split(',');
            ViewType vt  = ViewType.Bar;

            //if (_data.DtReportData.Rows.Count > 5 && sss.Length >= 2)
            //    vt = ViewType.StackedBar;
            //if (_data.DtReportData.Rows.Count > 4 && sss.Length >= 3)
            //    vt = ViewType.StackedBar;

            chartMain.DataSource = _data.DtReportData;
            Series s1 = new Series(chartField2, vt);

            s1.DataSource         = _data.DtReportData;
            s1.ArgumentDataMember = chartField1;
            s1.LegendText         = chartField2 + ": " + GetSum(chartField2);
            s1.ValueDataMembers.AddRange(new string[] { chartField2 });
            s1.ValueScaleType         = ScaleType.Numerical;
            s1.PointOptions.PointView = PointView.Values;
            s1.PointOptions.ValueNumericOptions.Format    = NumericFormat.Number;
            s1.PointOptions.ValueNumericOptions.Precision = 0;

            chartMain.Series.Clear();
            chartMain.Series.Add(s1);

            for (int i = 0; i < sss.Length; i++)
            {
                string ss = sss[i].Trim();
                Series s2 = new Series(ss, vt);
                s2.DataSource         = _data.DtReportData;
                s2.ArgumentDataMember = chartField1;
                s2.LegendText         = ss + ": " + GetSum(ss);
                s2.ValueDataMembers.AddRange(new string[] { ss });
                s2.ValueScaleType         = ScaleType.Numerical;
                s2.PointOptions.PointView = PointView.Values;
                s2.PointOptions.ValueNumericOptions.Format    = NumericFormat.Number;
                s2.PointOptions.ValueNumericOptions.Precision = 0;
                chartMain.Series.Add(s2);
            }
            ChartTitle chartTitle = new ChartTitle();

            chartTitle.Text      = Config.GetValue("Language").ToString() == "0" ? _drReport["MenuName"].ToString() : _drReport["MenuName2"].ToString();
            chartTitle.Font      = new System.Drawing.Font("Tahoma", 14);
            chartTitle.TextColor = System.Drawing.Color.RoyalBlue;
            chartMain.Titles.Clear();
            chartMain.Titles.Add(chartTitle);
            chartMain.Legend.AlignmentHorizontal = LegendAlignmentHorizontal.Left;
            chartMain.Legend.AlignmentVertical   = LegendAlignmentVertical.BottomOutside;
            chartMain.Legend.Direction           = LegendDirection.LeftToRight;
            XYDiagram d = (XYDiagram)chartMain.Diagram;

            d.AxisY.NumericOptions.Format    = NumericFormat.Number;
            d.AxisY.NumericOptions.Precision = 0;
            if (first && _data.DrTable["LinkField"].ToString() != "")
            {
                chartMain.DoubleClick += new EventHandler(chartMain_DoubleClick);
            }
        }
示例#29
0
 public static void SetSelectionRuntime(ChartControl chartControl, bool isSelection)
 {
     chartControl.RuntimeSelection = isSelection;
     chartControl.RuntimeSeriesSelectionMode = SeriesSelectionMode.Point;
 }
示例#30
0
 protected void BotMenuItem1SubItem1_Click(object sender, RoutedEventArgs e)
 {
     Draw.TextFixed(this, "infobox", "M1I1 - Bottom menu subitem 1 selected", TextPosition.BottomLeft, Brushes.Green, new Gui.Tools.SimpleFont("Arial", 25), Brushes.Transparent, Brushes.Transparent, 100);
     ChartControl.InvalidateVisual();
 }
示例#31
0
 public static void ChangePieView(ChartControl chartControl)
 {
     if (TypeChart == 1)
     {
         foreach (Series series in chartControl.Series)
         {
             series.ChangeView(ViewType.Pie);
             series.LegendPointOptions.PointView = PointView.Argument;
             series.PointOptions.ValueNumericOptions.Format = NumericFormat.Percent;
             series.PointOptions.ValueNumericOptions.Precision = 2;
         }
     }
     else
     {
         //danh cho truong hop di lieu 3 chieu XYZ
     }
 }
示例#32
0
 protected void BotMenuItem2_Click(object sender, RoutedEventArgs e)
 {
     Draw.TextFixed(this, "infobox", "B1 - Bottom button clicked", TextPosition.BottomLeft, Brushes.OrangeRed, new Gui.Tools.SimpleFont("Arial", 25), Brushes.Transparent, Brushes.Transparent, 100);
     // only invalidate the chart so that the text box will appear even if there is no incoming data
     ChartControl.InvalidateVisual();
 }
示例#33
0
        private void ApplyAnalysisFilter_Execute(object sender, SimpleActionExecuteEventArgs e)
        {
            //((XafExtAnalysis)View.CurrentObject).IsFilterVisible = true;   // !((XafExtAnalysis)View.CurrentObject).IsFilterVisible;

            XafExtAnalysis currentObject = detailView.CurrentObject as XafExtAnalysis;

            if (currentObject == null)
            {
                return;
            }

            // Добавляем преднастроенный фильтр, если он определён
            if (wp != null)
            {
                if (string.IsNullOrEmpty(currentObject.AdminCriteria))
                {
                    currentObject.Criteria = wp.CriterionString;
                }
                else
                {
                    currentObject.Criteria = "(" + currentObject.AdminCriteria + ")" + "(" + wp.CriterionString + ")";
                }
            }
            else
            {
                if (!string.IsNullOrEmpty(currentObject.AdminCriteria))
                {
                    currentObject.Criteria = currentObject.AdminCriteria;
                }
            }

            // Подключаемся к ListViewProcessCurrentObjectController
            if (analysisDataBindController != null)
            {
                AnalysisEditorWin         analysisEditor  = null;
                IList <AnalysisEditorWin> analysisEditors = detailView.GetItems <AnalysisEditorWin>();
                if (analysisEditors.Count == 1)
                {
                    analysisEditor = analysisEditors[0];

                    if (analysisEditor.IsDataSourceReady)
                    {
                        ChartControl     chartControl     = ((AnalysisControlWin)analysisEditor.Control).ChartControl;
                        PivotGridControl pivotGridControl = ((AnalysisControlWin)analysisEditor.Control).PivotGrid;

                        //    Type currentType = currentObject.DataType.UnderlyingSystemType;
                        //    XPCollection xpDataSource = new XPCollection(currentObject.Session, currentType);
                        //    xpDataSource.CriteriaString = currentObject.Criteria;
                        //    if (!xpDataSource.IsLoaded) xpDataSource.Load();

                        //    pivotGridControl.DataSource = xpDataSource;
                        ////pivotGridControl.Fields.A
                        //    //(pivotGridControl.DataSource as XPCollection).CriteriaString = currentObject.Criteria.ToString();

                        pivotGridControl.RefreshData();
                        chartControl.RefreshData();
                        //pivotGridControl.Update();
                        //// Do what you want with the chart and pivot grid controls
                        //foreach (PivotGridField field in pivotGridControl.Fields) {
                        //    field.Visible = true;
                        //}
                    }
                    else
                    {
                        ExecStandartAction(analysisDataBindController.BindDataAction);
                    }
                }
            }
        }
示例#34
0
 protected void RightMenu1Item1SubItem2_Click(object sender, RoutedEventArgs e)
 {
     Draw.TextFixed(this, "infobox", "M2I2 - Right menu subitem 2 selected", TextPosition.BottomLeft, Brushes.DarkOrchid, new Gui.Tools.SimpleFont("Arial", 25), Brushes.Transparent, Brushes.Transparent, 100);
     ChartControl.InvalidateVisual();
 }
示例#35
0
        public override void OnRender(ChartControl chartControl, ChartScale chartScale, ChartBars chartBars)
        {
            Bars bars = chartBars.Bars;

            if (chartBars.FromIndex > 0)
            {
                chartBars.FromIndex--;
            }

            SharpDX.Direct2D1.PathGeometry lineGeometry = new SharpDX.Direct2D1.PathGeometry(Core.Globals.D2DFactory);
            AntialiasMode oldAliasMode = RenderTarget.AntialiasMode;
            GeometrySink  sink         = lineGeometry.Open();

            sink.BeginFigure(new Vector2(chartControl.GetXByBarIndex(chartBars, chartBars.FromIndex > -1 ? chartBars.FromIndex : 0), chartScale.GetYByValue(bars.GetClose(chartBars.FromIndex > -1 ? chartBars.FromIndex : 0))), FigureBegin.Filled);

            for (int idx = chartBars.FromIndex + 1; idx <= chartBars.ToIndex; idx++)
            {
                double closeValue = bars.GetClose(idx);
                float  close      = chartScale.GetYByValue(closeValue);
                float  x          = chartControl.GetXByBarIndex(chartBars, idx);
                sink.AddLine(new Vector2(x, close));
            }

            sink.EndFigure(FigureEnd.Open);
            sink.Close();
            RenderTarget.AntialiasMode = AntialiasMode.PerPrimitive;
            RenderTarget.DrawGeometry(lineGeometry, UpBrushDX, (float)Math.Max(1, chartBars.Properties.ChartStyle.BarWidth));
            lineGeometry.Dispose();

            SharpDX.Direct2D1.SolidColorBrush fillOutline  = new SharpDX.Direct2D1.SolidColorBrush(RenderTarget, SharpDX.Color.Transparent);
            SharpDX.Direct2D1.PathGeometry    fillGeometry = new SharpDX.Direct2D1.PathGeometry(Core.Globals.D2DFactory);
            GeometrySink fillSink = fillGeometry.Open();

            fillSink.BeginFigure(new Vector2(chartControl.GetXByBarIndex(chartBars, chartBars.FromIndex > -1 ? chartBars.FromIndex : 0), chartScale.GetYByValue(chartScale.MinValue)), FigureBegin.Filled);
            float fillx = float.NaN;

            for (int idx = chartBars.FromIndex; idx <= chartBars.ToIndex; idx++)
            {
                double closeValue = bars.GetClose(idx);
                float  close      = chartScale.GetYByValue(closeValue);
                fillx = chartControl.GetXByBarIndex(chartBars, idx);
                fillSink.AddLine(new Vector2(fillx, close));
            }
            if (!double.IsNaN(fillx))
            {
                fillSink.AddLine(new Vector2(fillx, chartScale.GetYByValue(chartScale.MinValue)));
            }

            fillSink.EndFigure(FigureEnd.Open);
            fillSink.Close();
            DownBrushDX.Opacity = Opacity / 100f;
            if (!(DownBrushDX is SharpDX.Direct2D1.SolidColorBrush))
            {
                TransformBrush(DownBrushDX, new RectangleF(0, 0, (float)chartScale.Width, (float)chartScale.Height));
            }
            RenderTarget.FillGeometry(fillGeometry, DownBrushDX);
            RenderTarget.DrawGeometry(fillGeometry, fillOutline, (float)chartBars.Properties.ChartStyle.BarWidth);
            fillOutline.Dispose();
            RenderTarget.AntialiasMode = oldAliasMode;
            fillGeometry.Dispose();
        }
示例#36
0
 protected void RightMenu2Item1_Click(object sender, RoutedEventArgs e)
 {
     Draw.TextFixed(this, "infobox", "B2 - Right button clicked", TextPosition.BottomLeft, Brushes.MediumTurquoise, new Gui.Tools.SimpleFont("Arial", 25), Brushes.Transparent, Brushes.Transparent, 100);
     ChartControl.InvalidateVisual();
 }
        public override void OnRender(ChartControl chartControl, ChartScale chartScale)
        {
            //Allow user to change ZOrder when manually drawn on chart
            if (!hasSetZOrder && !StartAnchor.IsNinjaScriptDrawn)
            {
                ZOrderType   = DrawingToolZOrder.Normal;
                ZOrder       = ChartPanel.ChartObjects.Min(z => z.ZOrder) - 1;
                hasSetZOrder = true;
            }
            RenderTarget.AntialiasMode = SharpDX.Direct2D1.AntialiasMode.PerPrimitive;
            Stroke outlineStroke = OutlineStroke;

            outlineStroke.RenderTarget = RenderTarget;
            ChartPanel chartPanel = chartControl.ChartPanels[PanelIndex];

            // recenter region anchors to always be onscreen/centered
            double middleX = chartPanel.X + chartPanel.W / 2d;
            double middleY = chartPanel.Y + chartPanel.H / 2d;

            if (Mode == RegionHighlightMode.Price)
            {
                StartAnchor.UpdateXFromPoint(new Point(middleX, 0), chartControl, chartScale);
                EndAnchor.UpdateXFromPoint(new Point(middleX, 0), chartControl, chartScale);
            }
            else
            {
                StartAnchor.UpdateYFromDevicePoint(new Point(0, middleY), chartScale);
                EndAnchor.UpdateYFromDevicePoint(new Point(0, middleY), chartScale);
            }

            Point  startPoint = StartAnchor.GetPoint(chartControl, chartPanel, chartScale);
            Point  endPoint   = EndAnchor.GetPoint(chartControl, chartPanel, chartScale);
            double width      = endPoint.X - startPoint.X;

            AnchorLineStroke.RenderTarget = RenderTarget;

            if (!IsInHitTest && AreaBrush != null)
            {
                if (areaBrushDevice.Brush == null)
                {
                    Brush brushCopy = areaBrush.Clone();
                    brushCopy.Opacity     = areaOpacity / 100d;
                    areaBrushDevice.Brush = brushCopy;
                }
                areaBrushDevice.RenderTarget = RenderTarget;
            }
            else
            {
                areaBrushDevice.RenderTarget = null;
                areaBrushDevice.Brush        = null;
            }

            // align to full pixel to avoid unneeded aliasing
            float strokePixAdjust = Math.Abs(outlineStroke.Width % 2d).ApproxCompare(0) == 0 ? 0.5f : 0f;

            SharpDX.RectangleF rect = Mode == RegionHighlightMode.Time ?
                                      new SharpDX.RectangleF((float)startPoint.X + strokePixAdjust, ChartPanel.Y - outlineStroke.Width + strokePixAdjust,
                                                             (float)width, chartPanel.Y + chartPanel.H + outlineStroke.Width * 2) :
                                      new SharpDX.RectangleF(chartPanel.X - outlineStroke.Width + strokePixAdjust, (float)startPoint.Y + strokePixAdjust,
                                                             chartPanel.X + chartPanel.W + outlineStroke.Width * 2, (float)(endPoint.Y - startPoint.Y));

            if (!IsInHitTest && areaBrushDevice.BrushDX != null)
            {
                RenderTarget.FillRectangle(rect, areaBrushDevice.BrushDX);
            }

            SharpDX.Direct2D1.Brush tmpBrush = IsInHitTest ? chartControl.SelectionBrush : outlineStroke.BrushDX;
            RenderTarget.DrawRectangle(rect, tmpBrush, outlineStroke.Width, outlineStroke.StrokeStyle);

            if (IsSelected)
            {
                tmpBrush = IsInHitTest ? chartControl.SelectionBrush : AnchorLineStroke.BrushDX;
                RenderTarget.DrawLine(startPoint.ToVector2(), endPoint.ToVector2(), tmpBrush, AnchorLineStroke.Width, AnchorLineStroke.StrokeStyle);
            }
        }
示例#38
0
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     this.components = new System.ComponentModel.Container();
     System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
     this.checkBox_Drag = new System.Windows.Forms.CheckBox();
     this.panel1        = new System.Windows.Forms.Panel();
     this.checkBox1     = new System.Windows.Forms.CheckBox();
     this.chartControl1 = new Syncfusion.Windows.Forms.Chart.ChartControl();
     this.toolTip1      = new System.Windows.Forms.ToolTip(this.components);
     this.panel1.SuspendLayout();
     this.SuspendLayout();
     //
     // checkBox_Drag
     //
     this.checkBox_Drag.Font      = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this.checkBox_Drag.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(66)))), ((int)(((byte)(66)))));
     this.checkBox_Drag.Location  = new System.Drawing.Point(56, 66);
     this.checkBox_Drag.Name      = "checkBox_Drag";
     this.checkBox_Drag.Size      = new System.Drawing.Size(151, 27);
     this.checkBox_Drag.TabIndex  = 3;
     this.checkBox_Drag.Text      = "Drag And Drop";
     //
     // panel1
     //
     this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                                                                | System.Windows.Forms.AnchorStyles.Right)));
     this.panel1.BackColor = System.Drawing.Color.WhiteSmoke;
     this.panel1.Controls.Add(this.checkBox1);
     this.panel1.Controls.Add(this.checkBox_Drag);
     this.panel1.Location = new System.Drawing.Point(700, 0);
     this.panel1.Name     = "panel1";
     this.panel1.Size     = new System.Drawing.Size(260, 580);
     this.panel1.TabIndex = 2;
     //
     // checkBox1
     //
     this.checkBox1.Font            = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this.checkBox1.ForeColor       = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(66)))), ((int)(((byte)(66)))));
     this.checkBox1.Location        = new System.Drawing.Point(56, 30);
     this.checkBox1.Name            = "checkBox1";
     this.checkBox1.Size            = new System.Drawing.Size(112, 27);
     this.checkBox1.TabIndex        = 4;
     this.checkBox1.Text            = "Enable 3D";
     this.checkBox1.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged);
     //
     // chartControl1
     //
     this.chartControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                                                                        | System.Windows.Forms.AnchorStyles.Left)
                                                                       | System.Windows.Forms.AnchorStyles.Right)));
     this.chartControl1.BackInterior = new Syncfusion.Drawing.BrushInfo(Syncfusion.Drawing.GradientStyle.Vertical, System.Drawing.Color.FromArgb(((int)(((byte)(250)))), ((int)(((byte)(250)))), ((int)(((byte)(250))))), System.Drawing.Color.White);
     this.chartControl1.BorderAppearance.Interior.ForeColor = System.Drawing.Color.Transparent;
     this.chartControl1.ChartArea.BackInterior    = new Syncfusion.Drawing.BrushInfo(Syncfusion.Drawing.GradientStyle.None, System.Drawing.Color.White, System.Drawing.Color.White);
     this.chartControl1.ChartArea.CursorLocation  = new System.Drawing.Point(0, 0);
     this.chartControl1.ChartArea.CursorReDraw    = false;
     this.chartControl1.ChartArea.XAxesLayoutMode = Syncfusion.Windows.Forms.Chart.ChartAxesLayoutMode.SideBySide;
     this.chartControl1.ChartArea.YAxesLayoutMode = Syncfusion.Windows.Forms.Chart.ChartAxesLayoutMode.SideBySide;
     this.chartControl1.ChartAreaMargins          = new Syncfusion.Windows.Forms.Chart.ChartMargins(5, 5, 5, 2);
     this.chartControl1.ChartInterior             = new Syncfusion.Drawing.BrushInfo(Syncfusion.Drawing.GradientStyle.BackwardDiagonal, System.Drawing.Color.FromArgb(((int)(((byte)(250)))), ((int)(((byte)(250)))), ((int)(((byte)(250))))), System.Drawing.Color.FromArgb(((int)(((byte)(250)))), ((int)(((byte)(250)))), ((int)(((byte)(250))))));
     this.chartControl1.ColumnFixedWidth          = 35;
     this.chartControl1.DataSourceName            = "";
     this.chartControl1.Font         = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this.chartControl1.IsWindowLess = false;
     //
     //
     //
     this.chartControl1.Legend.Alignment        = Syncfusion.Windows.Forms.Chart.ChartAlignment.Center;
     this.chartControl1.Legend.BackInterior     = new Syncfusion.Drawing.BrushInfo(Syncfusion.Drawing.GradientStyle.Vertical, System.Drawing.Color.Transparent, System.Drawing.Color.Transparent);
     this.chartControl1.Legend.Border.ForeColor = System.Drawing.Color.Transparent;
     this.chartControl1.Legend.Font             = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this.chartControl1.Legend.ItemsSize        = new System.Drawing.Size(15, 15);
     this.chartControl1.Legend.Location         = new System.Drawing.Point(318, 46);
     this.chartControl1.Legend.Orientation      = Syncfusion.Windows.Forms.Chart.ChartOrientation.Horizontal;
     this.chartControl1.Legend.Position         = Syncfusion.Windows.Forms.Chart.ChartDock.Top;
     this.chartControl1.Legend.Spacing          = 3;
     this.chartControl1.LegendsPlacement        = Syncfusion.Windows.Forms.Chart.ChartPlacement.Outside;
     this.chartControl1.Localize = null;
     this.chartControl1.Location = new System.Drawing.Point(0, 0);
     this.chartControl1.Name     = "chartControl1";
     this.chartControl1.PrimaryXAxis.Crossing = double.NaN;
     this.chartControl1.PrimaryXAxis.Font     = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this.chartControl1.PrimaryXAxis.GridLineType.ForeColor = System.Drawing.Color.Transparent;
     this.chartControl1.PrimaryXAxis.LineType.ForeColor     = System.Drawing.Color.DarkGray;
     this.chartControl1.PrimaryXAxis.Margin = true;
     this.chartControl1.PrimaryXAxis.SmartDateZoomMonthLevelLabelFormat = "m";
     this.chartControl1.PrimaryYAxis.Crossing = double.NaN;
     this.chartControl1.PrimaryYAxis.Font     = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this.chartControl1.PrimaryYAxis.GridLineType.ForeColor = System.Drawing.Color.Transparent;
     this.chartControl1.PrimaryYAxis.LineType.ForeColor     = System.Drawing.Color.DarkGray;
     this.chartControl1.PrimaryYAxis.Margin = true;
     this.chartControl1.PrimaryYAxis.SmartDateZoomMonthLevelLabelFormat = "m";
     this.chartControl1.Size          = new System.Drawing.Size(700, 580);
     this.chartControl1.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
     this.chartControl1.TabIndex      = 3;
     this.chartControl1.Text          = "Essential Chart";
     //
     //
     //
     this.chartControl1.Title.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this.chartControl1.Title.Name = "Def_title";
     this.chartControl1.Title.Text = "Essential Chart";
     this.chartControl1.Titles.Add(this.chartControl1.Title);
     this.chartControl1.ZoomOutIncrement      = 1.5D;
     this.chartControl1.ChartFormatAxisLabel += new Syncfusion.Windows.Forms.Chart.ChartFormatAxisLabelEventHandler(this.chartControl1_ChartFormatAxisLabel);
     this.chartControl1.ChartRegionMouseMove += new Syncfusion.Windows.Forms.Chart.ChartRegionMouseEventHandler(this.chartControl1_ChartRegionMouseMove);
     this.chartControl1.ChartRegionMouseUp   += new Syncfusion.Windows.Forms.Chart.ChartRegionMouseEventHandler(this.chartControl1_ChartRegionMouseUp);
     //
     // Form1
     //
     this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
     this.BackColor         = System.Drawing.Color.White;
     this.ClientSize        = new System.Drawing.Size(958, 584);
     this.Controls.Add(this.chartControl1);
     this.Controls.Add(this.panel1);
     this.ForeColor     = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(66)))), ((int)(((byte)(66)))));
     this.Icon          = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
     this.MinimumSize   = new System.Drawing.Size(706, 428);
     this.Name          = "Form1";
     this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
     this.Text          = "Gantt";
     this.Load         += new System.EventHandler(this.Form1_Load);
     this.panel1.ResumeLayout(false);
     this.ResumeLayout(false);
 }
示例#39
0
 public static void DefineCaption_Y(ChartControl chartControl, string caption)
 {
     ((XYDiagram)chartControl.Diagram).AxisY.Title.Text = caption;
     ((XYDiagram)chartControl.Diagram).AxisY.Title.Visible = true;
     ((XYDiagram)chartControl.Diagram).AxisY.Title.Alignment = System.Drawing.StringAlignment.Center;
     ((XYDiagram)chartControl.Diagram).AxisY.Title.Font = new System.Drawing.Font("Tahoma", 8);
 }
示例#40
0
        public override void Plot(Graphics graphics, Rectangle bounds, double min, double max)
        {
            if (Bars == null)
            {
                return;
            }

            if (useplot)
            {
                base.Plot(graphics, bounds, min, max);


                int lastBar  = Math.Min(this.LastBarIndexPainted, Bars.Count - 1);
                int firstBar = this.FirstBarIndexPainted;

                Pen outlinePen = ChartControl.ChartStyle.Pen;

                int barPaintWidth = (int)(1 + 2 * (ChartControl.ChartStyle.BarWidthUI - 1) + 2 * outlinePen.Width);                  //ChartControl.ChartStyle.GetBarPaintWidth(ChartControl.BarWidth);
                int barwidth      = ChartControl.BarWidth;



                Color ColorNeutral = outlinePen.Color;

                Pen HiLoPen = (Pen)outlinePen.Clone();

                if (EnhanceHL)
                {
                    HiLoPen.Width *= 2;
                }



                int penSize;

                if (ChartControl.ChartStyle.ChartStyleType == ChartStyleType.OHLC)
                {
                    penSize = Math.Max(0, barwidth - 2);
                }
                else if (ChartControl.ChartStyle.ChartStyleType == ChartStyleType.HiLoBars)
                {
                    penSize = barwidth;
                }
                else if (chart == GomCDChartType.NonCumulativeChart && ForceHiLo)
                {
                    penSize = ForcedHiLoBS;
                }
                else
                {
                    penSize = 1;
                }

                drawPen.Width = penSize;

                int x, yHigh, yClose, yOpen, yLow;
                int direction;

                //zero line
                int y0 = ChartControl.GetYByValue(this, 0.0);



                if ((chart == GomCDChartType.NonCumulativeChart) || ReinitSession)
                {
                    graphics.DrawLine(new Pen(Color.Blue), bounds.X, y0, bounds.X + bounds.Width, y0);
                }

                for (int index = firstBar; index <= lastBar; index++)
                {
                    direction = 0;

                    if ((index <= lastcalcbar) && (index >= Math.Max(1, startbar)))
                    {
                        x      = ChartControl.GetXByBarIdx(BarsArray[0], index);
                        yHigh  = ChartControl.GetYByValue(this, dsHigh.Get(index));
                        yClose = ChartControl.GetYByValue(this, dsClose.Get(index));
                        yOpen  = ChartControl.GetYByValue(this, dsOpen.Get(index));
                        yLow   = ChartControl.GetYByValue(this, dsLow.Get(index));


                        if (PtType == GomPaintType.StrongUpDown)
                        {
                            if (dsClose.Get(index) < dsLow.Get(index - 1))
                            {
                                direction = -1;
                            }
                            else if (dsClose.Get(index) > dsHigh.Get(index - 1))
                            {
                                direction = 1;
                            }
                        }
                        else if (PtType == GomPaintType.UpDown)
                        {
                            if (dsClose.Get(index) < dsOpen.Get(index))
                            {
                                direction = -1;
                            }
                            else if (dsClose.Get(index) > dsOpen.Get(index))
                            {
                                direction = 1;
                            }
                        }


                        if (direction == 1)
                        {
                            drawPen.Color = ChartControl.UpColor;
                        }
                        else if (direction == -1)
                        {
                            drawPen.Color = ChartControl.DownColor;
                        }
                        else
                        {
                            drawPen.Color = ColorNeutral;
                        }

                        drawBrush.Color = drawPen.Color;


                        if ((ChartControl.ChartStyle.ChartStyleType == ChartStyleType.HiLoBars) || (chart == GomCDChartType.NonCumulativeChart && ForceHiLo))
                        {
                            graphics.DrawLine(drawPen, x, yHigh, x, yLow);
                        }

                        else if (ChartControl.ChartStyle.ChartStyleType == ChartStyleType.CandleStick)
                        {
                            graphics.DrawLine(HiLoPen, x, yLow, x, yHigh);

                            if (yClose == yOpen)
                            {
                                graphics.DrawLine(outlinePen, x - barwidth - outlinePen.Width, yClose, x + barwidth + outlinePen.Width, yClose);
                            }

                            else
                            {
                                graphics.FillRectangle(drawBrush, x - barPaintWidth / 2, Math.Min(yClose, yOpen) + 1, barPaintWidth, Math.Abs(yClose - yOpen));

                                if (ShowOutline)
                                {
                                    //	graphics.FillRectangle(neutralBrush,x-barwidth-outlinepenwidth,Math.Min(yClose,yOpen)+1,2*(barwidth+outlinepenwidth)+1,Math.Abs(yClose-yOpen)-1);
                                    //	graphics.FillRectangle(drawBrush,x-barwidth,Math.Min(yClose,yOpen)+1,2*barwidth+1,Math.Abs(yClose-yOpen)-1);
                                    //graphics.DrawRectangle(outlinePen, x - barwidth - outlinePen.Width / 2, Math.Min(yClose, yOpen), 2 * (barwidth) + outlinePen.Width + 1, Math.Abs(yClose - yOpen));

                                    graphics.DrawRectangle(outlinePen, x - (barPaintWidth / 2) + (outlinePen.Width / 2), Math.Min(yClose, yOpen), barPaintWidth - outlinePen.Width, Math.Abs(yClose - yOpen));
                                }
                            }
                        }

                        else
                        {
                            graphics.DrawLine(drawPen, x, yLow + penSize / 2, x, yHigh - penSize / 2);
                            graphics.DrawLine(drawPen, x, yClose, x + barwidth, yClose);
                            graphics.DrawLine(drawPen, x - barwidth, yOpen, x, yOpen);
                        }
                    }
                }
            }
            else
            {
                base.Plot(graphics, bounds, min, max);
            }
        }
示例#41
0
 public static void DefineTitleChart(ChartControl chartControl, string title)
 {
     ChartTitle chartTitle = new ChartTitle();
     chartTitle.Text = title;
     chartControl.Titles.Add(chartTitle);
 }
示例#42
0
        public override void OnMouseDown(ChartControl chartControl, ChartPanel chartPanel, ChartScale chartScale, ChartAnchor dataPoint)
        {
            if (lastMouseMoveDataPoint == null)
            {
                lastMouseMoveDataPoint = new ChartAnchor();
                dataPoint.CopyDataValues(lastMouseMoveDataPoint);
            }
            switch (DrawingState)
            {
            case DrawingState.Building:
                if (StartAnchor.IsEditing)
                {
                    dataPoint.CopyDataValues(StartAnchor);

                    StartAnchor.IsEditing = false;

                    // these lines only need one anchor, so stop editing end anchor too
//						if (LineType == ChartLineType.HorizontalLine || LineType == ChartLineType.VerticalLine)
//							EndAnchor.IsEditing = false;

                    // give end anchor something to start with so we dont try to render it with bad values right away
                    dataPoint.CopyDataValues(EndAnchor);
                }
                else if (EndAnchor.IsEditing)
                {
                    dataPoint.CopyDataValues(EndAnchor);

                    EndAnchor.Price     = StartAnchor.Price;
                    EndAnchor.IsEditing = false;
                }

                // is initial building done (both anchors set)
                if (!StartAnchor.IsEditing && !EndAnchor.IsEditing)
                {
                    DrawingState = DrawingState.Normal;
                    IsSelected   = false;
                }
                break;

            case DrawingState.Normal:
                Point point = dataPoint.GetPoint(chartControl, chartPanel, chartScale);
                // see if they clicked near a point to edit, if so start editing

                editingAnchor = GetClosestAnchor(chartControl, chartPanel, chartScale, cursorSensitivity, point);

                if (editingAnchor != null)
                {
                    editingAnchor.IsEditing = true;
                    DrawingState            = DrawingState.Editing;
                }
                else
                {
                    if (GetCursor(chartControl, chartPanel, chartScale, point) != null)
                    {
                        DrawingState = DrawingState.Moving;
                        dataPoint.CopyDataValues(lastMouseMoveDataPoint);
                    }
                    else
                    {
                        // user whiffed.
                        IsSelected = false;
                    }
                }
                break;
            }
        }
示例#43
0
 public static void DefineXYZ(ChartControl chartControl, DataSet ds, string valueX, string valueY, string valueSeries)
 {
     TypeChart = 2;
     chartControl.DataSource = ds.Tables[0];
     chartControl.SeriesDataMember = valueSeries;
     chartControl.SeriesTemplate.ArgumentDataMember = valueX;
     chartControl.SeriesTemplate.ValueDataMembers.AddRange(new string[] { valueY });
 }
示例#44
0
        protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
        {
            if (Bars == null || Bars.Instrument == null || IsInHitTest)
            {
                return;
            }

            int    firstBarIdxToPaint = -1;
            double tickSize           = Bars.Instrument.MasterInstrument.TickSize;
            double volumeMax          = 0;

            SharpDX.Direct2D1.Brush upBrush      = VolumeUpBrush.ToDxBrush(RenderTarget);
            SharpDX.Direct2D1.Brush downBrush    = VolumeDownBrush.ToDxBrush(RenderTarget);
            SharpDX.Direct2D1.Brush neutralBrush = VolumeNeutralBrush.ToDxBrush(RenderTarget);
            SharpDX.Direct2D1.Brush lineBrushDx  = LineBrush.ToDxBrush(RenderTarget);

            upBrush.Opacity      = (float)(alpha / 100.0);
            downBrush.Opacity    = (float)(alpha / 100.0);
            neutralBrush.Opacity = (float)(alpha / 100.0);

            for (int i = newSessionBarIdx.Count - 1; i >= 0; i--)
            {
                int prevSessionBreakIdx = newSessionBarIdx[i];

                if (prevSessionBreakIdx <= ChartBars.ToIndex)
                {
                    startIndexOf       = newSessionBarIdx.IndexOf(prevSessionBreakIdx);
                    firstBarIdxToPaint = prevSessionBreakIdx;
                    break;
                }
            }

            foreach (Dictionary <double, VolumeInfoItem> tmpDict in sortedDicList)
            {
                foreach (KeyValuePair <double, VolumeInfoItem> keyValue in tmpDict)
                {
                    double price = keyValue.Key;

                    if (price > chartScale.MaxValue || price < chartScale.MinValue)
                    {
                        continue;
                    }

                    VolumeInfoItem vii   = keyValue.Value;
                    double         total = vii.up + vii.down + vii.neutral;
                    volumeMax = Math.Max(volumeMax, total);
                }
            }

            if (volumeMax.ApproxCompare(0) == 0)
            {
                return;
            }

            int viiPositions = 0;

            foreach (KeyValuePair <double, VolumeInfoItem> keyValue in sortedDicList[startIndexOf])
            {
                viiPositions++;

                VolumeInfoItem vii = keyValue.Value;

                double priceLower      = keyValue.Key - tickSize / 2;
                float  yLower          = chartScale.GetYByValue(priceLower);
                float  yUpper          = chartScale.GetYByValue(priceLower + tickSize);
                float  height          = Math.Max(1, Math.Abs(yUpper - yLower) - barSpacing);
                int    barWidthUp      = (int)((ChartPanel.W / 2) * (vii.up / volumeMax));
                int    barWidthNeutral = (int)((ChartPanel.W / 2) * (vii.neutral / volumeMax));
                int    barWidthDown    = (int)((ChartPanel.W / 2) * (vii.down / volumeMax));
                float  stationaryXpos  = chartControl.GetXByBarIndex(ChartBars, !Bars.IsTickReplay ? ChartBars.FromIndex : Math.Max(ChartBars.FromIndex, firstBarIdxToPaint));
                float  xpos            = chartControl.GetXByBarIndex(ChartBars, !Bars.IsTickReplay ? ChartBars.FromIndex : Math.Max(1, Math.Max(ChartBars.FromIndex, firstBarIdxToPaint)) - 1);

                RenderTarget.FillRectangle(new SharpDX.RectangleF(xpos, yUpper, barWidthUp, height), upBrush);
                xpos += barWidthUp;
                RenderTarget.FillRectangle(new SharpDX.RectangleF(xpos, yUpper, barWidthNeutral, height), neutralBrush);
                xpos += barWidthNeutral;
                RenderTarget.FillRectangle(new SharpDX.RectangleF(xpos, yUpper, barWidthDown, height), downBrush);

                if (!drawLines)
                {
                    continue;
                }
                // Lower line
                RenderTarget.DrawLine(new SharpDX.Vector2(stationaryXpos, yLower), new SharpDX.Vector2((ChartPanel.X + ChartPanel.W), yLower), lineBrushDx);

                // Upper line (only at very top)
                if (viiPositions == sortedDicList[startIndexOf].Count)
                {
                    RenderTarget.DrawLine(new SharpDX.Vector2(stationaryXpos, yUpper), new SharpDX.Vector2((ChartPanel.X + ChartPanel.W), yUpper), lineBrushDx);
                }
            }

            lineBrushDx.Dispose();
            upBrush.Dispose();
            downBrush.Dispose();
            neutralBrush.Dispose();
        }
示例#45
0
 public static void SetAngleLabel_X(ChartControl chartControl, int angle)
 {
     ((XYDiagram)chartControl.Diagram).AxisX.Label.Angle = angle;
 }
示例#46
0
 public static ChartControl CreatXYChart(SolidColorBrush forecolor, string ChartTitle, List<ChartDataChartCommonData> dtchart)
 {
     mausac = 0;
     ChartControl abc = new ChartControl();
     XYDiagram2D dg1 = new XYDiagram2D();
     //Tao Tile cho Chart
     Title nt = new Title();
     nt.Content = ChartTitle;
     nt.Foreground = forecolor;
     abc.Titles.Add(nt);
     //Tinh so Series
     List<string> countsr = (from p in dtchart group p by p.Series into g select g.Key).ToList();
     //Creat Diagram
     abc.Diagram = dg1;
     //Begin tao guong
     Pane pane1 = new Pane();
     pane1.MirrorHeight = 100;//Do cao guong
     dg1.DefaultPane = pane1;
     //End tao guong
     //Begin set kieu bieu do
     for (int i = 0; i < countsr.Count; i++)
     {
         BarSideBySideSeries2D dgs1 = new BarSideBySideSeries2D() { DisplayName = countsr[i].ToString() };//Neu ko co DisplayName chu thich khong hien thi
         Quasi3DBar2DModel an1 = new Quasi3DBar2DModel();
         dgs1.Model = an1;
         foreach (ChartDataChartCommonData dr in dtchart)//Tao cac point
         {
             if (dr.Series == countsr.ElementAt(i))
             {
                 //Tao Series
                 SeriesPoint sr1 = new SeriesPoint();
                 sr1.Argument = dr.Agrument;
                 sr1.Value = dr.Value;
                 sr1.Tag = mausac.ToString();
                 dgs1.Points.Add(sr1);
                 mausac++;
             }
         }
         SeriesLabel lbl1 = new SeriesLabel();
         dgs1.LabelsVisibility = true;//Hien thi Lablel cho tung vung
         lbl1.Indent = 10;
         lbl1.ConnectorThickness = 1;
         lbl1.ResolveOverlappingMode = ResolveOverlappingMode.Default;
         dgs1.Label = lbl1;
         dg1.Series.Add(dgs1);
     }
     //Tao chu thich
     abc.Legend = new Legend()
     {
         VerticalPosition = VerticalPosition.BottomOutside,
         HorizontalPosition = HorizontalPosition.Center,
         Orientation = Orientation.Horizontal
     };
     //End tao chu thich
     return abc;
 }
示例#47
0
 public static void SetScroll(ChartControl chartControl,bool isScroll)
 {
     ((XYDiagram)chartControl.Diagram).EnableScrolling = isScroll;
 }
示例#48
0
 private void init()
 {
     chartLayer = new ChartControl();
     chartLayer.Interval = 1000;
     chartLayer.timeAtXAxis = true;
     lstLogInit();
     lstItemsInit();
     MainTimerInit();
     tabPage2.Controls.Add(chartLayer);
 }
示例#49
0
 public static void SetSmoothLabel_X(ChartControl chartControl, bool isSmooth)
 {
     ((XYDiagram)chartControl.Diagram).AxisX.Label.Antialiasing = isSmooth;
 }
示例#50
0
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     this.components = new System.ComponentModel.Container();
     Syncfusion.Windows.Forms.Chart.ChartSeries          chartSeries1          = new Syncfusion.Windows.Forms.Chart.ChartSeries();
     Syncfusion.Windows.Forms.Chart.ChartCustomShapeInfo chartCustomShapeInfo1 = new Syncfusion.Windows.Forms.Chart.ChartCustomShapeInfo();
     Syncfusion.Windows.Forms.Chart.ChartLineInfo        chartLineInfo1        = new Syncfusion.Windows.Forms.Chart.ChartLineInfo();
     System.ComponentModel.ComponentResourceManager      resources             = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
     this.panel1        = new System.Windows.Forms.Panel();
     this.label1        = new System.Windows.Forms.Label();
     this.timer1        = new System.Windows.Forms.Timer(this.components);
     this.toolTip1      = new System.Windows.Forms.ToolTip(this.components);
     this.chartControl1 = new Syncfusion.Windows.Forms.Chart.ChartControl();
     this.panel1.SuspendLayout();
     this.SuspendLayout();
     //
     // panel1
     //
     this.panel1.Dock      = DockStyle.Right;
     this.panel1.AutoSize  = true;
     this.panel1.BackColor = System.Drawing.Color.White;
     this.panel1.Controls.Add(this.label1);
     this.panel1.Font     = new System.Drawing.Font("Segoe UI", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this.panel1.Location = new System.Drawing.Point(12, 542);
     this.panel1.Name     = "panel1";
     this.panel1.Size     = new System.Drawing.Size(594, 27);
     this.panel1.TabIndex = 1;
     //
     // label1
     //
     this.label1.Dock      = System.Windows.Forms.DockStyle.Bottom;
     this.label1.Font      = new System.Drawing.Font("Segoe UI", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(161)));
     this.label1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(66)))), ((int)(((byte)(66)))));
     this.label1.Location  = new System.Drawing.Point(0, 10);
     this.label1.Name      = "label1";
     this.label1.Size      = new System.Drawing.Size(594, 17);
     this.label1.TabIndex  = 0;
     this.label1.Text      = "Click on the columns to drill down further";
     this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
     //
     // timer1
     //
     this.timer1.Enabled = true;
     //
     // chartControl1
     //
     this.chartControl1.ChartArea.BackInterior   = new Syncfusion.Drawing.BrushInfo(System.Drawing.Color.White);
     this.chartControl1.ChartArea.CursorLocation = new System.Drawing.Point(0, 0);
     this.chartControl1.ChartArea.CursorReDraw   = false;
     this.chartControl1.DataSourceName           = "";
     this.chartControl1.ForeColor    = System.Drawing.SystemColors.ControlText;
     this.chartControl1.IsWindowLess = false;
     //
     //
     //
     this.chartControl1.Legend.Location           = new System.Drawing.Point(830, 75);
     this.chartControl1.Localize                  = null;
     this.chartControl1.Location                  = new System.Drawing.Point(8, 10);
     this.chartControl1.Name                      = "chartControl1";
     this.chartControl1.PrimaryXAxis.Crossing     = double.NaN;
     this.chartControl1.PrimaryXAxis.Title        = "Vehicles";
     this.chartControl1.PrimaryXAxis.Margin       = true;
     this.chartControl1.PrimaryYAxis.Title        = "Sales (%)";
     this.chartControl1.PrimaryYAxis.Crossing     = double.NaN;
     this.chartControl1.PrimaryYAxis.ForceZero    = true;
     this.chartControl1.PrimaryYAxis.Margin       = true;
     chartSeries1.FancyToolTip.ResizeInsideSymbol = true;
     chartSeries1.Name = "Default";
     chartSeries1.Points.Add(0D, ((double)(18D)), ((double)(127D)), ((double)(112D)), ((double)(108D)));
     chartSeries1.Points.Add(1D, ((double)(56D)), ((double)(73D)), ((double)(61D)), ((double)(56D)));
     chartSeries1.Points.Add(2D, ((double)(4D)), ((double)(212D)), ((double)(82D)), ((double)(107D)));
     chartSeries1.Points.Add(3D, ((double)(50D)), ((double)(348D)), ((double)(55D)), ((double)(190D)));
     chartSeries1.Points.Add(4D, ((double)(87D)), ((double)(246D)), ((double)(136D)), ((double)(192D)));
     chartSeries1.Resolution          = 0D;
     chartSeries1.StackingGroup       = "Default Group";
     chartSeries1.Style.AltTagFormat  = "";
     chartSeries1.Style.DrawTextShape = false;
     chartLineInfo1.Alignment         = System.Drawing.Drawing2D.PenAlignment.Center;
     chartLineInfo1.Color             = System.Drawing.SystemColors.ControlText;
     chartLineInfo1.DashPattern       = null;
     chartLineInfo1.DashStyle         = System.Drawing.Drawing2D.DashStyle.Solid;
     chartLineInfo1.Width             = 1F;
     chartCustomShapeInfo1.Border     = chartLineInfo1;
     chartCustomShapeInfo1.Color      = System.Drawing.SystemColors.HighlightText;
     chartCustomShapeInfo1.Type       = Syncfusion.Windows.Forms.Chart.ChartCustomShape.Square;
     chartSeries1.Style.TextShape     = chartCustomShapeInfo1;
     chartSeries1.Text = "Default";
     this.chartControl1.Series.Add(chartSeries1);
     this.chartControl1.Size     = new System.Drawing.Size(934, 526);
     this.chartControl1.TabIndex = 2;
     this.chartControl1.Text     = "chartControl1";
     //
     //
     //
     this.chartControl1.Title.ForeColor = System.Drawing.SystemColors.ControlText;
     this.chartControl1.Title.Name      = "Default";
     this.chartControl1.Titles.Add(this.chartControl1.Title);
     this.chartControl1.ChartRegionClick      += new Syncfusion.Windows.Forms.Chart.ChartRegionMouseEventHandler(this.chartControl1_ChartRegionClick);
     this.chartControl1.ChartRegionMouseHover += new Syncfusion.Windows.Forms.Chart.ChartRegionMouseEventHandler(this.chartControl1_ChartRegionMouseHover);
     //
     // Form1
     //
     this.BackColor  = System.Drawing.Color.White;
     this.ClientSize = new System.Drawing.Size(954, 581);
     this.Controls.Add(this.chartControl1);
     this.Controls.Add(this.panel1);
     this.Icon                = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
     this.MinimumSize         = new System.Drawing.Size(461, 407);
     this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
     this.AutoScaleMode       = System.Windows.Forms.AutoScaleMode.Font;
     this.Name                = "Form1";
     this.StartPosition       = System.Windows.Forms.FormStartPosition.CenterScreen;
     this.Text                = "Drilldown";
     this.Load               += new System.EventHandler(this.Form1_Load);
     this.panel1.ResumeLayout(false);
     this.ResumeLayout(false);
     this.PerformLayout();
 }
示例#51
0
 public override void OnMouseUp(ChartControl chartControl, ChartPanel chartPanel, ChartScale chartScale, ChartAnchor dataPoint)
 {
     DrawingState = DrawingState.Normal;
 }
        public override void OnMouseDown(ChartControl chartControl, ChartPanel chartPanel, ChartScale chartScale, ChartAnchor dataPoint)
        {
            switch (DrawingState)
            {
            case DrawingState.Building:

                if (Mode == RegionHighlightMode.Price)
                {
                    dataPoint.Time = chartControl.FirstTimePainted.AddSeconds((chartControl.LastTimePainted - chartControl.FirstTimePainted).TotalSeconds / 2);
                }
                else
                {
                    dataPoint.Price = chartScale.MinValue + chartScale.MaxMinusMin / 2;
                }

                if (StartAnchor.IsEditing)
                {
                    dataPoint.CopyDataValues(StartAnchor);
                    StartAnchor.IsEditing = false;
                    dataPoint.CopyDataValues(EndAnchor);
                }
                else if (EndAnchor.IsEditing)
                {
                    if (Mode == RegionHighlightMode.Price)
                    {
                        dataPoint.Time      = StartAnchor.Time;
                        dataPoint.SlotIndex = StartAnchor.SlotIndex;
                    }
                    else
                    {
                        dataPoint.Price = StartAnchor.Price;
                    }

                    dataPoint.CopyDataValues(EndAnchor);
                    EndAnchor.IsEditing = false;
                }
                if (!StartAnchor.IsEditing && !EndAnchor.IsEditing)
                {
                    DrawingState = DrawingState.Normal;
                    IsSelected   = false;
                }
                break;

            case DrawingState.Normal:
                Point point = dataPoint.GetPoint(chartControl, chartPanel, chartScale);
                editingAnchor = GetClosestAnchor(chartControl, chartPanel, chartScale, cursorSensitivity, point);
                if (editingAnchor != null)
                {
                    editingAnchor.IsEditing = true;
                    DrawingState            = DrawingState.Editing;
                }
                else
                {
                    if (GetCursor(chartControl, chartPanel, chartScale, point) == Cursors.SizeAll)
                    {
                        DrawingState = DrawingState.Moving;
                    }
                    else if (GetCursor(chartControl, chartPanel, chartScale, point) == Cursors.SizeWE || GetCursor(chartControl, chartPanel, chartScale, point) == Cursors.SizeNS)
                    {
                        DrawingState = DrawingState.Editing;
                    }
                    else if (GetCursor(chartControl, chartPanel, chartScale, point) == Cursors.Arrow)
                    {
                        DrawingState = DrawingState.Editing;
                    }
                    else if (GetCursor(chartControl, chartPanel, chartScale, point) == null)
                    {
                        IsSelected = false;
                    }
                }
                break;
            }
        }
示例#53
0
		public override void GetMinMaxValues(ChartControl chartControl, ref double min, ref double max)
		{
			base.GetMinMaxValues(chartControl, ref min, ref max);
			if (!autoScale)
				if (max > (min * -1))
					min = max * -1;
				else
					max = min * -1;
			min = min - 20;
			max = max + 40;
		}
示例#54
0
        private void CreateChartLine(ChartControl arg_chart, DataTable arg_dt, string arg_name)
        {
            if (arg_dt == null || arg_dt.Rows.Count == 0)
            {
                return;
            }
            arg_chart.Series.Clear();
            arg_chart.Titles.Clear();

            //----------create--------------------
            Series series2 = new Series("POH", ViewType.Spline);
            Series series3 = new Series("Target", ViewType.Spline);

            DevExpress.XtraCharts.SplineSeriesView splineSeriesView1 = new DevExpress.XtraCharts.SplineSeriesView();
            DevExpress.XtraCharts.SplineSeriesView splineSeriesView2 = new DevExpress.XtraCharts.SplineSeriesView();
            //DevExpress.XtraCharts.SideBySideBarSeriesView sideBySideBarSeriesView1 = new DevExpress.XtraCharts.SideBySideBarSeriesView();
            //DevExpress.XtraCharts.PointSeriesLabel pointSeriesLabel1 = new DevExpress.XtraCharts.PointSeriesLabel();
            //DevExpress.XtraCharts.BarWidenAnimation barWidenAnimation1 = new DevExpress.XtraCharts.BarWidenAnimation();
            //DevExpress.XtraCharts.ElasticEasingFunction elasticEasingFunction1 = new DevExpress.XtraCharts.ElasticEasingFunction();
            //DevExpress.XtraCharts.XYSeriesBlowUpAnimation xySeriesBlowUpAnimation1 = new DevExpress.XtraCharts.XYSeriesBlowUpAnimation();
            DevExpress.XtraCharts.XYSeriesUnwindAnimation xySeriesUnwindAnimation1 = new DevExpress.XtraCharts.XYSeriesUnwindAnimation();
            //DevExpress.XtraCharts.XYSeriesUnwrapAnimation xySeriesUnwrapAnimation1 = new DevExpress.XtraCharts.XYSeriesUnwrapAnimation();

            //DevExpress.XtraCharts.PowerEasingFunction powerEasingFunction1 = new DevExpress.XtraCharts.PowerEasingFunction();
            DevExpress.XtraCharts.SineEasingFunction sineEasingFunction1 = new DevExpress.XtraCharts.SineEasingFunction();
            DevExpress.XtraCharts.ConstantLine       constantLine1       = new DevExpress.XtraCharts.ConstantLine();

            //--------- Add data Point------------
            for (int i = 0; i < arg_dt.Rows.Count; i++)
            {
                if (arg_dt.Rows[i]["ACTUAL"] == null || arg_dt.Rows[i]["ACTUAL"].ToString() == "")
                {
                    series2.Points.Add(new SeriesPoint(arg_dt.Rows[i]["NM"].ToString().Replace(" ", "\n")));
                }
                else
                {
                    series2.Points.Add(new SeriesPoint(arg_dt.Rows[i]["NM"].ToString().Replace(" ", "\n"), arg_dt.Rows[i]["ACTUAL"]));
                }

                series3.Points.Add(new SeriesPoint(arg_dt.Rows[i]["NM"].ToString().Replace(" ", "\n"), arg_dt.Rows[i]["TAR"]));
            }

            arg_chart.SeriesSerializable = new DevExpress.XtraCharts.Series[] { series2, series3 };



            //title
            DevExpress.XtraCharts.ChartTitle chartTitle2 = new DevExpress.XtraCharts.ChartTitle();
            chartTitle2.Alignment = System.Drawing.StringAlignment.Near;
            chartTitle2.Font      = new System.Drawing.Font("Calibri", 24F, System.Drawing.FontStyle.Bold);
            chartTitle2.Text      = arg_name;
            chartTitle2.TextColor = System.Drawing.Color.Black;
            arg_chart.Titles.AddRange(new DevExpress.XtraCharts.ChartTitle[] { chartTitle2 });


            // format Series
            splineSeriesView1.MarkerVisibility = DevExpress.Utils.DefaultBoolean.True;
            splineSeriesView1.Color            = System.Drawing.Color.DodgerBlue;
            splineSeriesView1.LineMarkerOptions.BorderColor   = System.Drawing.Color.DodgerBlue;
            splineSeriesView1.LineMarkerOptions.BorderVisible = false;
            splineSeriesView1.LineMarkerOptions.Kind          = DevExpress.XtraCharts.MarkerKind.Circle;
            splineSeriesView1.LineMarkerOptions.Color         = System.Drawing.Color.DodgerBlue;
            splineSeriesView1.LineMarkerOptions.Size          = 10;

            splineSeriesView1.LineStyle.Thickness = 1;
            series2.LabelsVisibility = DevExpress.Utils.DefaultBoolean.False;
            //series2.Label.TextPattern = "{V:#,0}";
            series2.View = splineSeriesView1;

            xySeriesUnwindAnimation1.EasingFunction = sineEasingFunction1;
            splineSeriesView1.SeriesAnimation       = xySeriesUnwindAnimation1;

            /////TAR
            splineSeriesView2.Color = System.Drawing.Color.Green;

            splineSeriesView2.LineStyle.Thickness = 2;
            series3.LabelsVisibility = DevExpress.Utils.DefaultBoolean.False;
            //series2.Label.TextPattern = "{V:#,0}";
            series3.View = splineSeriesView2;

            xySeriesUnwindAnimation1.EasingFunction = sineEasingFunction1;
            splineSeriesView2.SeriesAnimation       = xySeriesUnwindAnimation1;



            arg_chart.Legend.Direction = LegendDirection.LeftToRight;

            //Constant line
            // //constantLine1.ShowInLegend = false;
            // constantLine1.AxisValueSerializable = arg_dt.Rows[0]["TAR"].ToString();
            // constantLine1.Color = System.Drawing.Color.Green;
            // constantLine1.Name = "Target";
            //// constantLine1.ShowBehind = false;
            // constantLine1.Title.Visible = false;
            // constantLine1.Title.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            // //constantLine1.Title.Text = "Target";
            // constantLine1.LineStyle.Thickness = 2;
            //// constantLine1.Title.Alignment = DevExpress.XtraCharts.ConstantLineTitleAlignment.Far;
            // ((XYDiagram)arg_chart.Diagram).AxisY.ConstantLines.Clear();
            // ((XYDiagram)arg_chart.Diagram).AxisY.ConstantLines.AddRange(new DevExpress.XtraCharts.ConstantLine[] { constantLine1 });


            //((XYDiagram)arg_chart.Diagram).AxisX.Tickmarks.MinorVisible = false;
            ((XYDiagram)arg_chart.Diagram).AxisX.VisualRange.Auto             = false;
            ((XYDiagram)arg_chart.Diagram).AxisX.VisualRange.AutoSideMargins  = false;
            ((XYDiagram)arg_chart.Diagram).AxisX.VisualRange.SideMarginsValue = 2;
            ((XYDiagram)arg_chart.Diagram).AxisX.Label.Angle = 0;
            ((XYDiagram)arg_chart.Diagram).AxisX.Label.Font  = new System.Drawing.Font("Tahoma", 10, System.Drawing.FontStyle.Bold);
            ((XYDiagram)arg_chart.Diagram).AxisX.NumericScaleOptions.ScaleMode = DevExpress.XtraCharts.ScaleMode.Continuous;
            ((XYDiagram)arg_chart.Diagram).AxisY.Label.Font = new System.Drawing.Font("Tahoma", 10, System.Drawing.FontStyle.Bold);
            ((XYDiagram)arg_chart.Diagram).AxisX.Title.Font = new System.Drawing.Font("Tahoma", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            ((XYDiagram)arg_chart.Diagram).AxisY.Title.Font = new System.Drawing.Font("Tahoma", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));

            //--------Text AxisX/ AxisY
            ((XYDiagram)arg_chart.Diagram).AxisY.Title.Text       = "POH";
            ((XYDiagram)arg_chart.Diagram).AxisY.Title.TextColor  = System.Drawing.Color.Orange;
            ((XYDiagram)arg_chart.Diagram).AxisY.Title.Visibility = DevExpress.Utils.DefaultBoolean.Default;
            ((XYDiagram)arg_chart.Diagram).AxisX.Title.Text       = "Time";
            ((XYDiagram)arg_chart.Diagram).AxisX.Title.Visibility = DevExpress.Utils.DefaultBoolean.Default;
            ((XYDiagram)arg_chart.Diagram).AxisX.Title.TextColor  = System.Drawing.Color.Orange;



            //---------------add chart in panel
            // pn_body.Controls.Add(arg_chart);
        }
示例#55
0
        public override void GetMinMaxValues(ChartControl chartControl, ref double min, ref double max)
        {
            if (Bars == null || ChartControl == null)
                return;

            for (int idx = FirstBarIndexPainted; idx <= LastBarIndexPainted; idx++)
            {
                double tmpHigh = hah.Get(idx);
                double tmpLow = hal.Get(idx);

                if (tmpHigh != 0 && tmpHigh > max)
                    max = tmpHigh;
                if (tmpLow != 0 && tmpLow < min)
                    min = tmpLow;
            }
        }
示例#56
0
        protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
        {
            // This sample should be used along side the help guide educational resource on this topic:
            // http://www.ninjatrader.com/support/helpGuides/nt8/en-us/?using_sharpdx_for_custom_chart_rendering.htm

            // Default plotting in base class. Uncomment if indicators holds at least one plot
            // in this case we would expect NOT to see the SMA plot we have as well in this sample script
            //base.OnRender(chartControl, chartScale);

            // 1.1 - SharpDX Vectors and Charting RenderTarget Coordinates

            // The SharpDX SDK uses "Vector2" objects to describe a two-dimensional point of a device (X and Y coordinates)
            SharpDX.Vector2 startPoint;
            SharpDX.Vector2 endPoint;

            // For our custom script, we need a way to determine the Chart's RenderTarget coordinates to draw our custom shapes
            // This info can be found within the NinjaTrader.Gui.ChartPanel class.
            // You can also use various chartScale and chartControl members to calculate values relative to time and price
            // However, those concepts will not be discussed or used in this sample
            // Notes:  RenderTarget is always the full ChartPanel, so we need to be mindful which sub-ChartPanel we're dealing with
            // Always use ChartPanel X, Y, W, H - as chartScale and chartControl properties WPF units, so they can be drastically different depending on DPI set
            startPoint = new SharpDX.Vector2(ChartPanel.X, ChartPanel.Y);
            endPoint   = new SharpDX.Vector2(ChartPanel.X + ChartPanel.W, ChartPanel.Y + ChartPanel.H);

            // These Vector2 objects are equivalent with WPF System.Windows.Point and can be used interchangeably depending on your requirements
            // For convenience, NinjaTrader provides a "ToVector2()" extension method to convert from WPF Points to SharpDX.Vector2
            SharpDX.Vector2 startPoint1 = new System.Windows.Point(ChartPanel.X, ChartPanel.Y + ChartPanel.H).ToVector2();
            SharpDX.Vector2 endPoint1   = new System.Windows.Point(ChartPanel.X + ChartPanel.W, ChartPanel.Y).ToVector2();

            // SharpDX.Vector2 objects contain X/Y properties which are helpful to recalculate new properties based on the initial vector
            float width  = endPoint.X - startPoint.X;
            float height = endPoint.Y - startPoint.Y;

            // Or you can recalculate a new vector from existing vector objects
            SharpDX.Vector2 center = (startPoint + endPoint) / 2;

            // Tip: This check is simply added to prevent the Indicator dialog menu from opening as a user clicks on the chart
            // The default behavior is to open the Indicator dialog menu if a user double clicks on the indicator
            // (i.e, the indicator falls within the RenderTarget "hit testing")
            // You can remove this check if you want the default behavior implemented
            if (!IsInHitTest)
            {
                // 1.2 - SharpDX Brush Resources

                // RenderTarget commands must use a special brush resource defined in the SharpDX.Direct2D1 namespace
                // These resources exist just like you will find in the WPF/Windows.System.Media namespace
                // such as SolidColorBrushes, LienarGraidentBrushes, RadialGradientBrushes, etc.
                // To begin, we will start with the most basic "Brush" type
                // Warning:  Brush objects must be disposed of after they have been used
                SharpDX.Direct2D1.Brush areaBrushDx;
                SharpDX.Direct2D1.Brush smallAreaBrushDx;
                SharpDX.Direct2D1.Brush textBrushDx;

                // for convenience, you can simply convert a WPF Brush to a DXBrush using the ToDxBrush() extension method provided by NinjaTrader
                // This is a common approach if you have a Brush property created e.g., on the UI you wish to use in custom rendering routines
                areaBrushDx      = areaBrush.ToDxBrush(RenderTarget);
                smallAreaBrushDx = smallAreaBrush.ToDxBrush(RenderTarget);
                textBrushDx      = textBrush.ToDxBrush(RenderTarget);

                // However - it should be noted that this conversion process can be rather expensive
                // If you have many brushes being created, and are not tied to WPF resources
                // You should rather favor creating the SharpDX Brush directly:
                // Warning:  SolidColorBrush objects must be disposed of after they have been used
                SharpDX.Direct2D1.SolidColorBrush customDXBrush = new SharpDX.Direct2D1.SolidColorBrush(RenderTarget,
                                                                                                        SharpDX.Color.DodgerBlue);

                // 1.3 - Using The RenderTarget
                // before executing chart commands, you have the ability to describe how the RenderTarget should render
                // for example, we can store the existing RenderTarget AntialiasMode mode
                // then update the AntialiasMode to be the quality of non-text primitives are rendered
                SharpDX.Direct2D1.AntialiasMode oldAntialiasMode = RenderTarget.AntialiasMode;
                RenderTarget.AntialiasMode = SharpDX.Direct2D1.AntialiasMode.Aliased;

                // Note: The code above stores the oldAntialiasMode as a best practices
                // i.e., if you plan on changing a property of the RenderTarget, you should plan to set it back
                // This is to make sure your requirements to no interfere with the function of another script
                // Additionally smoothing has some performance impacts

                // Once you have defined all the necessary requirements for you object
                //  You can execute a command on the RenderTarget to draw specific shapes
                // e.g., we can now use the RenderTarget's DrawLine() command to render a line
                // using the start/end points and areaBrushDx objects defined before
                RenderTarget.DrawLine(startPoint, endPoint, areaBrushDx, 4);

                // Since rendering occurs in a sequential fashion, after you have executed a command
                // you can switch a property of the RenderTarget to meet other requirements
                // For example, we can draw a second line now which uses a different AntialiasMode
                // and the changes render on the chart for both lines from the time they received commands
                RenderTarget.AntialiasMode = SharpDX.Direct2D1.AntialiasMode.PerPrimitive;
                RenderTarget.DrawLine(startPoint1, endPoint1, areaBrushDx, 4);

                // 1.4 - Rendering Custom Shapes

                // SharpDX namespace consists of several shapes you can use to draw objects more complicated than lines
                // For example, we can use the RectangleF object to draw a rectangle that covers the entire chart area
                SharpDX.RectangleF rect = new SharpDX.RectangleF(startPoint.X, startPoint.Y, width, height);

                // The RenderTarget consists of two commands related to Rectangles.
                // The FillRectangle() method is used to "Paint" the area of a Rectangle
                RenderTarget.FillRectangle(rect, areaBrushDx);

                // and DrawRectangle() is used to "Paint" the outline of a Rectangle
                RenderTarget.DrawRectangle(rect, customDXBrush, 2);

                // Another example is an ellipse which can be used to draw circles
                // The ellipse center point can be used from the Vectors calculated earlier
                // The width and height an absolute 100 device pixels
                // To ensure that pixel coordinates work across all DPI devices, we use the NinjaTrader ChartingExteions methods
                // Which will convert the "100" value from WPF pixels to Device Pixels both vertically and horizontally
                int ellipseRadiusY = ChartingExtensions.ConvertToVerticalPixels(100, ChartControl.PresentationSource);
                int ellipseRadiusX = ChartingExtensions.ConvertToHorizontalPixels(100, ChartControl.PresentationSource);

                SharpDX.Direct2D1.Ellipse ellipse = new SharpDX.Direct2D1.Ellipse(center, ellipseRadiusX, ellipseRadiusY);

                // 1.5 - Complex Brush Types and Shapes
                // For this ellipse, we can use one of the more complex brush types "RadialGradientBrush"
                // Warning:  RadialGradientBrush objects must be disposed of after they have been used
                SharpDX.Direct2D1.RadialGradientBrush radialGradientBrush;

                // However creating a RadialGradientBrush requires a few more properties than SolidColorBrush
                // First, you need to define the array gradient stops the brush will eventually use
                SharpDX.Direct2D1.GradientStop[] gradientStops = new SharpDX.Direct2D1.GradientStop[2];

                // With the gradientStops array, we can describe the color and position of the individual gradients
                gradientStops[0].Color    = SharpDX.Color.Goldenrod;
                gradientStops[0].Position = 0.0f;
                gradientStops[1].Color    = SharpDX.Color.SeaGreen;
                gradientStops[1].Position = 1.0f;

                // then declare a GradientStopCollection from our render target that uses the gradientStops array defined just before
                // Warning:  GradientStopCollection objects must be disposed of after they have been used
                SharpDX.Direct2D1.GradientStopCollection gradientStopCollection =
                    new SharpDX.Direct2D1.GradientStopCollection(RenderTarget, gradientStops);

                // we also need to tell our RadialGradientBrush to match the size and shape of the ellipse that we will be drawing
                // for convenience, SharpDX provides a RadialGradientBrushProperties structure to help define these properties
                SharpDX.Direct2D1.RadialGradientBrushProperties radialGradientBrushProperties =
                    new SharpDX.Direct2D1.RadialGradientBrushProperties
                {
                    GradientOriginOffset = new SharpDX.Vector2(0, 0),
                    Center  = ellipse.Point,
                    RadiusX = ellipse.RadiusY,
                    RadiusY = ellipse.RadiusY
                };

                // we now have everything we need to create a radial gradient brush
                radialGradientBrush = new SharpDX.Direct2D1.RadialGradientBrush(RenderTarget, radialGradientBrushProperties,
                                                                                gradientStopCollection);

                // Finally, we can use this radialGradientBrush to "Paint" the area of the ellipse
                RenderTarget.FillEllipse(ellipse, radialGradientBrush);

                // 1.6 - Simple Text Rendering

                // For rendering custom text to the Chart, there are a few ways you can approach depending on your requirements
                // The most straight forward way is to "borrow" the existing chartControl font provided as a "SimpleFont" class
                // Using the chartControl LabelFont, your custom object will also change to the user defined properties allowing
                // your object to match different fonts if defined by user.

                // The code below will use the chartControl Properties Label Font if it exists,
                // or fall back to a default property if it cannot obtain that value
                NinjaTrader.Gui.Tools.SimpleFont simpleFont = chartControl.Properties.LabelFont ?? new NinjaTrader.Gui.Tools.SimpleFont("Arial", 12);

                // the advantage of using a SimpleFont is they are not only very easy to describe
                // but there is also a convenience method which can be used to convert the SimpleFont to a SharpDX.DirectWrite.TextFormat used to render to the chart
                // Warning:  TextFormat objects must be disposed of after they have been used
                SharpDX.DirectWrite.TextFormat textFormat1 = simpleFont.ToDirectWriteTextFormat();

                // Once you have the format of the font, you need to describe how the font needs to be laid out
                // Here we will create a new Vector2() which draws the font according to the to top left corner of the chart (offset by a few pixels)
                SharpDX.Vector2 upperTextPoint = new SharpDX.Vector2(ChartPanel.X + 10, ChartPanel.Y + 20);
                // Warning:  TextLayout objects must be disposed of after they have been used
                SharpDX.DirectWrite.TextLayout textLayout1 =
                    new SharpDX.DirectWrite.TextLayout(NinjaTrader.Core.Globals.DirectWriteFactory,
                                                       NinjaTrader.Custom.Resource.SampleCustomPlotUpperLeftCorner, textFormat1, ChartPanel.X + ChartPanel.W,
                                                       textFormat1.FontSize);

                // With the format and layout of the text completed, we can now render the font to the chart
                RenderTarget.DrawTextLayout(upperTextPoint, textLayout1, textBrushDx,
                                            SharpDX.Direct2D1.DrawTextOptions.NoSnap);

                // 1.7 - Advanced Text Rendering

                // Font formatting and text layouts can get as complex as you need them to be
                // This example shows how to use a complete custom font unrelated to the existing user-defined chart control settings
                // Warning:  TextLayout and TextFormat objects must be disposed of after they have been used
                SharpDX.DirectWrite.TextFormat textFormat2 =
                    new SharpDX.DirectWrite.TextFormat(NinjaTrader.Core.Globals.DirectWriteFactory, "Century Gothic", FontWeight.Bold,
                                                       FontStyle.Italic, 32f);
                SharpDX.DirectWrite.TextLayout textLayout2 =
                    new SharpDX.DirectWrite.TextLayout(NinjaTrader.Core.Globals.DirectWriteFactory,
                                                       NinjaTrader.Custom.Resource.SampleCustomPlotLowerRightCorner, textFormat2, 400, textFormat1.FontSize);

                // the textLayout object provides a way to measure the described font through a "Metrics" object
                // This allows you to create new vectors on the chart which are entirely dependent on the "text" that is being rendered
                // For example, we can create a rectangle that surrounds our font based off the textLayout which would dynamically change if the text used in the layout changed dynamically
                SharpDX.Vector2 lowerTextPoint = new SharpDX.Vector2(ChartPanel.W - textLayout2.Metrics.Width - 5,
                                                                     ChartPanel.Y + (ChartPanel.H - textLayout2.Metrics.Height));
                SharpDX.RectangleF rect1 = new SharpDX.RectangleF(lowerTextPoint.X, lowerTextPoint.Y, textLayout2.Metrics.Width,
                                                                  textLayout2.Metrics.Height);

                // We can draw the Rectangle based on the TextLayout used above
                RenderTarget.FillRectangle(rect1, smallAreaBrushDx);
                RenderTarget.DrawRectangle(rect1, smallAreaBrushDx, 2);

                // And render the advanced text layout using the DrawTextLayout() method
                // Note:  When drawing the same text repeatedly, using the DrawTextLayout() method is more efficient than using the DrawText()
                // because the text doesn't need to be formatted and the layout processed with each call
                RenderTarget.DrawTextLayout(lowerTextPoint, textLayout2, textBrushDx, SharpDX.Direct2D1.DrawTextOptions.NoSnap);

                // 1.8 - Cleanup
                // This concludes all of the rendering concepts used in the sample
                // However - there are some final clean up processes we should always provided before we are done

                // If changed, do not forget to set the AntialiasMode back to the default value as described above as a best practice
                RenderTarget.AntialiasMode = oldAntialiasMode;

                // We also need to make sure to dispose of every device dependent resource on each render pass
                // Failure to dispose of these resources will eventually result in unnecessary amounts of memory being used on the chart
                // Although the effects might not be obvious as first, if you see issues related to memory increasing over time
                // Objects such as these should be inspected first
                areaBrushDx.Dispose();
                customDXBrush.Dispose();
                gradientStopCollection.Dispose();
                radialGradientBrush.Dispose();
                smallAreaBrushDx.Dispose();
                textBrushDx.Dispose();
                textFormat1.Dispose();
                textFormat2.Dispose();
                textLayout1.Dispose();
                textLayout2.Dispose();
            }
        }
示例#57
0
        public void BuildSeries(ChartControl chart)
        {
            seriesK.Data.Clear();
            seriesD.Data.Clear();
            seriesBounds.parts.Clear();

            if (SeriesSources.Count == 0)
            {
                return;
            }
            var source = SeriesSources[0];

            if (source.DataCount == 0)
            {
                return;
            }

            if (source is CandlestickSeries == false &&
                source is LineSeries == false)
            {
                return;
            }

            // границы
            if (lowerBound > 0)
            {
                seriesBounds.parts.Add(new List <PartSeriesPoint>
                {
                    new PartSeriesPoint(1, lowerBound),
                    new PartSeriesPoint(source.DataCount, lowerBound)
                });
            }
            if (upperBound > 0 && upperBound < 100)
            {
                seriesBounds.parts.Add(new List <PartSeriesPoint>
                {
                    new PartSeriesPoint(1, upperBound),
                    new PartSeriesPoint(source.DataCount, upperBound)
                });
            }

            queue   = new RestrictedQueue <float>(period);
            queueMA = new RestrictedQueue <float>(periodMA);

            for (var i = 0; i < source.DataCount; i++)
            {
                var price =
                    source is CandlestickSeries
                        ? ((CandlestickSeries)source).Data.Candles[i].close
                        : ((LineSeries)source).GetPrice(i) ?? 0;
                queue.Add(price);

                if (queue.Length < period)
                {
                    seriesK.Data.Add(50);
                    seriesD.Data.Add(50);
                    continue;
                }
                var minValue = float.MaxValue;
                var maxValue = float.MinValue;
                foreach (var p in queue)
                {
                    if (p < minValue)
                    {
                        minValue = p;
                    }
                    if (p > maxValue)
                    {
                        maxValue = p;
                    }
                }
                var range = maxValue - minValue;
                var k     = range == 0 ? 50 : 100 * (price - minValue) / range;
                queueMA.Add(k);
                var d = queueMA.Length == periodMA?queueMA.Average() : k;

                seriesK.Data.Add(k);
                seriesD.Data.Add(d);
            }
        }
示例#58
0
        private void btnExport_Click(object sender, EventArgs e)
        {
            try
            {
                if (dt == null || dt.Rows.Count == 0)
                {
                    MessageDxUtil.ShowTips("没有数据需要导出!");
                    return;
                }

                string saveDocFile = FileDialogHelper.SaveExcel(string.Format("{0}.xls", ReportTitle), "C:\\");
                if (!string.IsNullOrEmpty(saveDocFile))
                {
                    Workbook  workbook  = new Workbook();
                    Worksheet worksheet = workbook.Worksheets[0];
                    worksheet.PageSetup.Orientation = PageOrientationType.Landscape; //横向打印
                    worksheet.PageSetup.Zoom        = 100;                           //以100%的缩放模式打开
                    worksheet.PageSetup.PaperSize   = PaperSizeType.PaperA4;

                    #region 表头及说明信息
                    Range range; Cell cell; string content;
                    int   colSpan = 10;
                    range = worksheet.Cells.CreateRange(0, 0, 1, colSpan);
                    range.Merge();
                    range.RowHeight = 20;
                    range.SetStyle(CreateTitleStyle(workbook));
                    cell = range[0, 0];
                    cell.PutValue(ReportTitle);

                    range = worksheet.Cells.CreateRange(1, 0, 1, colSpan);
                    range.Merge();
                    range.RowHeight = 15;
                    cell            = range[0, 0];
                    content         = string.Format("所选查询条件内,总计有{0}个统计项,详细列表如下:", dt.Rows.Count);
                    cell.PutValue(content);

                    #endregion

                    #region 生成报表头部表格
                    Style headStyle   = CreateStyle(workbook, true);
                    Style normalStyle = CreateStyle(workbook, false);
                    int   startRow    = 2;
                    int   startCol    = 0;
                    range = worksheet.Cells.CreateRange(startRow, 0, 2, 1);
                    range.Merge();
                    range.SetStyle(headStyle);
                    cell = range[0, 0];
                    cell.PutValue("序号");
                    cell.SetStyle(headStyle);

                    range = worksheet.Cells.CreateRange(startRow, 1, 2, 1);
                    range.Merge();
                    range.SetStyle(headStyle);
                    range.ColumnWidth = 40;
                    cell = range[0, 0];
                    cell.PutValue("统计项目");
                    cell.SetStyle(headStyle);

                    range = worksheet.Cells.CreateRange(startRow, 2, 2, 1);
                    range.Merge();
                    range.SetStyle(headStyle);
                    range.ColumnWidth = 40;
                    cell = range[0, 0];
                    cell.PutValue("统计值");
                    cell.SetStyle(headStyle);

                    #endregion

                    //写入数据到Excel
                    startRow = startRow + 2;
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        //添加序号
                        cell = worksheet.Cells[startRow, 0];
                        cell.PutValue(i + 1);
                        cell.SetStyle(normalStyle);

                        startCol = 1;
                        for (int j = 0; j < dt.Columns.Count; j++)
                        {
                            DataRow dr = dt.Rows[i];
                            cell = worksheet.Cells[startRow, startCol];
                            cell.PutValue(dr[j]);
                            cell.SetStyle(normalStyle);

                            startCol++;
                        }
                        startRow++;
                    }

                    //写入图注
                    startRow += 1;//跳过1行
                    range     = worksheet.Cells.CreateRange(startRow++, 0, 1, colSpan);
                    range.Merge();
                    range.RowHeight = 15;
                    cell            = range[0, 0];
                    cell.PutValue("以饼图展示如下:");

                    //插入图片到Excel里面
                    using (MemoryStream stream = new MemoryStream())
                    {
                        stream.Position = 0;
                        ChartControl chart = (ChartControl)chartPie.Clone();
                        chart.Size = new Size(600, 400);

                        chart.ExportToImage(stream, ImageFormat.Jpeg);
                        worksheet.Pictures.Add(startRow, 0, stream);
                    }

                    //写入图注
                    startRow += 25;//跳过20行
                    range     = worksheet.Cells.CreateRange(startRow++, 0, 1, colSpan);
                    range.Merge();
                    range.RowHeight = 15;
                    cell            = range[0, 0];
                    cell.PutValue("以柱状图展示如下:");

                    //插入图片到Excel里面
                    using (MemoryStream stream = new MemoryStream())
                    {
                        stream.Position = 0;
                        ChartControl chart = (ChartControl)chartBar.Clone();
                        chart.Size = new Size(800, 300);

                        chart.ExportToImage(stream, ImageFormat.Jpeg);
                        worksheet.Pictures.Add(startRow, 0, stream);
                    }

                    workbook.Save(saveDocFile);
                    if (MessageUtil.ShowYesNoAndTips("保存成功,是否打开文件?") == System.Windows.Forms.DialogResult.Yes)
                    {
                        System.Diagnostics.Process.Start(saveDocFile);
                    }
                }
            }
            catch (Exception ex)
            {
                LogTextHelper.Error(ex);
                MessageUtil.ShowError(ex.Message);
                return;
            }
        }
示例#59
0
        /// <summary>
        ///  Remove points and add intersection points in case of backward order
        /// </summary>
        /// <param name="X">x values of curve</param>
        /// <param name="Y">y values of curve</param>
        /// <param name="lower">if true, algorithm for lower tube curve is used;<para>
        /// if false, algorithm for upper tube curve is used</para></param>
        /// <return>Number of loops, that are removed.</return>
        private static int removeLoop(List<double> X, List<double> Y, bool lower)
        {
            // Visualization of working of removeLoop
            bool visualize = false;

            List<double> XLoops = new List<double>(X);
            List<double> YLoops = new List<double>(Y);
            int j = 1;
            int countLoops = 0;

            #if GUI
            // Visualization
            if (visualize)
            {
                ChartControl chartControl = new ChartControl(600, Int32.MaxValue, true);
                chartControl.AddLine("Tube curve with loop", X, Y, Color.FromKnownColor(KnownColor.Cyan));
                Application.Run(chartControl);
            }
            #endif
            while (j < X.Count - 2)
            {
                // Find backward segment (j, j + 1)
                if (X[j + 1] < X[j])
                {
                    countLoops++;

                    // ----------------------------------------------------------------------------------------------------
                    // 1. Find i,k, such that i <= j < j + 1 <= k - 1 and segment (i - 1, i) intersect segment (k - 1, k)
                    // ----------------------------------------------------------------------------------------------------

                    int i, k, iPrevious;
                    double y;
                    // for calculation and adding of intersection point
                    bool addPoint = true;
                    double ix = 0;
                    double iy = 0;

                    i = j;
                    iPrevious = i;
                    // Find initial value for i = i_s, such that X[i_s - 1] <= X[j + 1] < X[i_s]
                    // it holds: i element of interval (i_s, j)
                    while (X[j + 1] < X[i - 1]) // X[j + 1] < X[i - 1] => (i - 1 > 0 && Y[i - 2] <= Y[i - 1]) (in case of lower)
                        i--;

                    // initial value for k
                    k = j + 1;
                    y = Y[i - 1]; // X[i - 1] <= X[j + 1] == X[k] < X[i] && in case of lower: y == Y[i - 1] <= Y[i] <= Y[j] == Y[j + 1] == Y[k]

                    // Find k
                    while (((lower && y < Y[k]) || (!lower && Y[k] < y)) && k + 1 < Y.Count)// y < Y[k] => k < X.Count
                    {
                        iPrevious = i;
                        k++;
                        while (X[i] < X[k] && i < j)
                            i++;
                        // it holds X[i - 1] < X[k] <= X[i], particularly X[i] != X[i - 1]
                        // linear interpolation of (x, y) = (X[k], y) on segment (i - 1, i)
                        y = (Y[i] - Y[i - 1]) / (X[i] - X[i - 1]) * (X[k] - X[i - 1]) + Y[i - 1];
                    }
                    // k located: intersection point is on segment (k - 1, k)
                    // i approximately located: intersection point is on polygonal line (iPrevoius - 1, i)
                    // Regular case
                    if (iPrevious > 1)
                        i = iPrevious - 1;
                    // Special case handling: assure, that i - 1 >= 0
                    else
                        i = iPrevious;
                    if (X[k] != X[k - 1])
                        // linear interpolation of (x, y) = (X[i], y) on segment (k - 1, k)
                        y = (Y[k] - Y[k - 1]) / (X[k] - X[k - 1]) * (X[i] - X[k - 1]) + Y[k - 1];
                    // it holds Y[i] = Y[iPrevious - 1] < Y[k - 1]
                    // Find i
                    while ((X[k] != X[k - 1] && ((lower && Y[i] < y) || (!lower && y < Y[i]))) || (X[k] == X[k - 1] && X[i] < X[k]))
                    {
                        i++;
                        if (X[k] != X[k - 1])
                            // linear interpolation of (x, y) = (X[i], y) on segment (k - 1, k)
                            y = (Y[k] - Y[k - 1]) / (X[k] - X[k - 1]) * (X[i] - X[k - 1]) + Y[k - 1];
                    }
                    // ----------------------------------------------------------------------------------------------------
                    // 2. Calculate intersection point (ix, iy) of segments (i - 1, i) and (k - 1, k)
                    // ----------------------------------------------------------------------------------------------------
                    double a1 = 0;
                    double a2 = 0;

                    // both branches vertical
                    if (X[i] == X[i - 1] && X[k] == X[k - 1])
                    {
                        // add no point; check if case occur: slopes have different signs
                        addPoint = false;
                    }
                    // case i-branch vertical
                    else if (X[i] == X[i - 1])
                    {
                        ix = X[i];
                        iy = Y[k - 1] + ((X[i] - X[k - 1]) * (Y[k] - Y[k - 1])) / (X[k] - X[k - 1]);
                    }
                    // case k-branch vertical
                    else if (X[k] == X[k - 1])
                    {
                        ix = X[k];
                        iy = Y[i - 1] + ((X[k] - X[i - 1]) * (Y[i] - Y[i - 1])) / (X[i] - X[i - 1]);
                    }
                    // common case
                    else
                    {
                        a1 = (Y[i] - Y[i - 1]) / (X[i] - X[i - 1]); // slope of segment (i - 1, i)
                        a2 = (Y[k] - Y[k - 1]) / (X[k] - X[k - 1]); // slope of segment (k - 1, k)
                        // common case: no equal slopes
                        if (a1 != a2)
                        {
                            ix = (a1 * X[i - 1] - a2 * X[k - 1] - Y[i - 1] + Y[k - 1]) / (a1 - a2);

                            if (Math.Abs(a1) > Math.Abs(a2))
                                // calculate y on segment (k - 1, k)
                                iy = a2 * (ix - X[k - 1]) + Y[k - 1];
                            else
                                // calculate y on segment (i - 1, i)
                                iy = a1 * (ix - X[i - 1]) + Y[i - 1];
                        }
                        else
                            // case equal slopes: add no point
                            addPoint = false;
                    }
                    // ----------------------------------------------------------------------------------------------------
                    // 3. Delete points i until (including) k - 1
                    // ----------------------------------------------------------------------------------------------------
                    int count = k - i;
                    X.RemoveRange(i, count);
                    Y.RemoveRange(i, count);
                    // ----------------------------------------------------------------------------------------------------
                    // 4. Add intersection point
                    // ----------------------------------------------------------------------------------------------------
                    // add intersection point, if it isn`t already there
                    if (addPoint && (X[i] != ix || Y[i] != iy))
                    {
                        X.Insert(i, ix);
                        Y.Insert(i, iy);
                    }
                    // ----------------------------------------------------------------------------------------------------
                    // 5. set j = i
                    // ----------------------------------------------------------------------------------------------------
                    j = i;
                    // ----------------------------------------------------------------------------------------------------
                    // 6. Delete points that are doubled
                    // ----------------------------------------------------------------------------------------------------
                    if (X[i - 1] == X[i] && Y[i - 1] == Y[i])
                    {
                        X.RemoveAt(i);
                        Y.RemoveAt(i);
                        j = i - 1;
                    }
                }
                j++;
            }
            #if GUI
            // Visualization
            if (visualize)
            {
                ChartControl control = new ChartControl(500, Int32.MaxValue, true);
                control.AddLine("Tube curve with loop", XLoops, YLoops, Color.FromKnownColor(KnownColor.Cyan));
                control.AddLine("Tube curve without loop", X, Y, Color.FromKnownColor(KnownColor.Red));
                Application.Run(control);
            }
            #endif
            return countLoops;
        }
示例#60
0
 public void BuildSeries(ChartControl chart)
 {
     Calculation();
 }