Summary of application of MSChart under C #

Source: Internet
Author: User
Tags border color

"WinForm" MSChart main properties

First, the drawing area Chartareas

You can add multiple drawing areas in a chart control, each containing a separate chart group, a data source, and can be used with multiple chart types.

1.AlignmentOrientation: Chart area alignment, defines the alignment between the two plot areas, the default is vertical.

2.AlignmentStyle: Chart area alignment type, which defines the elements to be used between the charts.

3.AlignWithChartArea: The name of the drawing area to which the reference is aligned.

4.InnerPlotPosition: The Position property of the chart within the plot area.

A.auto: Whether to align automatically.

B.height: Height of the chart in the plot area (percentage, value at 0-100)

C.width: Width of the chart in the plot area (percentage, value at 0-100)

D.x,y: The chart is in the upper-left corner of the plot area coordinates

5.Position: Plot Area Position property, option as Innerplotposition.

6.Name: Plot area name.

7.Axes: Axis Collection-a very important part that can be set by x axis (x axis), Y axis (Y axis), second x axis (Secnondaryx axis) and second Y axis (secnondary y axis), commonly used properties include:

A.arrowstyle set axes with arrows

B.interval: Axis scale interval size

C.intervaloffset: Axis scale offset size

D.lablestyle set the text size of the axis, etc.

E.majorgrid: Main Auxiliary line

F.majortickmark: Major tick marks

G.minortickmark: Minor tick marks

H.minorgrid: Secondary Guides

I.title: Axis Title

J.titlealignment: Axis Title Alignment

Second, data series

Series: The most important attribute, the collection of charts, is the final view of the pie chart, histogram, line chart, point graph and other components of the composition; You can place multiple compatible types within a drawing area to form a composite diagram.

1.ChartArea: The name of the drawing area to which the chart belongs

2.ChartType: Chart type (column, pie, line, dot, etc.)

3.IsValueShownAsLabel: Whether to display data point labels, if true, to display each data value in the chart

4.Label: Data point label text

5.LabelFormat: Data point label text format

6.LabelAngle: Label Font angle

7.Legend: legend name used by current data series (chart)

8.Name: Name of the data series

9.Palette: Data series (chart) appearance definition

. Points: A collection of data points that form the point of a data series

11.XValueMember: The data source bound by the horizontal axis

12.XValueType: Horizontal axis type

13.YValueMembers: Data source with ordinate bindings

14.YValueType: Ordinate axis type

Three , legend legends

The legend for MSChart is not displayed by default, but can be set as follows:

1.Alignment: Alignment

2.AutoFitMinFontSize: The smallest font displayed when Istextautofit is True

3.BackColor: Background color, when the drawing area itself has a background, set it to transparent effect better.

4.enabled: Whether the legend is displayed

5.IsTextAutoFit: Text size automatically adjusts to the size of the legend area

6.Position: Where the legend appears

You can see that a chart can draw multiple ChartArea, and each ChartArea can draw multiple series. ChartArea is the drawing area, you can have multiple ChartArea superimposed together, series is painted on the Chartaarea, series English means "sequence, continuous", in fact, is the data line, it can be curve, point, column, bar, pie chart ... Note that the chart can be used to select the viewing area with the mouse when the data is very high, and further drag the horizontal vertical scroll bar to reduce the graph view.

First, the data source:

The way data is returned is Dataset.tables[0], a DataTable, and the most basic way to source data. Here we introduce only the DataTable binding data source, which is simple:

Chartdata.datasource = DT;

Chartdata.databind ();

Second, Series:

Series is drawn on the ChartArea line, point, column, bar, pie chart, simply say is the data drawn above, directly say the property,

1. "Tag": is the point of a data point, a data value. As shown in the following:

3. "Font": Fonts and styles on data labels

Font Label Fonts settings

Font.unit personal Settings This value for document, I realized

Labelangle the angle of the label, oblique how many degrees, it is recommended that the

Labelbackcolor Label Background color

Labelbordercolor Label Border Color

Labelborderdahstyle label Border Style

Labelborderwidth Label Border Width

Labelforecolor Label Font Color

Other properties Try it yourself

