Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Silverlight > Chart > Exporting a Chart to Image with prefered size

Not answered Exporting a Chart to Image with prefered size

Feed from this thread
  • Patric Svensson avatar

    Posted on May 7, 2012 (permalink)

    Hi,

    I am trying to export a RadChart to an image using myRadChart.ExportToImage(stream). This all works very well but I want to change the size of the output image.

    So I tried doing:

    myChart.Width = 800;
    myChart.Height = 600;
    myChart.ExportToImage(stream);

    However, the output image is still as big as the current browser view is.

    Is there a way around this?

    Thanks

    Reply

  • Petar Marchev Petar Marchev admin's avatar

    Posted on May 10, 2012 (permalink)

    Hello Patric,

    This is more of a architecture's limitation. If you attempted the same with any other Silverlight control (such as Button) then you would get the same result. This is because even though you are changing the size - a layout pass has not been performed. This is the reason we do not support such a functionality out-of-the-box.
     
    However, I can suggest that you try this: wrap the export (and the dispose) in a Dispatcher Invoke. This will delay the export and may be a layout update pass will occur. I have tried this in a simple example and it works. Code below should help:
    myChart.Width = 800;
    myChart.Height = 600;
     
    Dispatcher.BeginInvoke(() =>
    {
      myChart.ExportToImage(stream);
       // stream.Close();
    });

    Another thing you can try is to force the LayoutUpdate:
    myChart.Width = 800;
    myChart.Height = 600;
     
    myChart.UpdateLayout();
    myChart.ExportToImage(stream);

    I would like to note again that this is a framework's limitation and this is really a hacky way to go around it, so make sure you test this thoroughly before you ship your product.

    All the best,
    Petar Marchev
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

    Reply

  • Say Hello to Telerik's PivotGrid for ASP.NET AJAX, Silverlight, WPF and WinForms. Now packed with OLAP support.
  • shankar parsanamoni avatar

    Posted on Sep 12, 2012 (permalink)

    hello patric ,can you able to place the code here.

    Reply

  • Petar Marchev Petar Marchev admin's avatar

    Posted on Sep 14, 2012 (permalink)

    Hello Shukreya,

    I have attached a simple project that demonstrates the two approaches.

    Kind regards,
    Petar Marchev
    the Telerik team

    Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Silverlight > Chart > Exporting a Chart to Image with prefered size
Related resources for "Exporting a Chart to Image with prefered size"

Silverlight Chart Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  ]