Example #1
0
        private void SortAllOnLabels_Click(object sender, System.EventArgs e)
        {
            NDataSeriesCollection arrSeries = m_Bar.GetDataSeries(DataSeriesMask.Values | DataSeriesMask.Labels | DataSeriesMask.FillStyles, DataSeriesMask.None, false);

            int nMasterIndex = arrSeries.FindByMask(DataSeriesMask.Labels);

            arrSeries.Sort(nMasterIndex, (DataSeriesSortOrder)SortOrder.SelectedIndex);

            nChartControl1.Refresh();
        }
Example #2
0
        private void SortAllOnFillStyles_Click(object sender, System.EventArgs e)
        {
            // demonstration of the custom comparer support
            NCustomComparer customComparer = new NCustomComparer();

            NDataSeriesCollection arrSeries = m_Bar.GetDataSeries(DataSeriesMask.Values | DataSeriesMask.Labels | DataSeriesMask.FillStyles, DataSeriesMask.None, false);

            int nMasterIndex = arrSeries.FindByMask(DataSeriesMask.FillStyles);

            arrSeries.Sort(nMasterIndex, (DataSeriesSortOrder)SortOrder.SelectedIndex, customComparer);

            nChartControl1.Refresh();
        }
Example #3
0
        private void SortDescendingButton_Click(object sender, System.EventArgs e)
        {
            DataSeriesMask included = DataSeriesMask.RandomAccess |
                                      DataSeriesMask.FillStyles |
                                      DataSeriesMask.StrokeStyles |
                                      DataSeriesMask.DataLabelStyles;
            DataSeriesMask        excluded = DataSeriesMask.PieDetachments;
            NDataSeriesCollection arr      = m_Pie.GetDataSeries(included, excluded, false);

            int masterDataSeries = arr.FindByMask(DataSeriesMask.Values);

            arr.Sort(masterDataSeries, DataSeriesSortOrder.Descending);

            nChartControl1.Refresh();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                SortDropDownList.Items.Add("Ascending");
                SortDropDownList.Items.Add("Descending");
                SortDropDownList.SelectedIndex = 0;
            }

            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;

            // set a chart title
            NLabel title = nChartControl1.Labels.AddHeader("Sorted 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.Visible = false;
            legend.HorizontalBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel);
            legend.VerticalBorderStyle.Width   = new NLength(0, NGraphicsUnit.Pixel);
            legend.Location = new NPointL(
                new NLength(100, NRelativeUnit.ParentPercentage),
                new NLength(0, NRelativeUnit.ParentPercentage));

            // 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        = false;
            chart.DisplayOnLegend = nChartControl1.Legends[0];
            chart.BoundsMode      = BoundsMode.Fit;
            chart.Location        = new NPointL(
                new NLength(15, NRelativeUnit.ParentPercentage),
                new NLength(16, NRelativeUnit.ParentPercentage));
            chart.Size = new NSizeL(
                new NLength(70, NRelativeUnit.ParentPercentage),
                new NLength(70, NRelativeUnit.ParentPercentage));


            NPieSeries pie = (NPieSeries)chart.Series.Add(SeriesType.Pie);

            pie.PieStyle      = PieStyle.SmoothEdgePie;
            pie.Legend.Mode   = SeriesLegendMode.DataPoints;
            pie.Legend.Format = "<label> <percent>";

            pie.AddDataPoint(new NDataPoint(0, "Cars"));
            pie.AddDataPoint(new NDataPoint(0, "Trains"));
            pie.AddDataPoint(new NDataPoint(0, "Buses"));
            pie.AddDataPoint(new NDataPoint(0, "Airplanes"));
            pie.AddDataPoint(new NDataPoint(0, "Ships"));
            pie.Values.FillRandomRange(Random, 5, 1, 40);

            // apply style sheet
            NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.FreshMultiColor);

            styleSheet.Apply(nChartControl1.Document);

            DataSeriesMask        included = DataSeriesMask.RandomAccess;
            DataSeriesMask        excluded = DataSeriesMask.PieDetachments;
            NDataSeriesCollection arr      = pie.GetDataSeries(included, excluded, false);

            int masterDataSeries = arr.FindByMask(DataSeriesMask.Values);

            if (SortDropDownList.SelectedIndex == 0)
            {
                arr.Sort(masterDataSeries, DataSeriesSortOrder.Ascending);
            }
            else
            {
                arr.Sort(masterDataSeries, DataSeriesSortOrder.Descending);
            }
        }