Self-network implementation of Dual-scale charts in owc)

Source: Internet
Author: User

The line-column chart must be generated. This type does not exist in the chartcharttypeenum Enumeration type of owc. This is dumb, and I feel that I have no way to start. Keep trying, keep searching for information, ah, the consequences of the commitment are really serious, tossing for nearly four hours. At last, it was a bit eye-catching. If you do not specify a type for the entire chart object, you can specify a type for the Series object in the table. First, you can use a series object to draw a bar chart and then add a series object. The specified type is linear. Solve the problem.CodeAs follows:

Using Microsoft. Office. InterOP;
Using owc = Microsoft. Office. InterOP. owc11;
Public partial class default212: system. Web. UI. Page
{
Protected void page_load (Object sender, eventargs E)
{
// Create a chartspace object to place charts
Owc. chartspace objcspace = new owc. chartspaceclass ();

// Whether the legend is displayed
Objcspace. haschartspacelegend = true;

// Add a chart to the chartspace object. The add method returns the chart object.
Owc. chchart objchart = objcspace. charts. Add (0 );

// Specify the chart as a column chart

// Specify the title
Objchart. hastitle = true;
Objchart. Title. Caption = "first-half-year distribution chart ";

// Graph description of X and Y axes
Objchart. Axes [0]. hastitle = true;
Objchart. Axes [0]. Title. Caption = "Y: quantity ";
Objchart. Axes [1]. hastitle = true;
Objchart. Axes [1]. Title. Caption = "X: Month ";

// calculate data
/* categories and values can be represented by a tab string */
string strseriesname = "My tests ";
string strseriesname1 = "Lar ";
string strcategory = "1" + '\ t' + "2" +' \ t' + "3" + '\ t' + "4" +' \ t '+ "5" +' \ t' + "6" + '\ T ';
string strvalue = "9" + '\ t' + "8" +' \ t' + "4" + '\ t' + "10" +' \ t '+ "12" +' \ t' + "6" + '\ T ';
string strvalue1 = "0.038%" + '\ t' + ". 034% "+ '\ t' + ". 039% "+ '\ t' + ". 036% "+ '\ t' + ". 040% "+ '\ t' + ". 033% "+ '\ T';

/* Column chart */
// Add a series
Objchart. seriescollection. Add (0 );
Objchart. seriescollection [0]. type = owc. chartcharttypeenum. chcharttypecolumnclustered;
// Specify the name of a series.
Objchart. seriescollection [0]. setdata (owc. chartdimensionsenum. chdimseriesnames,
+ (INT) owc. chartspecialperformancesenum. chdataliteral, strseriesname );

// Specify a category
Objchart. seriescollection [0]. setdata (owc. chartdimensionsenum. chdimcategories,
+ (INT) owc. chartspecialperformancesenum. chdataliteral, strcategory );

// Specify the value of objchart [0]
Owc. chseries sdispdppm = objchart. seriescollection [0];
Sdispdppm. setdata
(Owc. chartdimensionsenum. chdimvalues,
(INT) owc. chartspecialperformancesenum. chdataliteral, strvalue );

/* Line chart */
// Add another series

Owc. chseries sdisplar = objchart. seriescollection. Add (0 );
Sdisplar. ungroup (true );
Owc. chaxis myaxis = objchart. Axes. Add (sdisplar. get_scalings (Microsoft. Office. InterOP. owc11.chartdimensionsenum. chdimvalues ));
Myaxis. Position = owc. chartaxispositionenum. chaxispositionright;
Myaxis. hasminorgridlines = false;
Myaxis. numberformat = "0.00% ";
Myaxis. hastitle = true;
Myaxis. Title. Caption = "rejection rate (% )";
// Specify the name of a series.
Sdisplar. setdata (owc. chartdimensionsenum. chdimseriesnames,
+ (INT) owc. chartspecialperformancesenum. chdataliteral, strseriesname1 );

// Specify the value of objchart [1]
Sdisplar. setdata
(Owc. chartdimensionsenum. chdimvalues,
(INT) owc. chartspecialperformancesenum. chdataliteral, strvalue1 );

// Ungroup Series
Sdisplar. type = owc. chartcharttypeenum. chcharttypelinemarkers;

// Output as a GIF file.
String strabsolutepath = (server. mappath (".") + "\ temp \ test.gif ";
Objcspace. exportpicture (strabsolutepath, "animated GIF", 600,350 );

// Create the relative path of the GIF file.
String strrelativepath = "./temp/test.gif ";

// Display the image
Image1.imageurl = strrelativepath. tostring ();

}
}

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.