Introduction:
The real-time curve component displays collected data based on curves and can be used in industrial real-time detection and other related fields.
This component supports simultaneous display of multiple curves;
It also supports display and processing of later data;
The multi-chart comparison function is also provided.
The most important thing is to support the zoom display function, which allows you to infinitely zoom in the desired position for viewing.
Development Environment: Visual Studio. NET 2005
Relationship diagram:
Custom Attributes:
Attribute name |
Type |
Description |
Allowzoom |
Bool |
Whether scaling is allowed |
Axisnamex |
String |
X axis title |
Axisnamey |
String |
Y axis title |
Axiscolor |
Color |
Coordinate dial color |
Dataseries |
Collection |
A set of curve data and a set of the plotinfomation class. |
Maginleft |
Int |
Size of the left boundary |
Magintop |
Int |
Upper Boundary size |
Maginright |
Int |
Size of the right boundary |
Maginbuttom |
Int |
Bottom Boundary size |
Offsetx |
Int |
The relative offset of each curve on the X axis when multiple curves are displayed. |
Offsety |
Int |
The relative offset of each curve on the Y axis when multiple curves are displayed. |
The attributes of plotinfomation are as follows:
Attribute name |
Type |
Description |
Linecolor |
Color |
Curve color |
Linewidth |
Int |
Curve width |
Datapoints |
List <float> |
Curve data point |
Linedashstyle |
Dashstyle |
Curve Line |
Name |
String |
Curve name |
Pointcountperminute |
Int |
Number of data points per minute |
Visible |
Bool |
Visible or not |
Method:
Method Name |
Description |
Virtual void savedatapoint (binarywriter BW) |
Store curve data in binary format |
Virtual void savedatapoint (streamwriter tw) |
Save curve data in text |
Virtual void loaddatapoint (binaryreader BW) |
Reading curve data from binary files |
Virtual void loaddatapoint (streamreader tw) |
Reading curve data from text files |
Void saveimage (string filename) |
Save the current image to a specified bitmap file |
Virtual void saveimage (Graphics g) |
Save the current image to a specified graphics object |
Void updaterootrect (float X, float y, float width, float height) |
Set the coordinate range of the bottom layer of the image. The horizontal direction is time, and the Unit is minute. The vertical direction is numeric, and a negative value is supported. |
Example:
- Using
System;
- Using
System. Collections. Generic;
- Using
System. componentmodel;
- Using
System. Data;
- Using
System. drawing;
- Using
System. text;
- Using
System. Windows. forms;
- Using
System. IO;
- Namespace
System. shangfei. Drawing. Plot
- {
/// <Summary>
///
/// </Summary>
Public
Partial
Class
Form1: Form
- {
/// <Summary>
///
/// </Summary>
Public
Form1 ()
- {
- Initializecomponent ();
- RND =
New
Random ();
- Propertygrid1.selectedobject = plotex1;
- }
Private
Void
Toolstripbutton2_click (
Object
Sender, eventargs E)
- {
This
. Plotex1.dataseries. Clear ();
This
. Plotex1.updaterootrect (0, 0, 20,100 0 );
- Plotinfomation Pi =
New
Plotinfomation ();
- Pi. Name =
"Curve 1"
;
- Pi. linecolor = color. Red;
- Pi. pointcountperminute = 30;
- Pi. datapoints =
New
List <
Float
> ();
This
. Plotex1.dataseries. Add (PI );
- Plotinfomation Pi2 =
New
Plotinfomation ();
- Pi2.name =
"Curve 2"
;
- Pi2.linedashstyle = system. Drawing. drawing2d. dashstyle. dashdotdot;
- Pi2.linecolor = color. Green;
- Pi2.pointcountperminute = 50;
- Pi2.datapoints =
New
List <
Float
> ();
This
. Plotex1.dataseries. Add (Pi2 );
- Timer1.enabled =
True
;
- }
Private
Random RND =
Null
;
Private
Float
Oldvalue = 100;
Private
Void
Timereffectick (
Object
Sender, eventargs E)
- {
Float
F = oldvalue + (
Float
) RND. nextdouble () * 4-2;
If
(F <0)
- F = 0;
If
(F> 1000)
- F = 1000;
This
. Plotex1.dataseries [0]. datapoints. Add (f );
This
. Plotex1.dataseries [1]. datapoints. Add (F + RND. Next (10)-5 );
- Oldvalue = F;
This
. Plotex1.invalidate ();
- }
Private
Void
Toolstripbutton#click (
Object
Sender, eventargs E)
- {
- Timer1.enabled =
False
;
- }
Private
Void
Toolstripbutton4_click (
Object
Sender, eventargs E)
- {
- Savefiledialog SFD =
New
Savefiledialog ();
- SFD. Filter =
"Text data | *. txt"
;
If
(SFD. showdialog () = dialogresult. OK)
- {
- Streamwriter Sw = file. createtext (SFD. filename );
This
. Plotex1.savedatapoint (SW );
- Sw. Close ();
- }
- SFD. Dispose ();
- }
Private
Void
Toolstripbutton3_click (
Object
Sender, eventargs E)
- {
- Openfiledialog ofd =
New
Openfiledialog ();
- Ofd. Filter =
"Text data | *. txt"
;
If
(OFD. showdialog () = dialogresult. OK)
- {
- Streamreader sr = file. opentext (OFD. filename );
This
. Plotex1.loaddatapoint (SR );
- Sr. Close ();
// Set the range based on the data.
This
. Plotex1.updaterootrect (0, 0, 20,100 0 );
- }
- Ofd. Dispose ();
- }
Private
Void
Toolstripbutton5_click (
Object
Sender, eventargs E)
- {
- Savefiledialog ofd =
New
Savefiledialog ();
- Ofd. Filter =
"Graphic file | *. BMP"
;
If
(OFD. showdialog () = dialogresult. OK)
- {
This
. Plotex1.saveimage (OFD. filename );
- }
- Ofd. Dispose ();
- }
- }
- }
:
In the graphic area, you can zoom in a selected area and double-click the selected area to roll back to the previous one. You can zoom in infinitely:
How to Get: http://item.taobao.com/item.htm? Id = 4546003182