April 23, 2014
Hot Topics:
RSS RSS feed Download our iPhone app

Microsoft Charts Overview

  • June 4, 2009
  • By Matt Goebel, Rachel Baker
  • Send Email »
  • More Articles »

Introduction

Charts are great for displaying information to users in a graphical, tangible way. To support charts in .NET applications, Microsoft provides an add-on for .NET 3.5 SP1 and Visual Studio 2008 to support robust charts without purchasing expensive, proprietary software. In order to create charts like the ones shown in this article, you will need to install Microsoft Chart Controls for Microsoft .NET Framework 3.5 and Microsoft Chart Controls add-on for Microsoft Visual Studio 2008. If you are new to MS Charts, you can check out this overview to help you get started and set up.

The following are overviews of the key pieces used in creating and displaying a chart with the MSChart control. The final section is a grouping of tips and tricks that will serve to make your first MSChart experience more enjoyable.

ChartAreas

The ChartAreas property is a collection of ChartArea objects. A ChartArea is what is responsible for the display properties of the container, or "background," of the chart. Since there can be more than one, this means that a single MSChart control can have multiple charts contained within it.



Click here for larger image

Figure 1.1 - Single and multiple ChartArea(s)

It is important to understand the following when using multiple ChartAreas:

  • While it is technically possible to control the positioning in order to "overlay" the ChartAreas, it is not recommended. Picture them as separate boxes within the MSChart control. To combine or overlay data points, it is more appropriate to use multiple series within a ChartArea. This will be discussed later. By default, the control will auto-size and position the ChartAreas for you.
  • The individual ChartArea will adjust independently to fit the data. As shown above, the Y values are larger in the second ChartArea, and there are fewer data points.
  • Multiple ChartAreas allows you to display charts with multiple ChartTypes (the property in the Series object that controls the type of chart to display; such as Bar, Column, or Pie) that are incompatible. The charts are still displayed in close proximity within the same MSChart control.

Focusing in on a single ChartArea, there are many individual properties that can be set and tweaked to give you the ability to design your chart area to fit many different situations. Most of its properties are similar to those of a Panel control, so we won't cover those. There are others that are unique to the ChartArea. Below is a list of those unique properties.

  • 3D Styling: By using the ChartArea's Area3DStyle property and sub properties, we are able to create sharp, eye-pleasing, 3D charts. You must set the "(Enable3D") property to True in either the designer or code. The rest of the properties allow the 3D effect to be tweaked by adjusting the rotation, perspective, lighting style, and other 3D elements that give an image a 3D appearance.



    Click here for larger image

    Figure 1.2 3D styling

  • Axes Control and Styling: The Axes collection contains the X and Y Axes, as well as secondary X and Y Axes. The properties on these 4 items allow you to style, set labels, define intervals, set tooltips, set scale, and many other items. Use these properties if your chart needs precise axes intervals, labels, or other special display requirements. For example, you can reverse axes values or control how the tick marks are displayed on the X axis. If you are using the chart for real-time values, you use the IntervalType property to configure the chart to show data points based on date and time.
  • Selection Cursor: If you are interested in allowing the user to be able to use the cursor to select data points, or to click and drag ranges, then the CursorX and CursorY sets of properties are useful. You can enable selection and set initial cursor position or range.





Page 1 of 3



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Sitemap | Contact Us

Rocket Fuel