Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created November 2, 2022 19:30
Show Gist options
  • Save bjoerntx/e1b992e65ae27d87b8d2f4510e1a3c77 to your computer and use it in GitHub Desktop.
Save bjoerntx/e1b992e65ae27d87b8d2f4510e1a3c77 to your computer and use it in GitHub Desktop.
// create a new chart control
Chart chart = new Chart();
// add a chart area
chart.ChartAreas.Add("chartArea1");
chart.Series.Add("series1");
chart.Series["series1"].ChartArea = "chartArea1";
chart.Series["series1"].ChartType = SeriesChartType.Bar;
// connect to a data source
DataSet ds = new DataSet();
ds.ReadXml("data.xml");
chart.Series[0].XValueMember = ds.Tables[0].Columns[0].ColumnName;
chart.Series[0].YValueMembers = ds.Tables[0].Columns[1].ColumnName;
chart.DataSource = ds.Tables[0];
chart.DataBind();
// create a chart frame
TXTextControl.DataVisualization.ChartFrame frame =
new TXTextControl.DataVisualization.ChartFrame(chart);
frame.Name = "points";
// add chart to the document
textControl1.Charts.Add(frame, -1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment