Quantcast
Channel: Telerik Forums RSS
Viewing all articles
Browse latest Browse all 94857

Chart view image doesn't work correctly

$
0
0

Hi,

I'm facing a strange behaviour when i export a userControl containing a ChartView as a png picture.
Let's explain my issue with code.

First i create a userControl, this userControl has a title ( label) and a chartView.

this chart is slightly customized, i want to show checkboxes as legend items. to do this, i have followed an example mentioned in the forum.

If the checkbox is unckeced the related serie is hidden.

 

var myUserControl = newStatisticLayoutWithAdditionalStats();
 
myUserControl.ChartView.ChartElement.LegendElement.VisualItemCreating += LegendElement_VisualItemCreating;
/// Set layout properties
myUserControl.Title = "Blablabla";
myUserControl.ChartView.AreaType = ChartAreaType.Cartesian;
myUserControl.ChartView.ShowLegend = true;
 
LineSeries serie1 = newLineSeries();
LineSeries serie2 = newLineSeries();
 
 
serie1.DataSource = newBindingList<Coordinate>(Serie1DataSource.Coordinates);
serie1.CategoryMember = "Abscissa";
 
serie2.DataSource = newBindingList<Coordinate>(Serie2DataSource.Coordinates);
serie2.CategoryMember = "Abscissa";
serie2.ValueMember = "Ordinate";
 
myUserControl.ChartView.Series.Add(serie1);
myUserControl.ChartView.Series.Add(serie2);

 

// This class is used to customize legend items
publicclassCheckBoxLegentItemElement : LegendItemElement
{
 privateRadCheckBoxElement checkBox = newRadCheckBoxElement();
 
publicCheckBoxLegentItemElement(LegendItem item)
{
 this.checkBox.ToggleStateChanged += checkBox_ToggleStateChanged;
}
 
 voidcheckBox_ToggleStateChanged(objectsender, StateChangedEventArgs args)
        {
            if(args.ToggleState == Telerik.WinControls.Enumerations.ToggleState.On)
            {
                this.LegendItem.Element.IsVisible = true;
            }
            else
            {
                this.LegendItem.Element.IsVisible = false;
 
            }
        }
 
 
}

 

If i display this userControl in a Form it works fine.

But i want to export this userControl as a picture, the userControl can't be displayed in a form, juste created in memory.

 

myUserControl.Size = newSize(600,400);
Bitmap bitmap = newBitmap(600, 400);
myUserControl.DrawToBitmap(bitmap, (myUserControl.ClientRectangle));

If all checkboxes are checked, the image is good.

But if, at least, one of them is uncheck the graph doesn't display.

Do you have any explanation ?

Regards,

Mathieu


Viewing all articles
Browse latest Browse all 94857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>