Chartdirector Application Notes (can provide graphs for both Web and QT MFC)

Source: Internet
Author: User

Chartdirector Introduction

Chartdirector is a small and sophisticated business chart library. It is available in a wide range of languages, including. Net, Java, ASP, VB, PHP, Python, Ruby, C + +, etc. Chartdirector provides charting support for Web applications and provides a good charting experience for desktop applications. In addition, Chartdirector can seamlessly integrate with MFC, QT and other interface frameworks. This, you can get a glimpse of one or two in the official Help documentation. In this series of articles, you will also use the QT application framework as a basis for writing application examples of various charts.

As mentioned above, Chartdirector is a commercial chart library. When used without official authorization, a yellow identifier appears in the chart. As an independent individual developer, it is clear that you cannot and do not have to purchase a certificate of use for the library. Online crack Way is also more, basically is the official accompanying DLL file to crack cover can.

Chartdirector class level

There are three categories of inheritance structures in the Chartdirector library that are more commonly used, and the following three categories of inheritance structures are drawn:

The chart class inheritance hierarchy is a summary of the functionality of the entire Chartdirector library. As can be seen, the Chartdirector class library can draw seven kinds of charts: MultiChart, Polarchart, Threedchart, Basemeter, Piechart, XYChart, Pyramidchart. Among them, the financial class chart Financechart inherits from the MultiChart. Financial charts often contain various parameters and indicators, so using MultiChart as a base class inheritance is also a matter of reason. The Threedchart class derives two sub-classes: Surfacechart and Threedscatterchart. These two sub-classes are used to draw 3D charts, 3D charts are often used for three-dimensional performance data differences, drawing out the chart has a strong stereoscopic visual effect. The Basemeter class represents the instrument base class, and derived subclasses include: Angularmeter and Linearmeter classes. As the class name shows, the gauges drawn by Angularmeter often have radians, while the Linearmeter class is a linear drawing instrument, usually with a horizontal or vertical appearance.

The Xychart class is a large class in the Chartdirector class library, and all charts that contain x and Y coordinates belong to Xychart. Therefore, the layer class for the Xychart class also derives a rich subclass for implementing different types of XY charts. What is the specific role of the layer class? Because the Chartdirector design architecture is not elaborated on official documents, it is only possible to speculate on the function of layer. My understanding is that layers are a layer of the general sense, and if you need to draw multiple XY charts on the same artboard, you need to combine different layer classes. Different layers can be combined to achieve complex functions. In general, when drawing a chart, you need to add different layer derived classes based on different chart types.

The following is the layer class inheritance hierarchy for the Polar/radar class:

As you can see, the layer classes of the Polarchart class are relatively small and the styles relatively fixed. Polarlinelayer, Polararealayer, and polarvectorlayer three classes are derived from the Polarlayer class as the base class.

The whole Chartdirector class library is basically made up of these classes. Of course, it also includes array, Axis, Box, Sector class helper classes. From this perspective, the Chartdirector class library is still light enough, learning to use is also relatively simple. Unfortunately, the accompanying documentation does not cover too many architectural instructions. Therefore, there are some difficulties in fully understanding the design concept of Chartdirector library.

Important Concepts

It is necessary to understand some concepts in order to use Chartdirector class library skillfully. Here are some of my summary and understanding:

    • The chart object. The chart object is the basis of the drawing and can be an object of any of the classes in the hierarchy of the above chart class inheritance. Each drawn chart belongs to a particular chart class. Like the simple Bar Chart in the Help document, this is an example of an Xychart application, and the resulting Chart object is an instance of the Xychart class. In summary, you need to instantiate a chart object before you can draw each chart.
    • Layer class. The layer class is mentioned slightly above, which I interpret as layers in image processing. Layers can be stacked together to draw more complex diagrams. It is important to note that different chart components require the corresponding layer class to be implemented. In the Xychart class, many of the add* functions are implemented to add layers to a chart object. such as Addlinelayer, Addbarlayer, Addboxlayer and so on.
    • PlotArea. The PlotArea class represents the drawing area in an XY chart. In the process of drawing an XY chart, setting PlotArea is the first thing to do after the chart object instantiation is complete. PlotArea uses the pixel coordinate system, which means: (0,0) is located in the upper left of the drawing area, the X axis increases to the right, and the Y axis increases downward. For other kinds of charts, the concept of PlotArea does not exist.
    • Drawarea. The Drawarea class is at the bottom of the drawing and is an important basis for the whole class library drawing. All chart classes in the Chartdirector class library maintain an Drawarea object internally, which is used to provide a drawing primitive, such as drawing lines, shapes, text, and so on. Users can also customize drawing options by getting Drawarea objects.
    • Qchartviewer. Qchartviewer is the intermediate class used to integrate the Chartdirector class library into the QT framework. This class inherits from the Qlabel and Viewportmanager classes and is used to represent the chart drawing results, handling mouse, keyboard interaction events, and so on. In the Chartdirector class library, the Qchartviewer class is included as source code. Users can see how they are implemented, or they can be directly included in the QT project for use.
