RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


Build a Reusable Graphical Charting Engine with C# : Page 5

The .NET framework contains everything you need to build this customizable line-graphing application that supports multiple overlaid data sets, each with its own color and line style. Unless you need extremely sophisticated charts, just draw your own.

Supporting Multiple Data Sets
Being able to draw a single graph is sufficient for many applications, but sometimes you need to be able to superimpose multiple graphs on the same set of axes. For example, it's common to annotate a share price chart with some kind of moving average, or even a set of them. These additional graphs must be drawn to the same scale as the primary graph (you don't want to draw another set of axes), and their data range should be independent of the chart's final data rectangle. In other words, these secondary graphs are simply overlays on the primary graph; they shouldn't have any effect on the primary chart itself).

You'll also want to make some kind of visual distinction between these secondary data sets; therefore it's time to move the data set implementation (previously just an array of PointF objects) into a separate class. The Chart.Study class lets you customize the color and drawing style of each individual data study. It's a nested class, because it has no significance outside the context of its parent. Figure 7 depicts a chart with a single study, and Figure 8 shows the same chart with a secondary study

Thanks for your registration, follow us on our social networks to keep up-to-date