In-depth introduction to CChart one lesson per day-11th class hierarchical view, girls in class 7 upstairs

Source: Internet
Author: User

In mature commercial software such as Origin, the layering function is essential for Drawing Images with multiple scales.

CChart currently contains two types of views with hierarchical functions. A hierarchical view is called. All layers in this view share the drawing area, and each layer draws its own axis. The other is shared X-axis view. All layers of this view share the X-axis except the drawing area. Each layer draws its own Y-axis separately.

This section describes the hierarchical view.

Create a VC6 project named Lesson11 in the way of the first lesson. For the WM_CREATE response routine, enter the following.

Case WM_CREATE: chartWnd. attach (hWnd, kTypeLayered); chartWnd. getChart ()-> ResizePlots (2); double pX [200], pY [200]; int I; for (I = 0; I <200; I ++) {pX [I] = I + 1; pY [I] = (I + 1) * (I + 1);} chartWnd. getChart ()-> AddCurve (pX, pY, 200, 0); for (I = 0; I <200; I ++) {pX [I] = (I + 1) * 10; pY [I] = sin (I * 2.0*3.1415926536/200.0);} chartWnd. getChart ()-> AddCurve (pX, pY, 200, 1); chartWnd. getChart ()-> SetTitle (_ T ("layer 1"), 0); chartWnd. getChart ()-> SetTitle (_ T ("Layer 2"), 1); break;

The hierarchical view code is kTypeLayered.

The ResizePlots function also appears in the previous lesson. In this lesson, the ResizePlots function is defined:

voidResizePlots(int nLayers); 


This function is very easy to understand. Its Parameter nLayers indicates the number of layers.

The above code sets two layers.

Because the sine function of the math library is used earlier, add a reference to the header file of Lesson11.cpp.

#include <math.h> 


Run the program.

650) this. width = 650; "src =" http://img.blog.csdn.net/20130918225713968? Watermark/2/text/plain =/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA =/dissolve/70/gravity/SouthEast "alt =" SouthEast "/>

We can see that the two curves with very different scales are drawn to the same graph.

Note that the current clumsy way to differentiate different layers is color. All elements of the same layer, including titles, curves, and axes, are in the same color.

You can use the mouse to test the interaction function of the hierarchical view.

Related Article

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.