Drawing steps

Take the simple bar chart as an example:

    1. Generate Chart object: xychart* c = new XYChart (250, 250);
    2. Set drawing area (optional): C->setplotarea (30, 20, 200, 200);
    3. Add layer (optional): C->addbarlayer (...);
    4. Set coordinate parameters: C->xaxis ()->setlabels (...); C->yaxis ()->setlabels (...);

The next article describes the use of the simple Bar chart.

Http://www.cnblogs.com/csuftzzk/p/3496695.html

Using Chartdirector in QT, configure the project properties and copy the corresponding library files to the project directory. The following is a drawing code-based analysis:

 1//y Axis Data 2 const double data[] = {450, 560, 630, 800, 1100, 1350, 1600, 1950, 2300, 2700}; 3//x Axis Mark 4 const char* lbs[] = {"1996", "1997", "1998", "1999", "2000", "2001", "2002", "2003", "2004", "2005"}; 5//Add a caption to the chart, which is drawn outside the PlotArea area. When specifying text content, we also need to specify the text font, as well as the font size. 6//Under the C:\WINDOWS\Fonts of WINDOWS XP system, you can view the font library with the system. 7 C->addtitle (Msg.mainTitle.c_str (), "Timesbi.ttf", 18); 8//Set PlotArea area, Setplotarea () function with more parameters, here we can set the size of the PlotArea area and the position in the chart canvas. 9//Front four parameters sets the position and size of the PlotArea area in the Xychart drawing coordinates, and the last two parameters specify the color of the horizontal, vertical grid lines. The Lineargradientcolor () Xychart () can be used to set the gradient of the PlotArea area, the first four parameters specify the ramp area, and the subsequent two color values specify a 11//color gradient range.       C->setplotarea (+, 340, 250,13 C->lineargradientcolor (14, 290, Msg.bgcolor, 0x000000) -1,15 0xffffff, msg.gridcolor,17 msg.gridcolor) 18//Add a layer barlayer. In this layer, we use Intarray (0, 0) to specify the color value of the bars. In other words, we do not specify the bar color. 19//In this case, Chartdirector automatically fills the bars by selecting a color from the default palette. 20//Here we call setBorderColor () to set the soft lighting effect. According to the different values: LeFT, right, light and shadow appear on different sides of the bars. C->addbarlayer (Doublearray (data, (int) (sizeof (data)/sizeof (Data[0])), and Intarray (0, 0))->setbordercolor ( Chart::transparent, Chart::softlighting (msg.lightdirection)); 23//Set X-axis mark (C->xaxis ()->setlabels ( Stringarray (lbs, (int) (sizeof (lbs)/sizeof (Lbs[0])))); 25//Set the x-axis marker displacement. C->xaxis ()->settickoffset (0.5); 27//Set X, y-axis caption Description of font and font size of C->xaxis ()->settitle (Msg.xTitle.c_str (), "Timesbi.ttf", 8); C->yaxis ()->settitle (Msg.yTitle.c_str (), "Timesbi.ttf", 8), 30//set X, Y axis width, here is 2 pixels wide. C->xaxis ()->setwidth (2), C->yaxis ()->setwidth (2);

Summary
    1. The chart plot area and PlotArea size are distinguished: The chart plot area is the size of the entire canvas, and all subsequent drawing operations are performed on this canvas, including data such as XY coordinate area, XY axis label, name, and so on. The chart area size is specified when the Xychart object is generated, and the PlotArea object has been mentioned earlier and is meaningful for xychart. In Xychart, the area represented by PlotArea is a rectangular region formed by the X, Y axis, excluding the X, y-axis markers, names, and chart headings. All layers are also covered with PlotArea.
    2. Chartdirector supported image file formats include PNG, JPG, JPEG, GIF, BMP, SVG, etc. Where the SVG format needs to be set by calling Basechart.enablevectoroutput before generating the chart file.

Http://www.cnblogs.com/csuftzzk/p/3504161.html

Chartdirector Application Notes (can provide graphs for both Web and QT MFC)

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.