4, Blank point (Emptypointstyle): is continuous data, such as the x-axis corresponding to the y-axis no data, or the y-axis corresponding to the x-axis no data, such data points can be set corresponding properties;

5. Data Source: Note This is the data source for series (Xvaluemember, Yvaluemembers)

Attention:
First, these two properties correspond to the two columns of the DataTable, that is, the normal x-axis corresponding time, the y-axis corresponds to the data value, but also pay attention to the value of each data unit of the DataTable, especially DBNull or empty. The Newdatetime column data type of my database here is a datetime type, and Newfyj is a double type.

Second, there is a difference between the data source of the series and the data source of the chart control, only the DataTable is bound to the chart,series before the column, otherwise it cannot correspond.

6. Chart (ChartArea): that is, serie painting on which ChartArea, ChartType is the chart type of Serie, that is, what kind of diagram, graph, line, point, histogram, pie chart, etc...

7. Legend (Legend): that is, the name and style of each serie, as long as the creation of Serie will automatically generate load in the Legend, the properties can be tested, if you want to adjust the location of Legend, you can go to Legend set, relatively simple , there's not much to say

8. Mapping Area (TOOTIP): Mouse on the data points appear on the small hint, the proposed code control;

9. Miscellaneous: Emptypointvalue: The value of an empty data point is done on average or 0 processing

LabelStyle: Hard-to-label rules show where the data points are located

10. Axis : That is the x-axis and y-axis, the x-axis has a spindle and a secondary axis, the y-axis also has a spindle and a secondary axis, the spindle is primary, the secondary axis is secondary. The x spindle is below, the Y spindle is on the right, the X sub-axis is above, and the y-axis is on the right.

Third, Chartareas:

Most important in the chart control, each serie is drawn on the ChartArea, and the chart control can be displayed with multiple ChartArea superimposed. For example, the first chartarea to draw the curve, the second picture of the histogram or something else, which is said above the Serie ChartType, we can also draw multiple serie on a chartarea, but if there is a column data unit range in 500~ Data floating between 10000 is the largest, there is a column of data unit range between 0.1~2.0, there is a column of data unit range between 50~100, the painting on the same chartarea display, 0.1 to 2.0 of the data will become a straight line. When there are only 1 or 2 such data, you can set the spindle and the sub-axis in the Serie, but when there are multiple data, multiple types of display, you need multiple ChartArea to solve.

1. Alignment: ChartArea alignment;

Alignmentorientation horizontal alignment, vertical alignment, all alignment

Alignmentstyle which way to align Alignmentwithchartarea and which alignment

2. Three-dimensional (Area3dstyle): Try yourself, the effect is very heavy, not very good;

3. Appearance: can set the color, border and position of ChartArea;

Attention:

First, innerplotposition and position one is big, one is the internal drawing, try to understand, here is the most important is a number of ChartArea overlap together, two position must be set the same, otherwise overlap.

Second, when multiple chartarea overlap together, the color or picture can only be set at the bottom of the ChartArea, the above ChartArea are set to transparent, the bottom chartarea is chartareas[0], so do not set the wrong.

4. Cursors: Cursorx and cursory, is the horizontal and vertical scroll bar, first of all, as long as you want to select a region to see the curve, you must enable the cursor, the cursor settings can only be superimposed on the top of the ChartArea settings, that is chartarea[ Chartarea.count-1],x axis and y-axis can have a cursor, you can drag, you can notice that there is a button above a circle, that is, backward, sliding the user selection of the area, release the mouse will become the area of the graph;

5. Shaft axes!! : Very important, a CHARTAREA has 4 axes: spindle x axis, spindle y (value) axis, secondary axis x axis, secondary axis y (value) axis, each axis property is the same; properties: Label, Interval (Interval), title, Data View (scaleview), Slide bar (ScrollBar), appearance, network tick marks, etc.;

Note: Scaleview is a Data view, which is currently drawn out of a chart area, if you use the mouse to select an area to expand the display, the new expansion is a scaleview, just think of it as the current display of the view is good to understand. ScrollBar is the cursor, before we say the Chartarea.cursorx or Y is also a cursor, where the scrollbar is a scrollbar, look closely at the properties of the two are not difficult to find, one is the selection area, one is to drag scroll bar to see all the data.

Summary of application of MSChart under C #

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.