Charts

C# affords us the convenience of quickly and efficiently designing one of the simplest forms of data visualization: charts. You can implement various types of charts, including vertical bars, horizontal bars, line charts, and the preferred chart type of the world's most famous Nuclear Safety Inspector: a doughnut chart.

How the chart is generated is fixed, depending on the type you've choosen, so the only work you need to do upfront is filling the chart with DataPoints, placed inside of a DataPointCollection object.

DataPoint objects contain properties such as XValue, YValues, and Color. "YValue" is an array of doubles, as would be necessary for most types of graphs, except bubble, candlestick, and stock charts. Stock charts, for example, would require a high, low, open, and closed value to be associated with each DataPoint. You can individually build each DataPoint before adding them to a DataPointCollection or you can build them dynamically as you add them (public int AddXY(double X, double Y) to the collection.

The Series class stores the DataPointCollection alongside a variety of attributes. The properties are Points (referring to the collection); ChartType referring to -- you guessed it (chart types are defined within a SeriesChartType enumeration); and a ChartArea, which defines the digital real estate occupied by this chart.

With these tools in hand, you can easily and quickly build simple data visualizations, either populated before the chart is drawn or modified in real-time as new DataPoints are added.