Use Microsoft owc11 to draw charts

Source: Internet
Author: User
The project module in the project needs to use charts to display data, and then selects "owc11", the effect is as follows:

Void toprint (string categorystr, string [] valuearr, string [] titlearr, string [] colorarr)
{
// Create a new drawing Space
Chartspace objcspace = new chartspace ();

// Create a new chart in the drawing Space
Chchart objchart = objcspace. charts. Add (0 );
// Objchart. type = chartcharttypeenum. chcharttypecolumnclustered3d; // specify the chart type as a 3D column.
Objchart. type = chartcharttypeenum. chcharttypecolumnclustered; // planar Column
Objchart. haslegend = true; // specifies whether a legend is required for a chart.

// Title
Objchart. hastitle = true;
Objchart. Title. Caption = "annual water consumption statistics ";
Objchart. Title. Font. size = 9;
Objchart. Title. Font. Name = "";
Objchart. Title. Font. Bold = true;

Objchart. plotarea. Interior. color = "# c0c0c0"; // background color of the drawing Area
Objchart. plotarea. Floor. Interior. color = "#888888"; // background color of the drawing Area

Objchart. Legend. Font. size = 9; // font of the legend

// Graphical properties of the X and Y axes
// Objchart. Axes [0]. hastitle = true;
// Objchart. Axes [0]. Title. Caption = "X: Month ";
// Objchart. Axes [0]. Title. Font. size = 9;
// Objchart. Axes [1]. hastitle = true;
// Objchart. Axes [1]. Title. Caption = "Y: volume ";
// Objchart. Axes [1]. Title. Font. size = 9;

For (INT I = 0; I <valuearr. length; I ++)
{
// Add a data series to the chart
Chseries objseries = objchart. seriescollection. Add (I );
Objseries. setdata (chartdimensionsenum. chdimseriesnames, chartspecialperformancesenum. chdataliteral. gethashcode (), titlearr );
Objseries. setdata (chartdimensionsenum. chdimcategories, chartspecialperformancesenum. chdataliteral. gethashcode (), categorystr );
Objseries. setdata (chartdimensionsenum. chdimvalues, chartspecialperformancesenum. chdataliteral. gethashcode (), valuearr );
Objseries. Interior. Color = colorarr; // color inside the column
Objseries. gapwidth = 300; // Gap Between Columns

Chdatalabels objdatalabels = objchart. seriescollection. datalabelscollection. Add ();
Objdatalabels. hasvalue = false; // whether the number on the column is displayed
Objdatalabels. Font. color = "black"; // the number on the column is black.
}

Object objpic = objcspace. getpicture ("animated GIF", 700,300 );

Response. Buffer = true;
Response. contenttype = "image/GIF ";
Response. binarywrite (byte []) objpic );
Response. End ();
}

Call:

String [] categoryarr = new string [] {"January", "January ", "March "};
String categorystr = string. Join ("\ t", categoryarr );

String [] valuearr1 = new string [] {"3832", "3167", "3575", "3816", "2651", "3494 "};
String [] valuearr2 = new string [] {"17627.2", "14568.2", "12194.6", "16445", "17553.6", "16072.4 "};
String [] valuearr3 = new string [] {"5748", "4750.5", "3976.5", "5362.5", "5724", "5241 "};
String [] valuearr4 = new string [] {"23375.2", "19318.7", "16171.1", "21807.5", "23277.6", "21313.4 "};
String valuestr1 = string. Join ("\ t", valuearr1 );
String valuestr2 = string. Join ("\ t", valuearr2 );
String valuestr3 = string. Join ("\ t", valuearr3 );
String valuestr4 = string. Join ("\ t", valuearr4 );
String [] valuearr = new string [] {valuestr1, valuestr2, valuestr3, valuestr4 };

String [] titlearr = new string [] {"Consumption m3", "Water Fee (RMB)", "sewage fee (RMB)", "Total (RMB )"};

String [] colorarr = new string [] {"# 9999ff", "#993366", "# ffffcc", "# ccffff "};

toprint (categorystr, valuearr, titlearr, colorarr);
from:
Software customer Forum →. NET technology → use Microsoft's owc11 to draw charts

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.