Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1725
Inserting UltraCharts into a report
posted

First, let me say I know nothing useful about graphics (transforms and scaling and such).  That having been said, what I'm trying to do is insert an ultrachart into a Documents Report that I'm export.  

The thing I'm trying to figure out is how to insert and scale (automatically if possible) the chart to the canvas I'm rendering the chart into. The code looks like

                IText txt;
                txt = section.AddText();
                txt.AddContent("Summary Results", h1Style);
                txt.Heading = Infragistics.Documents.Report.TextHeading.H1;
                txt.Margins.Bottom = 10;

                txt = section.AddText();
                txt.AddContent("Summary Chart", h2Style);
                txt.Heading = Infragistics.Documents.Report.TextHeading.H2;
                txt.Margins.Bottom = 10;
                if (null == _results)
                {
                    _results = new TastingResults(_tasting);
                    _results.LoadResults();
                }
                if (null == chartHelper)
                    chartHelper = new ReportChartForm(_tasting, _results );                   

                //* This actually builds the chart based on the input values from above
               chartHelper.SetupChart(Infragistics.UltraChart.Shared.Styles.ChartType.ColumnChart);
                Infragistics.Win.UltraWinChart.UltraChart resultsChart = chartHelper.Chart;
                Report.ICanvas canvas = section.AddCanvas();
              
                Graphics g = canvas.CreateGraphics();

                resultsChart.BorderStyle = BorderStyle.None;
                resultsChart.TitleTop.Text = "Tasting Summary";
                resultsChart.RenderPdfFriendlyGraphics(g);
 

I've kind of got things to work by scaling the chart with something like

              canvas.Scale(.70f, .70f);

But these numbers come only from trial and error. 

 

What I'm looking for is the "right" way to do this. I want to be able to size the canvas or size the chart or both so that it fills the remaining space on the current page. 

More generally, I'm going to have a section in the report that will need to be multicolumn and will include charts (similar to what MS Word does with inserting charts in a multicolumn document). I need some way to generally figure out and the scale the charts (keeping the aspect ratio). 

In the code above I've been using the RenderPdfFriendlyGraphics method. For my purposes would it be better to somehow get an image and the use the InsertImage or InsertMetafile methods. These seem to provide more control over scaling using relativeheight/width type properties.

If I use the code above (without the scale) the chart is just clipped at the page  bottom/right.

I also find that the chart has a border that I don't want even though I've set (I think) the borderstyle to none on the chart.

 

Thanks

Neil