private void UpdateScaleBreak() { if (nChartControl1 == null) { return; } NChart chart = nChartControl1.Charts[0]; NStandardScaleConfigurator scale = chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NStandardScaleConfigurator; scale.ScaleBreaks.Clear(); if (EnableScaleBreaksCheckBox.Checked) { NAutoScaleBreak scaleBreak = new NAutoScaleBreak((float)ThresholdUpDown.Value); scaleBreak.Style = new NLineScaleBreakStyle(); scaleBreak.Style.Length = new NLength((float)LengthUpDown.Value, NGraphicsUnit.Point); scaleBreak.MaxScaleBreakCount = (int)MaxBreaksUpDown.Value; NScaleBreakPosition scaleBreakPosition = new NRangeScaleBreakPosition(); switch (PositionModeComboBox.SelectedIndex) { case 0: // Range scaleBreakPosition = new NRangeScaleBreakPosition(); break; case 1: // percent scaleBreakPosition = new NPercentScaleBreakPosition((float)PositionPercentUpDown.Value); break; case 2: // content scaleBreakPosition = new NContentScaleBreakPosition(); break; } scaleBreak.Position = scaleBreakPosition; scale.ScaleBreaks.Add(scaleBreak); } nChartControl1.Refresh(); }
protected void UpdateScaleBreaks() { // read the form control values float threshold; if (!float.TryParse(thresholdTextBox.Text, out threshold) || threshold < 0 || threshold > 1) { threshold = 0.25f; thresholdTextBox.Text = threshold.ToString(); } int maxBreaks; if (!int.TryParse(maxBreaksTextBox.Text, out maxBreaks) || maxBreaks < 0 || maxBreaks > 3) { maxBreaks = 1; maxBreaksTextBox.Text = maxBreaks.ToString(); } float length; if (!float.TryParse(lengthTextBox.Text, out length) || length < 0 || length > 1000) { length = 5; lengthTextBox.Text = length.ToString(); } int positionPercent; if (!int.TryParse(positionPercentTextBox.Text, out positionPercent) || positionPercent < 0 || positionPercent > 1000) { positionPercent = 50; positionPercentTextBox.Text = positionPercent.ToString(); } // recreate scale breaks NChart chart = nChartControl1.Charts[0]; NStandardScaleConfigurator scale = chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NStandardScaleConfigurator; scale.ScaleBreaks.Clear(); if (enableBreaksCheckBox.Checked) { NAutoScaleBreak scaleBreak = new NAutoScaleBreak(threshold); scaleBreak.Style = new NWaveScaleBreakStyle(); scaleBreak.Style.Length = new NLength(length, NGraphicsUnit.Point); scaleBreak.MaxScaleBreakCount = maxBreaks; NScaleBreakPosition scaleBreakPosition = new NRangeScaleBreakPosition(); switch (positionModeDropDownList.SelectedIndex) { case 0: // Range scaleBreakPosition = new NRangeScaleBreakPosition(); break; case 1: // percent scaleBreakPosition = new NPercentScaleBreakPosition((float)positionPercent); break; case 2: // content scaleBreakPosition = new NContentScaleBreakPosition(); break; } scaleBreak.Position = scaleBreakPosition; scale.ScaleBreaks.Add(scaleBreak); } }