Example #1
0
        public override void Initialize()
        {
            base.Initialize();

            // add a label
            NLabel title = nChartControl1.Labels.AddHeader("Binding to DataAdapter");

            title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic);
            title.ContentAlignment    = ContentAlignment.BottomCenter;
            title.Location            = new NPointL(new NLength(50, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage));

            NChart chart = nChartControl1.Charts[0];

            // add the bar series
            NBarSeries bar = new NBarSeries();

            chart.Series.Add(bar);
            bar.Name                  = "Bar";
            bar.Legend.Format         = "<label>";
            bar.DataLabelStyle.Format = "<label>";
            bar.BarShape              = BarShape.SmoothEdgeBar;
            bar.Legend.Mode           = SeriesLegendMode.DataPoints;

            // connection string with relative path
            this.oleDbConnection1.ConnectionString = @"Data Source=""" + Application.StartupPath + @"\..\..\DataManipulation\DataBinding\Data.mdb"";Provider=""Microsoft.Jet.OLEDB.4.0"";";

            try
            {
                NDataBindingManager dataBindingManager = nChartControl1.DataBindingManager;

                dataBindingManager.AddBinding(0, 0, "Values", oleDbDataAdapter1, "values");
                dataBindingManager.AddBinding(0, 0, "Labels", oleDbDataAdapter1, "colors");
                dataBindingManager.AddBinding(0, 0, "FillStyles", oleDbDataAdapter1, "colors");
                dataBindingManager.UpdateChartControl();

                oleDbDataAdapter1.Fill(dataSet1);

                DataTable dataTable = dataSet1.Tables[0];
                dataTable.Columns["id"].ReadOnly = true;
                dataTable.RowChanged            += new DataRowChangeEventHandler(dataTable_RowChanged);

                dataView1.Table = dataTable;
            }
            catch (Exception x)
            {
                MessageBox.Show(x.Message);
            }
        }
        public override void Initialize()
        {
            base.Initialize();

            // setup background

            // add a label
            NLabel title = nChartControl1.Labels.AddHeader("Binding to DataTable");

            title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic);

            title.ContentAlignment = ContentAlignment.BottomCenter;
            title.Location         = new NPointL(new NLength(50, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage));


            NChart chart = nChartControl1.Charts[0];

            // add bar series 1
            NBarSeries bar1 = (NBarSeries)chart.Series.Add(SeriesType.Bar);

            bar1.Name = "Bar 1";
            bar1.DataLabelStyle.Format = "<value>";

            // add bar series 2
            NBarSeries bar2 = (NBarSeries)chart.Series.Add(SeriesType.Bar);

            bar2.MultiBarMode          = MultiBarMode.Clustered;
            bar2.FillStyle             = new NColorFillStyle(Color.Violet);
            bar2.Name                  = "Bar 2";
            bar2.DataLabelStyle.Format = "<value>";

            NDataBindingManager dataBindingManager = nChartControl1.DataBindingManager;

            dataBindingManager.AddBinding(0, 0, "Values", dataTable, "ValueY1");
            dataBindingManager.AddBinding(0, 1, "Values", dataTable, "ValueY2");

            dataGrid1.SetDataBinding(dataTable, null);
        }