void OnTitleAngleUpDownValueChanged(NValueChangeEventArgs arg) { for (int i = 0; i < m_Chart.Axes.Count; i++) { NScaleLabelAngle oldTitleAngle = m_Chart.Axes[i].TitleAngle; m_Chart.Axes[i].TitleAngle = new NScaleLabelAngle(oldTitleAngle.LabelAngleMode, ((NNumericUpDown)arg.TargetNode).Value); } }
void OnTitleAngleModeComboBoxSelectedIndexChanged(NValueChangeEventArgs arg) { for (int i = 0; i < m_Chart.Axes.Count; i++) { NScaleLabelAngle oldTitleAngle = m_Chart.Axes[i].TitleAngle; m_Chart.Axes[i].TitleAngle = new NScaleLabelAngle((ENScaleLabelAngleMode)((NComboBox)arg.TargetNode).SelectedIndex, oldTitleAngle.CustomAngle); } }
void OnAllowLabelsToFlipCheckBoxCheckedChanged(NValueChangeEventArgs arg) { for (int i = 0; i < m_Chart.Axes.Count; i++) { NScaleLabelAngle titleAngle = m_Chart.Axes[i].TitleAngle; titleAngle.AllowTextFlip = ((NCheckBox)arg.TargetNode).Checked; m_Chart.Axes[i].TitleAngle = titleAngle; } }
private void UpdateScaleLabelAngle(NValueChangeEventArgs arg) { NScaleLabelAngle angle = new NScaleLabelAngle((ENScaleLabelAngleMode)m_AngleModeComboBox.SelectedIndex, (float)m_CustomAngleNumericUpDown.Value, m_AllowTextFlipCheckBox.Checked); // apply angle to radial gauge axis NGaugeAxis axis = (NGaugeAxis)m_RadialGauge.Axes[0]; NLinearScale scale = (NLinearScale)axis.Scale; scale.Labels.Style.Angle = angle; // apply angle to linear gauge axis axis = (NGaugeAxis)m_LinearGauge.Axes[0]; scale = (NLinearScale)axis.Scale; scale.Labels.Style.Angle = angle; }
private void UpdateScaleLabelAngle() { NScaleLabelAngle angle = new NScaleLabelAngle((ScaleLabelAngleMode)AngleModeComboBox.SelectedIndex, (int)CustomAngleNumericComboBox.SelectedItem, AllowTextFlipCheckBox.IsChecked.Value); // apply angle to radial gauge axis NGaugeAxis axis = (NGaugeAxis)m_RadialGauge.Axes[0]; NLinearScaleConfigurator scale = (NLinearScaleConfigurator)axis.ScaleConfigurator; scale.LabelStyle.Angle = angle; // apply angle to linear gauge axis axis = (NGaugeAxis)m_LinearGauge.Axes[0]; scale = (NLinearScaleConfigurator)axis.ScaleConfigurator; scale.LabelStyle.Angle = angle; nChartControl1.Refresh(); }
protected void UpdateScaleLabelAngle() { // read the form control values float customAngle; if (!float.TryParse(CustomAngleTextBox.Text, out customAngle) || customAngle < 0 || customAngle > 360) { customAngle = 0f; CustomAngleTextBox.Text = customAngle.ToString(); } // update scale labels angle NScaleLabelAngle angle = new NScaleLabelAngle((ScaleLabelAngleMode)Enum.Parse(typeof(ScaleLabelAngleMode), angleModeDropDownList.SelectedItem.Value), customAngle, allowFlipCheckBox.Checked); // apply angle to radial gauge axis NGaugeAxis axis = (NGaugeAxis)m_RadialGauge.Axes[0]; NLinearScaleConfigurator scale = (NLinearScaleConfigurator)axis.ScaleConfigurator; scale.LabelStyle.Angle = angle; }
private void UpdateScaleLabelAngle() { if (m_Chart != null) { int count = m_Chart.Axes.Count; NScaleLabelAngle angle = new NScaleLabelAngle((ScaleLabelAngleMode)AngleModeComboBox.SelectedIndex, (float)CustomAngleNumericUpDown.Value, AllowTextFlipCheckBox.Checked); // update the x axis NAxis axis = (NAxis)m_Chart.Axes[(int)StandardAxis.PrimaryX]; NStandardScaleConfigurator scale = axis.ScaleConfigurator as NStandardScaleConfigurator; scale.LabelStyle.Angle = angle; // update the depth axis axis = (NAxis)m_Chart.Axes[(int)StandardAxis.Depth]; scale = axis.ScaleConfigurator as NStandardScaleConfigurator; scale.LabelStyle.Angle = angle; nChartControl1.Refresh(); } }
protected void Page_Load(object sender, System.EventArgs e) { // init form controls if (!IsPostBack) { AngleModeDropDownList.Items.Add("View"); AngleModeDropDownList.Items.Add("Scale"); AngleModeDropDownList.SelectedIndex = 1; AllowFlipCheckBox.Checked = false; FitAxisContentInBox.Checked = true; } nChartControl1.BackgroundStyle.FrameStyle.Visible = false; nChartControl1.Settings.JitterMode = JitterMode.Enabled; nChartControl1.Panels.Clear(); // set a chart title NLabel header = new NLabel("Axis Labels Orientation"); nChartControl1.Panels.Add(header); header.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); header.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; header.Margins = new NMarginsL(10, 10, 10, 4); header.DockMode = PanelDockMode.Top; // setup the chart NCartesianChart chart = new NCartesianChart(); nChartControl1.Panels.Add(chart); chart.Enable3D = true; chart.Fit3DAxisContent = FitAxisContentInBox.Checked; chart.DockMode = PanelDockMode.Fill; chart.BorderStyle = new NStrokeBorderStyle(BorderShape.RoundedRect); chart.BackgroundFillStyle = new NGradientFillStyle(Color.White, Color.LightGray); chart.Margins = new NMarginsL(10, 0, 10, 10); chart.Padding = new NMarginsL(2, 2, 2, 2); // set predefined projection and lighting chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveTilted); chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.MetallicLustre); chart.Depth = 50; chart.Width = 50; chart.Height = 50; chart.BoundsMode = BoundsMode.Fit; chart.Location = new NPointL(new NLength(10, NRelativeUnit.ParentPercentage), new NLength(10, NRelativeUnit.ParentPercentage)); chart.Size = new NSizeL(new NLength(80, NRelativeUnit.ParentPercentage), new NLength(80, NRelativeUnit.ParentPercentage)); // add interlaced stripe NStandardScaleConfigurator scaleConfiguratorY = (NStandardScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; NScaleStripStyle stripStyle = new NScaleStripStyle(); stripStyle.FillStyle = new NColorFillStyle(Color.Beige); stripStyle.SetShowAtWall(ChartWallType.Back, true); stripStyle.SetShowAtWall(ChartWallType.Left, true); stripStyle.Interlaced = true; scaleConfiguratorY.StripStyles.Add(stripStyle); // add series Color[] seriesColors = new Color[] { Color.Crimson, Color.Orange, Color.OliveDrab }; int dataItemsCount = 6; for (int i = 0; i < seriesColors.Length; i++) { NBarSeries bar = (NBarSeries)chart.Series.Add(SeriesType.Bar); bar.BarShape = BarShape.SmoothEdgeBar; bar.FillStyle = new NColorFillStyle(seriesColors[i]); bar.Name = "Series " + i.ToString(); bar.Values.FillRandomRange(Random, dataItemsCount, 10, 30); bar.InflateMargins = true; bar.DataLabelStyle.Visible = false; } // configure the x axis labels (categories) NOrdinalScaleConfigurator ordinalScale = chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator as NOrdinalScaleConfigurator; ordinalScale.AutoLabels = false; ordinalScale.Title.Text = "Categories Title"; ordinalScale.MajorTickMode = MajorTickMode.CustomStep; ordinalScale.LabelFitModes = new LabelFitMode[] { LabelFitMode.Stagger2, LabelFitMode.AutoScale }; for (int i = 0; i < dataItemsCount; i++) { ordinalScale.Labels.Add("S" + i.ToString()); } // configure the depth axis labels (series) ordinalScale = chart.Axis(StandardAxis.Depth).ScaleConfigurator as NOrdinalScaleConfigurator; ordinalScale.AutoLabels = false; ordinalScale.Title.Text = "Series Title"; ordinalScale.MajorTickMode = MajorTickMode.CustomStep; ordinalScale.Labels.Add("S1"); ordinalScale.Labels.Add("S2"); ordinalScale.Labels.Add("S3"); ordinalScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, true); ordinalScale.LabelFitModes = new LabelFitMode[] { LabelFitMode.Stagger2, LabelFitMode.AutoScale }; // set title to Y axis NNumericScaleConfigurator numericScale = chart.Axis((int)StandardAxis.PrimaryY).ScaleConfigurator as NNumericScaleConfigurator; numericScale.Title.Text = "Values"; // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); // read the form control values float customAngle; if (!float.TryParse(CustomAngleTextBox.Text, out customAngle) || customAngle < 0 || customAngle > 360) { customAngle = 0f; CustomAngleTextBox.Text = customAngle.ToString(); } // update scale labels angle int count = chart.Axes.Count; NScaleLabelAngle angle = new NScaleLabelAngle((ScaleLabelAngleMode)Enum.Parse(typeof(ScaleLabelAngleMode), AngleModeDropDownList.SelectedItem.Value), customAngle, AllowFlipCheckBox.Checked); // update the x axis NAxis axis = (NAxis)chart.Axes[(int)StandardAxis.PrimaryX]; NStandardScaleConfigurator scale = axis.ScaleConfigurator as NStandardScaleConfigurator; scale.LabelStyle.Angle = angle; // update the depth axis axis = (NAxis)chart.Axes[(int)StandardAxis.Depth]; scale = axis.ScaleConfigurator as NStandardScaleConfigurator; scale.LabelStyle.Angle = angle; }
public override void Create() { nChartControl1.Panels.Clear(); // set a chart title NLabel header = new NLabel("Gauge Custom Labels"); header.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, System.Drawing.FontStyle.Italic); header.ContentAlignment = ContentAlignment.BottomRight; header.Location = new NPointL(new NLength(2, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage)); nChartControl1.Panels.Add(header); // create the radial gauge NRadialGaugePanel radialGauge = new NRadialGaugePanel(); radialGauge.Location = new NPointL(new NLength(10, NRelativeUnit.ParentPercentage), new NLength(12, NRelativeUnit.ParentPercentage)); radialGauge.Size = new NSizeL(new NLength(80, NRelativeUnit.ParentPercentage), new NLength(80, NRelativeUnit.ParentPercentage)); radialGauge.PaintEffect = new NGlassEffectStyle(); radialGauge.BorderStyle = new NEdgeBorderStyle(BorderShape.Auto); NAdvancedGradientFillStyle advGradient = new NAdvancedGradientFillStyle(); advGradient.BackgroundColor = Color.Black; advGradient.Points.Add(new NAdvancedGradientPoint(Color.White, 10, 10, 0, 100, AGPointShape.Circle)); radialGauge.BackgroundFillStyle = advGradient; radialGauge.SweepAngle = 360; radialGauge.BeginAngle = -90; nChartControl1.Panels.Add(radialGauge); NGaugeAxis axis = (NGaugeAxis)radialGauge.Axes[0]; axis.Range = new NRange1DD(0, 60); axis.Anchor.RulerOrientation = RulerOrientation.Right; axis.Anchor = new NDockGaugeAxisAnchor(GaugeAxisDockZone.Top, true, RulerOrientation.Right, 0, 100); NLinearScaleConfigurator scale = (NLinearScaleConfigurator)axis.ScaleConfigurator; NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.FromArgb(20, Color.LightGray)), null, true, 0, 0, 1, 1); stripStyle.SetShowAtWall(ChartWallType.Back, true); stripStyle.Interlaced = true; scale.StripStyles.Add(stripStyle); scale.MinorTickCount = 4; scale.MajorTickMode = MajorTickMode.CustomStep; scale.CustomStep = 5.0f; scale.SetPredefinedScaleStyle(PredefinedScaleStyle.Watch); scale.OuterMajorTickStyle.FillStyle = new NGradientFillStyle(Color.White, Color.Beige); scale.OuterMajorTickStyle.LineStyle = new NStrokeStyle(Color.DarkGray); scale.OuterMajorTickStyle.Length = new NLength(14); scale.RulerStyle.FillStyle = new NColorFillStyle(Color.FromArgb(50, Color.Silver)); scale.RulerStyle.BorderStyle = new NStrokeStyle(Color.Beige); axis.UpdateScale(); axis.SynchronizeScaleWithConfigurator = false; NTextStyle textStyle1 = new NTextStyle(); textStyle1.FillStyle = new NColorFillStyle(Color.White); textStyle1.BorderStyle = new NStrokeStyle(1, Color.Beige); textStyle1.FontStyle.Style = System.Drawing.FontStyle.Bold; textStyle1.FontStyle.EmSize = new NLength(22); NScaleLabelAngle angle = new NScaleLabelAngle(ScaleLabelAngleMode.Scale, 0); NTextStyle textStyle2 = new NTextStyle(); textStyle2.FillStyle = new NColorFillStyle(Color.White); textStyle2.BorderStyle = new NStrokeStyle(1, Color.Beige); textStyle2.FontStyle.Style = System.Drawing.FontStyle.Bold; textStyle2.FontStyle.EmSize = new NLength(12); NCustomScaleDecorator customDecorator = new NCustomScaleDecorator(); NValueScaleLabelStyle style1 = new NValueScaleLabelStyle(textStyle1, ContentAlignment.MiddleCenter, angle, new NLength(0)); NValueScaleLabelStyle style2 = new NValueScaleLabelStyle(textStyle2, ContentAlignment.MiddleCenter, angle, new NLength(0)); for (int i = 12; i > 0; i--) { string text = NSystem.IntToRoman(i); NValueScaleLabel hourLabel; if (i % 3 == 0) { hourLabel = new NValueScaleLabel(new NScaleValueDecorationAnchor(i * 5), text, (NValueScaleLabelStyle)style1.Clone()); } else { hourLabel = new NValueScaleLabel(new NScaleValueDecorationAnchor(i * 5), text, (NValueScaleLabelStyle)style2.Clone()); } customDecorator.Decorations.Add(hourLabel); } NScaleLevel textLevel = (NScaleLevel)axis.Scale.Levels[1]; textLevel.Decorators.Clear(); textLevel.Decorators.Add(customDecorator); m_HoursArrow = new NNeedleValueIndicator(); m_HoursArrow.Value = 79; m_HoursArrow.Shape.FillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.White, Color.Red); m_HoursArrow.Shape.StrokeStyle.Color = Color.Red; m_HoursArrow.OffsetOriginMode = IndicatorOffsetOriginMode.ScaleEnd; m_HoursArrow.OffsetFromScale = new NLength(30); m_HoursArrow.Width = new NLength(8); radialGauge.Indicators.Add(m_HoursArrow); m_MinituesArrow = new NNeedleValueIndicator(); m_MinituesArrow.Value = 79; m_MinituesArrow.Shape.FillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.White, Color.Red); m_MinituesArrow.Shape.StrokeStyle.Color = Color.Red; m_MinituesArrow.OffsetOriginMode = IndicatorOffsetOriginMode.ScaleEnd; m_MinituesArrow.OffsetFromScale = new NLength(30); m_MinituesArrow.Width = new NLength(5); radialGauge.Indicators.Add(m_MinituesArrow); m_SecondsArrow = new NNeedleValueIndicator(); m_SecondsArrow.Value = 79; m_SecondsArrow.Shape.FillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.White, Color.Red); m_MinituesArrow.OffsetOriginMode = IndicatorOffsetOriginMode.ScaleEnd; m_SecondsArrow.Shape.StrokeStyle.Color = Color.Red; m_SecondsArrow.OffsetFromScale = new NLength(10); m_SecondsArrow.Width = new NLength(1); radialGauge.Indicators.Add(m_SecondsArrow); //nChartControl1.AutoRefresh = true; SynchronizeWithTime(); m_Timer = new DispatcherTimer(); m_Timer.Interval = new TimeSpan(1000); m_Timer.Tick += m_Timer_Tick; m_Timer.IsEnabled = true; m_Timer.Start(); }