public CppOnlineDash() { // Initialize Components InitializeComponent(); XML_ADS_Parser(); UI_Disconnected(); scopeProjectPanel.ScopeProject = new ScopeProject(); chart = new YTChart(); axisGroup = new AxisGroup(); channel = new Channel(); acquisitionInterpreter = new AcquisitionInterpreter(); adsAcquisition = new AdsAcquisition(); style = new SeriesStyle(); // Register Events checkBoxAdsLocal.CheckedChanged += new EventHandler(this.AdsTargetBox_Checked); btnAdsConnect.Click += new EventHandler(this.AdsConnect_Click); btnAdsDisconnect.Click += new EventHandler(this.AdsDisconnect_Click); btnTcComVer1.Click += new EventHandler(this.TcComVer1_Click); btnTcComVer2.Click += new EventHandler(this.TcComVer2_Click); btnTcComVer3.Click += new EventHandler(this.TcComVer3_Click); btnTcComVer4.Click += new EventHandler(this.TcComVer4_Click); btnTcComVer5.Click += new EventHandler(this.TcComVer5_Click); // Execute some setup code scopeProjectPanel.ScopeProject.AddMember(chart); chart.AddMember(axisGroup); axisGroup.AddMember(channel); }
private void ChangeChannelSettings(Color displayColor, Color markerColor) { style = channel.SubMember.OfType <ChannelStyle>().First().SubMember.OfType <SeriesStyle>().First(); channel.DisplayColor = displayColor; style.DisplayColor = displayColor; style.MarkColor = markerColor; style.LineWidth = 3; }
/// <summary> /// Creates the chart. /// </summary> /// <param name="currency">The currency.</param> /// <param name="labels">The labels.</param> /// <param name="values">The values.</param> private void CreateChart(Currency currency, string[] labels, decimal[] values) { // Label style (x and y label) LabelStyle labelStyleX = new LabelStyle(); labelStyleX.Font = new Font("Arial", 10); labelStyleX.ForeColor = Color.Black; labelStyleX.Name = "xStyle"; c_chartVisits.LabelStyles.Add(labelStyleX); // Data point style DataPointLabelStyle dataPointStyle = c_chartVisits.DataPointLabelStyles.CreateNew("CustomStyle"); if (dataPointStyle != null) { dataPointStyle.ForeColor = System.Drawing.Color.Black; dataPointStyle.Font = new System.Drawing.Font("Arial", 10, System.Drawing.GraphicsUnit.Point); dataPointStyle.LabelPosition = LabelPositionKind.AboveVertical; } // Chart settings c_chartVisits.View.Kind = ProjectionKind.TwoDimensional; c_chartVisits.View.LightsOffOn2D = false; c_chartVisits.ResizeMarginsToFitLabels = true; //c_chartVisits.MainStyle = "Line"; if (ViewState["ChartWidth"] != null) { c_chartVisits.Width = new Unit((double)ViewState["ChartWidth"]); } else { ViewState["ChartWidth"] = c_chartVisits.Width.Value; } // If more than 24 columns, if (labels.Length > 24) { c_chartVisits.Width = labels.Length * 23; //title.Font = new System.Drawing.Font("Arial", 10, System.Drawing.GraphicsUnit.Point); dataPointStyle.Font = new System.Drawing.Font("Arial", 10, System.Drawing.GraphicsUnit.Point); } // Line style LineStyle2D lineStyle2D = new LineStyle2D(); lineStyle2D.Color = ColorTranslator.FromHtml("#0266fb"); lineStyle2D.Width = 2; lineStyle2D.ShadeWidth = 2; c_chartVisits.LineStyles2D.Add(lineStyle2D); // Series style SeriesStyle seriesStyle = new SeriesStyle(); seriesStyle.ChartKind = ChartKind.Rectangle; seriesStyle.LineStyle2DName = lineStyle2D.Name; c_chartVisits.SeriesStyles.Add(seriesStyle); // Series Series s1 = new Series("S1"); s1.StyleName = seriesStyle.Name; s1.Parameters["pointAreaAttributes"] = "alt=\"#[Param(y)]\""; s1.DataPointParameters["color"] = System.Drawing.Color.Black; c_chartVisits.RenderAreaMap = true; c_chartVisits.Series.Add(s1); c_chartVisits.DefineValue("S1:y", values); c_chartVisits.DefineValue("x", labels); c_chartVisits.DataBind(); SeriesLabels sLabels = s1.CreateAnnotation("y", "CustomStyle"); for (int i = 0; i < sLabels.Count; i++) { DataPointLabel label = sLabels[i]; decimal value = Convert.ToDecimal(label.Text); label.Text = value.ToString(currency.GetNumberFormatInfo(CultureInfo.CurrentUICulture)); } // Y axis AxisAnnotation yAnnotation = c_chartVisits.CoordinateSystem.YAxis.AxisAnnotations["Y@Xmin"]; //yAnnotation.AxisTitle = CurrentModule.Strings.GetValue("Visits", FoundationContext.LanguageID, true); yAnnotation.AxisTitleStyleName = "xStyle"; yAnnotation.LabelStyleName = "xStyle"; yAnnotation.AxisTitleOffsetPts = 35; foreach (AxisLabel label in yAnnotation.Labels) { decimal value; if (decimal.TryParse(label.Text, out value)) { label.Text = value.ToString(currency.GetNumberFormatInfo(CultureInfo.CurrentUICulture)); } } // X axis AxisAnnotation xAnnotation = c_chartVisits.CoordinateSystem.XAxis.AxisAnnotations["X@Ymin"]; xAnnotation.AxisTitleStyleName = "xStyle"; xAnnotation.LabelStyleName = "xStyle"; xAnnotation.HOffset = 3; xAnnotation.VOffset = 0; xAnnotation.RotationAngle = 45; // Background StripSet yStripSet1 = c_chartVisits.CoordinateSystem.PlaneXY.StripSets["YinPlaneXY"]; yStripSet1.Color = Color.White; yStripSet1.AlternateColor = Color.FromArgb(242, 242, 242); c_chartVisits.Frame.FrameKind = ChartFrameKind.Thin2DFrame; c_chartVisits.Frame.FrameColor = Color.Gray; c_chartVisits.BackGradientKind = GradientKind.Center; }