Hi,
Is there any option to export legend box to an image?
I know I can export any chart with/without the legend but I would like to export just legend box (if visible).
I use TeeChart for WPF.
regards, Adam
Export legend only to an image
Re: Export legend only to an image
Hello Adam,
I hope will helps.
Thanks,
No, there isn't. If you want get the legend box, you must export the control Chart. When you have the image, you can manipulate it as you want. To achieve this, you can use GetLegendRect event as do in next code:Is there any option to export legend box to an image?
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
private Bitmap chartBmp;
private void InitializeChart()
{
tChart1.Series.Add(new Steema.TeeChart.Styles.Bar()).FillSampleValues();
chartBmp = tChart1.Bitmap;
tChart1.GetLegendRect += tChart1_GetLegendRect;
}
void tChart1_GetLegendRect(object sender, Steema.TeeChart.GetLegendRectEventArgs e)
{
Rectangle cropRect = e.Rectangle;
Bitmap legendImg = new Bitmap(cropRect.Width, cropRect.Height);
using (Graphics g = Graphics.FromImage(legendImg))
{
g.DrawImage(chartBmp, new Rectangle(0, 0, legendImg.Width, legendImg.Height),
cropRect,
GraphicsUnit.Pixel);
}
legendImg.Save(@"c:\temp\legend.png");
}
Thanks,
Best Regards,
Sandra Pazos / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |