An example of an OWC development

xiaoxiao2021-03-04  54

Recently developed a report generation system, which uses the .NET chart third-party control. The following is an example of using OWC9 to draw a BAR figure:

Public class chartclass {public chartclass () {}

public void GetChart (string category, string value1, string value2, string title, System.Web.HttpServerUtility Server, System.Web.UI.WebControls.PlaceHolder ChartHolder, string filename, string sdate, string edate, bool y) {OWC.ChartSpace objCSpace = new OWC.ChartSpaceClass (); OWC.WCChart objChart = objCSpace.Charts.Add (0); objChart.Type = OWC.ChartChartTypeEnum.chChartTypeBarStacked; // chart type objChart.HasLegend = true; objChart.HasTitle = true; if (y == true) objChart.title.caption = Title "The previous 12 months of advertising main cost (" sdate "to" edate ")"; else object.title.caption = title " Month advertising main cost (" SDATE " to " edate ") "; objchart.axes [0] .hastitle = false; objchart.axes [1] .hastitle = false; objchart.seriescollection.add (0); objChart.SeriesCollection [0] .SetData (OWC.ChartDimensionsEnum.chDimSeriesNames, (int) OWC.ChartSpecialDataSourcesEnum.chDataLiteral, "paper"); objChart.SeriesCollection [0] .SetData (OWC.ChartDimensionsEnum.chDimCategories, (int) OWC.ChartSpecialDat aSourcesEnum.chDataLiteral, category); objChart.SeriesCollection [0] .SetData (OWC.ChartDimensionsEnum.chDimValues, (int) OWC.ChartSpecialDataSourcesEnum.chDataLiteral, value1); objChart.SeriesCollection.Add (1); objChart.SeriesCollection [1]. SetData (OWC.ChartDimensionsEnum.chDimSeriesNames, (int) OWC.ChartSpecialDataSourcesEnum.chDataLiteral, "Journal"); objChart.SeriesCollection [1] .SetData (OWC.ChartDimensionsEnum.chDimCategories, (int) OWC.ChartSpecialDataSourcesEnum.chDataLiteral, category);

objChart.SeriesCollection [1] .SetData (OWC.ChartDimensionsEnum.chDimValues, (int) OWC.ChartSpecialDataSourcesEnum.chDataLiteral, value2); object ob = "# 66FF66"; objChart.SeriesCollection [0] .Interior.set_Color (ref ob); // Don't know why, in VB, I can use Interior.Color = "# 66ff66" to set the color, and the set_color method must be used in C #, and the parameters must be Ref Object. Objchart.seriescollection [0]. Border.set_color (ref ob); objChart.SeriesCollection [1] .inter.SeriesCollection [1] .Border.SeriesCollection [1] .Border.SET_COLOR (Ref obj ); objChart.SeriesCollection [0] .Border.set_Weight (OWC.LineWeightEnum.owcLineWeightThin); objChart.SeriesCollection [1] .Border.set_Weight (OWC.LineWeightEnum.owcLineWeightThin); ob = "# FFFFFF"; objChart.PlotArea.Border .SET_COLOR (Ref ob); objchart.plotarea.interior.set_color (ref ob);

Objchart.axes [0] .font.set_name ("arial"); objchart.axes [0] .font.set_size (9); objchart.axes [1] .majortickmarks = owc.chattickmarkenum.chtickmarkInside; Objchart.axes [1 ] .Minortickmarks = owc.chartTickMarkenum.chtickmarknone; objChart.axes [0] .majorgridlines.Line.set_color (ref ob);

Objchart.axes [1] .font.set_name ("Song"); Objchart.axes [1] .font.set_size (9);

// objChart.SeriesCollection [0] .DataLabelsCollection.Add (); // objChart.SeriesCollection [1] .DataLabelsCollection.Add (); // objChart.SeriesCollection [0] .DataLabelsCollection [0] .HasValue = true; // Ob = "red"; // objChart.seriesCollection [0] .datalabelscollection [0] .font.set_color (ref ob); // ObjChart.seriesCollection [1] .datalabelscollection [0] .Font.set_color (ref ob); // objChart.SeriesCollection [0] .DataLabelsCollection [0] .Position = OWC.ChartDataLabelPositionEnum.chLabelPositionOutsideBase; // objChart.SeriesCollection [1] .DataLabelsCollection [0] .Position = OWC.ChartDataLabelPositionEnum.chLabelPositionOutsideEnd; // NOTE above paragraphs The content is displayed, the setting code of displaying data values ​​on the data column

Objchart.Legend.font.set_name ("Song"); objChart.Legend.Font.Set_size (9);

Objchart.title.font.set_name ("Song"); objchart.title.font.set_size (11);

String strabsolutepath = server.mappath (".") @ "/ tempfiles /" filename; // file saved location objcspace.exportPicture (StrabsolutePath, "GIF", 600, 350); // File resolution other attribute string strRelativePath = "./TempFiles/" filename; string strImageTag = ""; ChartHolder.Controls.Add (new LiteralControl (strImageTag)); // picture filled PlaceHolder objects in Chartholer. } The charted effect of the last display is as follows:

转载请注明原文地址:https://www.9cbs.com/read-31629.html

New Post(0)