ReportMax is a free reporting tool for .NET developers. In this tutorial, I will show how to use the Chart control within ReportMax reports. Please note that as a pre-requisite for this tutorial, you need to read Tutorial 1 located here.
This is a series of tutorials on how to use this nice free tool. This is one of the most wanted features: Using Charts inside Reports.
You will need ReportMax version 2.3 or higher.
MainReport
MainChart
Please note that the Chart control is basically a wrapper around Microsoft Chart control. So anything you can do with Microsoft Chart control, you can do with this control.
For a good reference for Microsoft Chart control, you can refer to this link.
Another important point to mention is that you can only program the chart control by code and not at design time.
ReportMax
ReportFile
Report_PageHeader
private void reportMaxViewer1_Report_PageHeader_Format( CppMax.ReportMax.ReportMaxPage FilePage, ref bool bCancel) { ReportMaxChart MainChart = (ReportMaxChart)FilePage.FindControl("MainChart"); Chart chart1 = MainChart.GetChart(); ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); Legend legend1 = new System.Windows.Forms.DataVisualization.Charting.Legend(); Series series1 = new System.Windows.Forms.DataVisualization.Charting.Series(); Series series2 = new System.Windows.Forms.DataVisualization.Charting.Series(); Title title1 = new System.Windows.Forms.DataVisualization.Charting.Title(); chart1.BackColor = System.Drawing.Color.FromArgb( ((System.Byte)(243)), ((System.Byte)(223)), ((System.Byte)(193))); chart1.BackGradientStyle = System.Windows.Forms.DataVisualization.Charting.GradientStyle.TopBottom; chart1.BorderlineColor = System.Drawing.Color.FromArgb( ((System.Byte)(181)), ((System.Byte)(64)), ((System.Byte)(1))); chart1.BorderlineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Solid; chart1.BorderlineWidth = 2; chart1.BorderSkin.SkinStyle = System.Windows.Forms.DataVisualization.Charting.BorderSkinStyle.Emboss; chartArea1.Area3DStyle.IsClustered = true; chartArea1.Area3DStyle.Perspective = 10; chartArea1.Area3DStyle.IsRightAngleAxes = false; chartArea1.Area3DStyle.WallWidth = 0; chartArea1.Area3DStyle.Inclination = 15; chartArea1.Area3DStyle.Rotation = 10; chartArea1.AxisX.LabelStyle.Font = new System.Drawing.Font("Trebuchet MS", 8.25F, System.Drawing.FontStyle.Bold); chartArea1.AxisX.LineColor = System.Drawing.Color.FromArgb( ((System.Byte)(64)), ((System.Byte)(64)), ((System.Byte)(64)), ((System.Byte)(64))); chartArea1.AxisX.MajorGrid.LineColor = System.Drawing.Color.FromArgb( ((System.Byte)(64)), ((System.Byte)(64)), ((System.Byte)(64)), ((System.Byte)(64))); chartArea1.AxisY.LabelStyle.Font = new System.Drawing.Font("Trebuchet MS", 8.25F, System.Drawing.FontStyle.Bold); chartArea1.AxisY.LineColor = System.Drawing.Color.FromArgb( ((System.Byte)(64)), ((System.Byte)(64)), ((System.Byte)(64)), ((System.Byte)(64))); chartArea1.AxisY.MajorGrid.LineColor = System.Drawing.Color.FromArgb( ((System.Byte)(64)), ((System.Byte)(64)), ((System.Byte)(64)), ((System.Byte)(64))); chartArea1.AxisY.MajorTickMark.Size = 0.6F; chartArea1.BackColor = System.Drawing.Color.OldLace; chartArea1.BackSecondaryColor = System.Drawing.Color.White; chartArea1.BorderColor = System.Drawing.Color.FromArgb( ((System.Byte)(64)), ((System.Byte)(64)), ((System.Byte)(64)), ((System.Byte)(64))); chartArea1.Name = "Default"; chartArea1.Position.Auto = false; chartArea1.Position.Height = 78F; chartArea1.Position.Width = 88F; chartArea1.Position.X = 5F; chartArea1.Position.Y = 15F; chartArea1.ShadowColor = System.Drawing.Color.Transparent; chart1.ChartAreas.Add(chartArea1); legend1.Alignment = System.Drawing.StringAlignment.Far; legend1.IsTextAutoFit = false; legend1.BackColor = System.Drawing.Color.Transparent; legend1.Font = new System.Drawing.Font("Trebuchet MS", 8.25F, System.Drawing.FontStyle.Bold); legend1.Name = "Default"; legend1.Position.Auto = false; legend1.Position.Height = 14.23021F; legend1.Position.Width = 19.34047F; legend1.Position.X = 74.73474F; legend1.Position.Y = 74.08253F; chart1.Legends.Add(legend1); chart1.Location = new System.Drawing.Point(16, 56); chart1.Name = "chart1"; chart1.Palette = System.Windows.Forms.DataVisualization.Charting.ChartColorPalette.BrightPastel; series1.BorderColor = System.Drawing.Color.FromArgb(( (System.Byte)(180)), ((System.Byte)(26)), ((System.Byte)(59)), ((System.Byte)(105))); series1.ChartType = SeriesChartType.Radar; series1.Color = System.Drawing.Color.FromArgb( ((System.Byte)(220)), ((System.Byte)(65)), ((System.Byte)(140)), ((System.Byte)(240))); series1.MarkerBorderColor = System.Drawing.Color.FromArgb( ((System.Byte)(64)), ((System.Byte)(64)), ((System.Byte)(64))); series1.MarkerSize = 9; series1.Name = "Series1"; series1.ShadowOffset = 1; series2.BorderColor = System.Drawing.Color.FromArgb( ((System.Byte)(180)), ((System.Byte)(26)), ((System.Byte)(59)), ((System.Byte)(105))); series2.ChartType = SeriesChartType.Radar; series2.Color = System.Drawing.Color.FromArgb(((System.Byte)(220)), ((System.Byte)(252)), ((System.Byte)(180)), ((System.Byte)(65))); series2.MarkerBorderColor = System.Drawing.Color.FromArgb( ((System.Byte)(64)), ((System.Byte)(64)), ((System.Byte)(64))); series2.MarkerSize = 9; series2.Name = "Series2"; series2.ShadowOffset = 1; chart1.Series.Add(series1); chart1.Series.Add(series2); chart1.TabIndex = 1; title1.ForeColor = System.Drawing.Color.FromArgb( ((System.Byte)(26)), ((System.Byte)(59)), ((System.Byte)(105))); title1.Font = new System.Drawing.Font("Trebuchet MS", 14.25F, System.Drawing.FontStyle.Bold); title1.ShadowColor = System.Drawing.Color.FromArgb( ((System.Byte)(32)), ((System.Byte)(0)), ((System.Byte)(0)), ((System.Byte)(0))); title1.ShadowOffset = 3; title1.Text = "Radar Chart"; chart1.Titles.Add(title1); // Populate series data // this could come from a data source double[] yValues = { 65.62, 75.54, 60.45, 34.73, 85.42, 55.9, 63.6, 55.1, 77.2 }; double[] yValues2 = { 76.45, 23.78, 86.45, 30.76, 23.79, 35.67, 89.56, 67.45, 38.98 }; string[] xValues = { "France", "Canada", "Germany", "USA", "Italy", "Spain", "Russia", "Sweden", "Japan" }; chart1.Series["Series1"].Points.DataBindXY(xValues, yValues); chart1.Series["Series2"].Points.DataBindXY(xValues, yValues2); // Set radar chart style chart1.Series["Series1"]["RadarDrawingStyle"] = "Area"; chart1.Series["Series2"]["RadarDrawingStyle"] = "Area"; chart1.Series["Series1"].BorderColor = Color.FromArgb(100, 100, 100); chart1.Series["Series1"].BorderWidth = 1; chart1.Series["Series2"].BorderColor = Color.FromArgb(100, 100, 100); chart1.Series["Series2"].BorderWidth = 1; // Set circular area drawing style chart1.Series["Series1"]["AreaDrawingStyle"] = "Polygon"; chart1.Series["Series2"]["AreaDrawingStyle"] = "Polygon"; // Set labels style chart1.Series["Series1"]["CircularLabelsStyle"] = "Circular"; chart1.Series["Series2"]["CircularLabelsStyle"] = "Circular"; MainChart.UpdateChart(chart1); }
Note that a chart type you can do with Microsoft Chart control can be done by ReportMaxChart control.
ReportMaxChart
First, you need to get the embedded Microsoft Chart control and modify it and at the end, call UpdateChart to paint.
UpdateChart
The sample project contains a charting example. Please note that you can obtain data from any data source accessible from .NET and bind it to the chart.
Also, please refer to:
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)
0 messages have been posted for this article Visit http://www.codeproject.com/Tips/581160/NET-Reporting-Tool-Tutorial-3 to post and view comments on this article, or click here to get a print view with messages.