Implementation of modular dynamic dashes

Source: Internet
Author: User

Implementation of modular dynamic dashes

Application Software: VC ++ 6.0.

Source code: http://download.csdn.net/detail/wojiushiwo987/5200730

Question: there is no way to describe the trend of data by storing the points and tracing them. That is, the CPU usage in the task manager is the same, and the usage trend is clearly displayed. Now there is a change trend in the start time in the 360 management software. Other features of similar dashboard software are very intuitive!

 

For project requirements, we also need a similar dash trend statistics module to collect statistics, for example, the time changes with the increase of the count.

Here, to simplify and include the required functions. Modular testing.

Step 1): You need to know the number of horizontal and vertical axes. What is the relationship between the horizontal and vertical axes?

For the sake of simplicity, the X axis is set to the number of times. You can use a timer to count + 1 at a given interval. The vertical axis represents a random value. The relationship between the horizontal axis and the vertical axis is that one number of times corresponds to one vertical axis point value.

Step 2): design a function to generate non-repeated random numbers and store random values in an array of a given size.

Step 3): Set the dash area. To ensure that the dash can be connected together, you need to re-paint the area, that is, you need to write the function in onpaint. Graphtest is the drawing area we set.

 

Step 4): For the sake of intuition, in order to ensure the intuition of the drawing, the X and Y axes must be selected. The coordinates of the graphtest client region are left (top) and right (right, bottom ). Note that a small part of the reserved area is used to write the ruler value.

Step 5): Set the ruler. We mainly need to design the number of horizontal and vertical axis points under the length just set. For example, we need the following 6 points: 0, 10, 20, 30, 40, 50, but 6 points can be separated by only five equal segments. This requires extreme caution in programming. It is not easy to cause the segment to be too large or too small, and not easy to draw points.

 

Step 6): design the timer and set the time interval. the random values change at each specified time interval. You can verify the correctness of the random values that are not repeated in the following way. (You can run 10 points first to verify the correctness of the program ). Prepare for the subsequent drawing and dashes!

 

Step 7): draw a line. In this case, you need to consider re-painting. You need to know the number of times of the horizontal axis and the size of the vertical axis value. More importantly, to ensure the correctness of the points, you need to know the size of the horizontal or vertical small scale of a point, and pay attention to the boundary. A loop ensures that the previous vertex and the next vertex are connected to all vertices. Coupled with the timer function, we can make sure to draw a dynamic line diagram, as shown in.



 

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.