Real-time curve component 2.0

Source: Internet
Author: User

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:

  1. Using
    System;
  2. Using
    System. Collections. Generic;
  3. Using
    System. componentmodel;
  4. Using
    System. Data;
  5. Using
    System. drawing;
  6. Using
    System. text;
  7. Using
    System. Windows. forms;
  8. Using
    System. IO;
  9. Namespace
    System. shangfei. Drawing. Plot
  10. {

  11. /// <Summary>

  12. ///

  13. /// </Summary>

  14. Public
    Partial
    Class
    Form1: Form
  15. {

  16. /// <Summary>

  17. ///

  18. /// </Summary>

  19. Public
    Form1 ()
  20. {
  21. Initializecomponent ();
  22. RND =
    New
    Random ();
  23. Propertygrid1.selectedobject = plotex1;
  24. }

  25. Private
     
    Void
    Toolstripbutton2_click (
    Object
    Sender, eventargs E)
  26. {

  27. This
    . Plotex1.dataseries. Clear ();

  28. This
    . Plotex1.updaterootrect (0, 0, 20,100 0 );
  29. Plotinfomation Pi =
    New
    Plotinfomation ();
  30. Pi. Name =
    "Curve 1"
    ;
  31. Pi. linecolor = color. Red;
  32. Pi. pointcountperminute = 30;
  33. Pi. datapoints =
    New
    List <
    Float
    > ();

  34. This
    . Plotex1.dataseries. Add (PI );
  35. Plotinfomation Pi2 =
    New
    Plotinfomation ();
  36. Pi2.name =
    "Curve 2"
    ;
  37. Pi2.linedashstyle = system. Drawing. drawing2d. dashstyle. dashdotdot;
  38. Pi2.linecolor = color. Green;
  39. Pi2.pointcountperminute = 50;
  40. Pi2.datapoints =
    New
    List <
    Float
    > ();

  41. This
    . Plotex1.dataseries. Add (Pi2 );
  42. Timer1.enabled =
    True
    ;
  43. }

  44. Private
    Random RND =
    Null
    ;

  45. Private
     
    Float
    Oldvalue = 100;

  46. Private
     
    Void
    Timereffectick (
    Object
    Sender, eventargs E)
  47. {

  48. Float
    F = oldvalue + (
    Float
    ) RND. nextdouble () * 4-2;

  49. If
    (F <0)
  50. F = 0;

  51. If
    (F> 1000)
  52. F = 1000;

  53. This
    . Plotex1.dataseries [0]. datapoints. Add (f );

  54. This
    . Plotex1.dataseries [1]. datapoints. Add (F + RND. Next (10)-5 );
  55. Oldvalue = F;

  56. This
    . Plotex1.invalidate ();
  57. }

  58. Private
     
    Void
    Toolstripbutton#click (
    Object
    Sender, eventargs E)
  59. {
  60. Timer1.enabled =
    False
    ;
  61. }

  62. Private
     
    Void
    Toolstripbutton4_click (
    Object
    Sender, eventargs E)
  63. {
  64. Savefiledialog SFD =
    New
    Savefiledialog ();
  65. SFD. Filter =
    "Text data | *. txt"
    ;

  66. If
    (SFD. showdialog () = dialogresult. OK)
  67. {
  68. Streamwriter Sw = file. createtext (SFD. filename );

  69. This
    . Plotex1.savedatapoint (SW );
  70. Sw. Close ();
  71. }
  72. SFD. Dispose ();
  73. }

  74. Private
     
    Void
    Toolstripbutton3_click (
    Object
    Sender, eventargs E)
  75. {
  76. Openfiledialog ofd =
    New
    Openfiledialog ();
  77. Ofd. Filter =
    "Text data | *. txt"
    ;

  78. If
    (OFD. showdialog () = dialogresult. OK)
  79. {
  80. Streamreader sr = file. opentext (OFD. filename );

  81. This
    . Plotex1.loaddatapoint (SR );
  82. Sr. Close ();

  83. // Set the range based on the data.

  84. This
    . Plotex1.updaterootrect (0, 0, 20,100 0 );
  85. }
  86. Ofd. Dispose ();
  87. }

  88. Private
     
    Void
    Toolstripbutton5_click (
    Object
    Sender, eventargs E)
  89. {
  90. Savefiledialog ofd =
    New
    Savefiledialog ();
  91. Ofd. Filter =
    "Graphic file | *. BMP"
    ;

  92. If
    (OFD. showdialog () = dialogresult. OK)
  93. {

  94. This
    . Plotex1.saveimage (OFD. filename );
  95. }
  96. Ofd. Dispose ();
  97. }
  98. }
  99. }

:

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


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.