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