Esempio n. 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();
        }
Esempio n. 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();
        }
Esempio n. 3
0
        private void ImportFromDatabase_Click(object sender, System.EventArgs e)
        {
            nChartControl1.Clear();

            InitTitleAndBackground();

            OleDbConnection myConnection = null;
            OleDbDataReader myReader     = null;

            try
            {
                // create a database connection object using the connection string
                myConnection = new OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" + Application.StartupPath + "\\..\\..\\DataManipulation\\Importing\\DataBinding.mdb");

                // create a database command on the connection using query
                OleDbCommand myCommand = new OleDbCommand("select * from Sales", myConnection);

                // create a bar chart
                NChart     chart = nChartControl1.Charts[0];
                NBarSeries bar   = (NBarSeries)chart.Series.Add(SeriesType.Bar);
                bar.Legend.Mode = SeriesLegendMode.DataPoints;

                // import the SalesAmount and ProductName into the bar Values and Labels
                myCommand.Connection.Open();
                myReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection);

                NDataSeriesCollection arrSeries = bar.GetDataSeries(DataSeriesMask.Values | DataSeriesMask.Labels, DataSeriesMask.None, false);
                string[] arrCollumns            = { "SalesAmount", "ProductName" };

                arrSeries.FillFromDataReader(myReader, arrCollumns);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                if (myReader != null)
                {
                    myReader.Close();
                }

                if (myConnection != null)
                {
                    myConnection.Close();
                }
            }

            nChartControl1.Refresh();
        }
Esempio n. 4
0
        private void ExportToDataTable_Click(object sender, System.EventArgs e)
        {
            NChart chart = nChartControl1.Charts[0];
            NDataSeriesCollection arrSeries = new NDataSeriesCollection();
            string sTableName = "";

            switch (ChartCombo.SelectedIndex)
            {
            case 0:                     // Bar Chart
                NBarSeries bar = (NBarSeries)chart.Series[0];
                sTableName = "Bar Chart";

                arrSeries.Add(bar.Values, DataSeriesMask.Values);
                arrSeries.Add(bar.Labels, DataSeriesMask.Labels);
                break;

            case 1:                     // Line Chart With X Values
                NLineSeries line = (NLineSeries)chart.Series[0];
                sTableName = "Line Chart";

                arrSeries.Add(line.Values, DataSeriesMask.Values);
                arrSeries.Add(line.XValues, DataSeriesMask.XValues);
                arrSeries.Add(line.Labels, DataSeriesMask.Labels);
                break;

            case 2:                     // Pie Chart with detachments
                NPieSeries pie = (NPieSeries)chart.Series[0];
                sTableName = "Pie Chart";

                arrSeries.Add(pie.Values, DataSeriesMask.Values);
                arrSeries.Add(pie.Detachments, DataSeriesMask.PieDetachments);
                arrSeries.Add(pie.Labels, DataSeriesMask.Labels);
                break;

            case 3:                     // Open - High - Low - Close
                NStockSeries stock = (NStockSeries)chart.Series[0];
                sTableName = "Stock Chart";

                arrSeries.Add(stock.OpenValues, DataSeriesMask.StockOpenValues);
                arrSeries.Add(stock.HighValues, DataSeriesMask.StockHighValues);
                arrSeries.Add(stock.LowValues, DataSeriesMask.StockLowValues);
                arrSeries.Add(stock.CloseValues, DataSeriesMask.StockCloseValues);
                break;
            }

            dataView1.Table = arrSeries.ExportToDataTable(sTableName);

            nChartControl1.Refresh();
        }
Esempio n. 5
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();
        }
Esempio n. 6
0
        private void ImportFromDataView_Click(object sender, System.EventArgs e)
        {
            NChart chart = nChartControl1.Charts[0];

            chart.Series.Clear();

            NBarSeries bar = (NBarSeries)chart.Series.Add(SeriesType.Bar);

            NDataSeriesCollection arrSeries = new NDataSeriesCollection();

            arrSeries.Add(bar.Values, DataSeriesMask.Values);
            arrSeries.Add(bar.Labels, DataSeriesMask.Labels);

            string[] arrCollumns = { "Values", "Labels" };
            arrSeries.FillFromDataView(dataView1, arrCollumns);

            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);
            }
        }
Esempio n. 8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;

            NLegend legend = nChartControl1.Legends[0];

            legend.FillStyle.SetTransparencyPercent(50);
            legend.SetPredefinedLegendStyle(PredefinedLegendStyle.Bottom);
            legend.Data.ExpandMode = LegendExpandMode.RowsFixed;
            legend.Data.RowCount   = 2;

            // set a chart title
            NLabel title = nChartControl1.Labels.AddHeader("Import from Data Reader");

            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));

            // configure the chart
            NChart chart = nChartControl1.Charts[0];

            chart.Width      = 100.0f;
            chart.Height     = 65.0f;
            chart.BoundsMode = BoundsMode.Stretch;
            chart.Location   = new NPointL(
                new NLength(10, NRelativeUnit.ParentPercentage),
                new NLength(20, NRelativeUnit.ParentPercentage));
            chart.Size = new NSizeL(
                new NLength(80, NRelativeUnit.ParentPercentage),
                new NLength(58, NRelativeUnit.ParentPercentage));

            // create a bar chart
            NBarSeries bar = (NBarSeries)chart.Series.Add(SeriesType.Bar);

            bar.DataLabelStyle.Visible = false;
            bar.Legend.Mode            = SeriesLegendMode.DataPoints;

            OleDbConnection myConnection = null;
            OleDbDataReader myReader     = null;

            try
            {
                // create a database connection object using the connection string
                myConnection = new OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" + this.MapPathSecure(this.TemplateSourceDirectory + "\\DataBinding.mdb"));

                // create a database command on the connection using query
                OleDbCommand myCommand = new OleDbCommand("select * from Sales", myConnection);

                // import the SalesAmount and ProductName into the bar Values and Labels
                myCommand.Connection.Open();
                myReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection);

                NDataSeriesCollection arrSeries = bar.GetDataSeries(DataSeriesMask.Values | DataSeriesMask.Labels, DataSeriesMask.None, false);
                string[] arrCollumns            = { "SalesAmount", "ProductName" };

                arrSeries.FillFromDataReader(myReader, arrCollumns);
            }
            finally
            {
                if (myReader != null)
                {
                    myReader.Close();
                }

                if (myConnection != null)
                {
                    myConnection.Close();
                }
            }

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

            styleSheet.Apply(nChartControl1.Document);
        }