private void GroupValues_Click(object sender, System.EventArgs e) { if (m_bGroupedData) { MessageBox.Show("Click the ungroup button first"); return; } // get a subset containing the pies which are smaller than the specified value NDataSeriesSubset smallerThanValue = m_Pie.Values.Filter(Nevron.Chart.CompareMethod.Less, m_dGroupValue); // determine the sum of the filtered pies double dOtherSliceValue = m_Pie.Values.Evaluate("SUM", smallerThanValue); // remove the data points contained in the for (int i = m_Pie.GetDataPointCount(); i >= 0; i--) { if (smallerThanValue.Contains(i)) { m_Pie.RemoveDataPointAt(i); } } // add a detached pie with the specified group label and color NDataPoint dp = new NDataPoint(dOtherSliceValue, m_sGroupLabel); dp[DataPointValue.PieDetachment] = 2; dp[DataPointValue.FillStyle] = new NColorFillStyle(m_GroupColor); dp[DataPointValue.StrokeStyle] = new NStrokeStyle(1, m_GroupColor); m_Pie.AddDataPoint(dp); m_bGroupedData = true; nChartControl1.Refresh(); }
private void Filter(NBarSeries bar) { NDataSeriesSubset subsetAll = new NDataSeriesSubset(); NDataSeriesSubset subsetFilter = new NDataSeriesSubset(); subsetAll.AddRange(0, bar.Values.Count - 1); try { double dValue = Double.Parse(ValueTextBox.Text); Nevron.Chart.CompareMethod method = (Nevron.Chart.CompareMethod)FilterDropDownList.SelectedIndex; subsetFilter = bar.Values.Filter(method, dValue); // apply red color only to the bars in the filter subset foreach (int index in subsetFilter) { bar.FillStyles[index] = new NColorFillStyle(Color.Red); } } catch { } }
private void ApplyColorToSubset(NDataSeriesSubset subset, Color color) { m_Bar.FillStyles.Clear(); foreach (int index in subset) { m_Bar.FillStyles[index] = new NColorFillStyle(color); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { FunctionDropDownList.Items.Add("MIN"); FunctionDropDownList.Items.Add("MAX"); FunctionDropDownList.Items.Add("AVE"); FunctionDropDownList.Items.Add("SUM"); FunctionDropDownList.Items.Add("ABSSUM"); FunctionDropDownList.Items.Add("FIRST"); FunctionDropDownList.Items.Add("LAST"); FunctionDropDownList.SelectedIndex = 0; } nChartControl1.BackgroundStyle.FrameStyle.Visible = false; // add header NLabel header = nChartControl1.Labels.AddHeader("Evaluating Data"); header.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); header.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; header.TextStyle.FillStyle = new NColorFillStyle(Color.FromArgb(60, 90, 108)); header.ContentAlignment = ContentAlignment.BottomRight; header.Location = new NPointL( new NLength(2, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage)); // configure the legend nChartControl1.Legends.Clear(); // setup the chart NChart chart = nChartControl1.Charts[0]; chart.Axis(StandardAxis.Depth).Visible = false; chart.BoundsMode = BoundsMode.Stretch; chart.Location = new NPointL( new NLength(5, NRelativeUnit.ParentPercentage), new NLength(15, NRelativeUnit.ParentPercentage)); chart.Size = new NSizeL( new NLength(90, NRelativeUnit.ParentPercentage), new NLength(80, NRelativeUnit.ParentPercentage)); NBarSeries bar = (NBarSeries)chart.Series.Add(SeriesType.Bar); bar.Values.FillRandom(Random, 10); NDataSeriesSubset subset = new NDataSeriesSubset(); subset.AddRange(0, 9); string function = FunctionDropDownList.SelectedItem.Text; double result = bar.Values.Evaluate(function, subset); ResultTextBox.Text = result.ToString(); }
public NFilteringDataUC() { InitializeComponent(); m_SubsetAll = new NDataSeriesSubset(); m_SubsetFilter = new NDataSeriesSubset(); compareMethodCombo.FillFromEnum(typeof(Nevron.Chart.CompareMethod)); subsetOperationCombo.Items.Add("Replace"); subsetOperationCombo.Items.Add("Combine"); subsetOperationCombo.Items.Add("Intersect"); subsetOperationCombo.Items.Add("Subtract"); }
public NEvaluatingDataUC() { InitializeComponent(); m_Subset = new NDataSeriesSubset(); FunctionCombo.Items.Add("MIN"); FunctionCombo.Items.Add("MAX"); FunctionCombo.Items.Add("AVE"); FunctionCombo.Items.Add("SUM"); FunctionCombo.Items.Add("ABSSUM"); FunctionCombo.Items.Add("FIRST"); FunctionCombo.Items.Add("LAST"); }
private void ApplyFilter_Click(object sender, System.EventArgs e) { double dValue; string sFilter = ""; string sOperation = ""; // make all colors blue ApplyColorToSubset(m_SubsetAll, Color.Blue); try { dValue = Double.Parse(Value.Text); } catch { return; } Nevron.Chart.CompareMethod compareMethod = (Nevron.Chart.CompareMethod)compareMethodCombo.SelectedIndex; NDataSeriesSubset subset = m_Bar.Values.Filter(compareMethod, dValue); switch (compareMethodCombo.SelectedIndex) { case 0: sFilter = "(> " + dValue.ToString() + ")"; break; case 1: sFilter = "(< " + dValue.ToString() + ")"; break; case 2: sFilter = "(==" + dValue.ToString() + ")"; break; case 3: sFilter = "(>=" + dValue.ToString() + ")"; break; case 4: sFilter = "(<=" + dValue.ToString() + ")"; break; case 5: sFilter = "(!=" + dValue.ToString() + ")"; break; } switch (subsetOperationCombo.SelectedIndex) { case 0: // replace m_SubsetFilter = subset; OperationList.Items.Clear(); sOperation = "f = "; break; case 1: // combine m_SubsetFilter.Combine(subset); sOperation = "f = f combine "; break; case 2: // intersect m_SubsetFilter.Intersect(subset); sOperation = "f = f intersect "; break; case 3: // subtract m_SubsetFilter.Subtract(subset); sOperation = "f = f subtract "; break; } OperationList.Items.Add(sOperation + sFilter); CurrentFilter.Text = m_SubsetFilter.ToString(); // apply red color only on the bars in the filter subset ApplyColorToSubset(m_SubsetFilter, Color.Red); nChartControl1.Refresh(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { WebExamplesUtilities.FillComboWithColorNames(GroupedPieColorDropDownList); GroupedPieColorDropDownList.SelectedIndex = 20; // init form controls ThresholdValueTextBox.Text = "34"; GroupedPieLabelTextBox.Text = "Other"; } nChartControl1.BackgroundStyle.FrameStyle.Visible = false; nChartControl1.Settings.JitterMode = JitterMode.Enabled; // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Grouped Pie Chart"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; title.ContentAlignment = ContentAlignment.BottomRight; title.Location = new NPointL( new NLength(2, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage)); // setup legend NLegend legend = nChartControl1.Legends[0]; legend.OuterBottomBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); legend.OuterLeftBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); legend.OuterRightBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); legend.OuterTopBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); legend.FillStyle.SetTransparencyPercent(70); legend.HorizontalBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); legend.VerticalBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); // by default the control contains a Cartesian chart -> remove it and create a Pie chart NChart chart = new NPieChart(); nChartControl1.Charts.Clear(); nChartControl1.Charts.Add(chart); chart.Enable3D = true; chart.DisplayOnLegend = nChartControl1.Legends[0]; chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveElevated); chart.BoundsMode = BoundsMode.Fit; chart.Location = new NPointL( new NLength(20, NRelativeUnit.ParentPercentage), new NLength(20, NRelativeUnit.ParentPercentage)); chart.Size = new NSizeL( new NLength(60, NRelativeUnit.ParentPercentage), new NLength(60, NRelativeUnit.ParentPercentage)); // setup pie series NPieSeries pie = (NPieSeries)chart.Series.Add(SeriesType.Pie); pie.Legend.Mode = SeriesLegendMode.None; pie.PieStyle = PieStyle.SmoothEdgePie; int count = 10; pie.Values.FillRandomRange(Random, count, 1, 100); for (int i = 0; i < count; i++) { pie.Detachments.Add(0); pie.Labels.Add(arrLabels[i]); pie.FillStyles[i] = arrCustomColors2[i % arrCustomColors2.Length]; } if (GroupPiesCheckBox.Checked == true) { try { Color groupColor = WebExamplesUtilities.ColorFromDropDownList(GroupedPieColorDropDownList); double dGroupValue = Int32.Parse(ThresholdValueTextBox.Text); // get a subset containing the pies which are smaller than the specified value NDataSeriesSubset smallerThanValue = pie.Values.Filter(Nevron.Chart.CompareMethod.Less, dGroupValue); // determine the sum of the filtered pies double dOtherSliceValue = pie.Values.Evaluate("SUM", smallerThanValue); // remove the data points contained in the for (int i = pie.GetDataPointCount(); i >= 0; i--) { if (smallerThanValue.Contains(i)) { pie.RemoveDataPointAt(i); } } // add a detached pie with the specified group label and color NDataPoint dp = new NDataPoint(dOtherSliceValue, GroupedPieLabelTextBox.Text); dp[DataPointValue.PieDetachment] = 1.0; dp[DataPointValue.FillStyle] = new NColorFillStyle(groupColor); dp[DataPointValue.StrokeStyle] = new NStrokeStyle(1, groupColor); pie.AddDataPoint(dp); } catch { } } else { } }
private void SetConstline(NDataSeriesDouble ds) { NAxis axis = m_Chart.Axis(StandardAxis.PrimaryY); // add a constline if necessary if (axis.ConstLines.Count == 0) { axis.ConstLines.Add(); } // the line series won't be used m_Line.Visible = false; // add a new constline NAxisConstLine cl = (NAxisConstLine)axis.ConstLines[0]; cl.StrokeStyle.Width = new NLength(3, NGraphicsUnit.Pixel); cl.StrokeStyle.Color = Color.Green; cl.Value = (double)ds.GetValueForIndex(0); string text = cl.Value.ToString(); if (text.Length > 7) { text = text.Substring(0, 7); } /* NAxisCustomLabel axisLabel = axis.CustomLabels.Add(); * axisLabel.Offset = 3; * axisLabel.TextStyle.BackplaneStyle.Visible = true; * axisLabel.Angle = 180; * axisLabel.Text = text; * axisLabel.Value = cl.Value;*/ // set proper scale for the axis, so that it includes the constline NDataSeriesSubset subset = new NDataSeriesSubset(); subset.AddRange(0, ds.Count - 1); double max1 = m_Line1.Values.Evaluate("MAX", subset); double min1 = m_Line1.Values.Evaluate("MIN", subset); double max2 = m_Line2.Values.Evaluate("MAX", subset); double min2 = m_Line2.Values.Evaluate("MIN", subset); if (max1 < max2) { max1 = max2; } if (min1 > min2) { min1 = min2; } if (cl.Value > max1) { axis.View = new NRangeAxisView(new NRange1DD(double.MinValue, cl.Value), false, true); } else if (cl.Value < min1) { axis.View = new NRangeAxisView(new NRange1DD(cl.Value, double.MaxValue), true, false); } }