Saving the Chart Image as Jpeg or Png

To save the C1Chart control as a .Jpg or .Png, use the following code:

// should be added at the beginning of file

    using C1.Silverlight.Chart.Extended;

   ...

 

    // Silverlight

    SaveFileDialog sfd = new SaveFileDialog();

    sfd.Filter = "Jpeg files (*.jpg)|*.jpg|Png files (*.png)|*.png";

    if (sfd.ShowDialog() == true)

    {

      using (var stream = sfd.OpenFile())

      {

       if (sfd.SafeFileName.EndsWith(".jpg"))

         chart.SaveImage(stream, ImageFormat.Jpeg);

       else

       chart.SaveImage(stream, ImageFormat.Png);

      }

    }


Send us comments about this topic.
Copyright © GrapeCity, inc. All rights reserved.