We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

ChartWebControl.SaveImage messing with image ratio

Hi,
I've migrated a ASP.NET Web Forms solution from .NET framework 3.5 to .NET 4.0 and along with it, from syncfusion 6.303.1.8 to 13.240.0.29. 

I'm currently fixing the differences.

I have some ChartWebControls in an aspx page, which are all 400x324. It all worked and continues working well in the page.
Eventually, those charts are exported to XLS. They are saved to a Png Stream and then added to the sheet Pictures collection:

this.cwb_chart1.SaveImage(stream1, ImageFormat.Png);
sheet.Pictures.AddPicture(4, 2, stream1);

But if I check the resolution of the Image in the Stream saved, even before adding it to the Worksheet, it shows 560x324, not 400x324. All charts are now getting wider.
I tried to resize the control do 800x648, then saving it to stream and then resizing the image to 400x324 before adding to the Worksheet. The ratio is maintained, but the chart becomes unreadable, because the letters get too small.

Also tried using SaveImage(Size chartSize, bool drawHiddenElements) specifying 400x324 size, but the behaviour is the same.

Is there a way to preserve the original resolution of 400x324 for all charts when saving?

Thank you in advance

3 Replies

SK Sanjith Kesavan Syncfusion Team August 19, 2015 06:40 AM UTC

Hi Djaci,
Sorry for the inconvenience caused. We can able to reproduce the reported issue while legend is enabled and the scroll bar for the legend is visible.Please confirm us that whether legend is enabled and scrollbar for the legend is visible in your sample. This will be helpful for us to provide you a timeline for this fix. If this is not your case can you provide us a sample replicating the scenario along with replication procedure.
Let us know if you have any queries.
Regards,
Sanjith K


DJ Djaci August 21, 2015 05:07 PM UTC

Hi Sanjith,

Thank you for the response.

The chart has legend enabled, but no scrollbar visible. Here is one example:

                        <syncfusion:ChartWebControl ID="cwb_GraficoSul" runat="server" AutoCleanupCacheExpiration="00:00:30"
                            BackColor="" BackInterior="Solid; LightSteelBlue" ChartInterior="Solid; LightSteelBlue"
                            Font-Names="Verdana" Font-Size="14pt" GUID="" Height="324px" Series-Capacity="4"
                            Series-ShouldSort="False" Style="left: 2px" Width="400px" ZoomOutIncrement="0.20000000298023224">
                            <Legend Orientation="Horizontal" Style="position: absolute; display: block; left: 344px;
                                top: 10px; width: 46px; height: 22px; z-index: 300;" Visible="False"></Legend>
                            <ToolBar Caption="ToolBar" ControlRootCSSClass="toolbarRoot"></ToolBar>
                            <PrimaryYAxis DrawGrid="False" ForceZero="True" ForeColor="Black" Range="0, 100, 20" RangeType="Set" />
                            <PrimaryXAxis DateTimeFormat="dd/MM/yyyy" DrawGrid="False" ForeColor="Black" HidePartialLabels="True" IntervalType="Days" Range="0, 31, 10" RangeType="Set" />
                            <ChartArea ID="ChartArea1" BackInterior="Solid; LightSteelBlue" BorderStyle="None" textRenderingHint="SystemDefault">
                                <ChartAreaMargins Bottom="10" />
                            </ChartArea>
                        </syncfusion:ChartWebControl>

and code behind:

            this.cwb_GraficoSul.PrimaryXAxis.Title = textInfo.ToTitleCase(date.ToString("MMMM/yyyy", culture));
            this.cwb_GraficoSul.PrimaryXAxis.ValueType = ChartValueType.DateTime;
            this.cwb_GraficoSul.PrimaryXAxis.RangeType = ChartAxisRangeType.Set;
            this.cwb_GraficoSul.PrimaryXAxis.DateTimeRange = new ChartDateTimeRange(initialDate, finalDate, 10, ChartDateTimeIntervalType.Days);
            this.cwb_GraficoSul.PrimaryXAxis.TickSize = new Size(1, 5);
            this.cwb_GraficoSul.PrimaryXAxis.SmallTicksPerInterval = 1;
            this.cwb_GraficoSul.PrimaryXAxis.SmallTickSize = new Size(1, 5);
            this.cwb_GraficoSul.PrimaryXAxis.DateTimeFormat = "dd";

            this.cwb_GraficoSul.PrimaryYAxis.RangeType = ChartAxisRangeType.Set;
            this.cwb_GraficoSul.PrimaryYAxis.Range = new MinMaxInfo(0, 100, 20);
            this.cwb_GraficoSul.PrimaryYAxis.SmallTickSize = new Size(5, 1);
            this.cwb_GraficoSul.PrimaryYAxis.SmallTicksPerInterval = 1;
            this.cwb_GraficoSul.PrimaryYAxis.TickSize = new Size(5, 1);


Other than that there's only code concerning ChartSeries data and style.

Hope this info helps you.

Regards,
Djaci


VA Vinothkumar Arumugam Syncfusion Team August 24, 2015 12:58 PM UTC

Hi Pranav,

We are able to reproduce the issue. So we have logged defect on this “Chart export image size not proper resolution in Excel” with new incident 143155. A support incident to track the status of this issue has been created under your account. Please log on to our support website to check for further updates
https://www.syncfusion.com/account/login?ReturnUrl=%2fsupport%2fdirecttrac%2fincidents .
Please let us know if you have any concern.
Thanks,
Vinothkumar Arumugam.


Loader.
Live Chat Icon For mobile
Up arrow icon