This is a migrated thread and some comments may be shown as answers.

Need Data Source event

1 Answer 108 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Terry
Top achievements
Rank 1
Terry asked on 18 Apr 2012, 05:01 PM
Im trying to adjust the labels on the legend of a pie chart and want to make sure i have the need data source event set up correctly, does it look correct below? sorry about the code format below i dont know how to condense of format it as asked.

namespace

 

 

Reports

 

{

 

 

using System;

 

 

 

using System.ComponentModel;

 

 

 

using System.Drawing;

 

 

 

using System.Windows.Forms;

 

 

 

using Telerik.Reporting;

 

 

 

using Telerik.Reporting.Drawing;

 

 

 

using Telerik.Reporting.Charting;

 

 

 

/// <summary>

 

 

 

/// Summary description for DeliveryStatus___Client.

 

 

 

/// </summary>

 

 

 

public partial class DeliveryStatus___Client : Telerik.Reporting.Report

 

{

 

 

public DeliveryStatus___Client()

 

{

 

 

//

 

 

 

// Required for telerik Reporting designer support

 

 

 

//

 

InitializeComponent();

}

 

 

//

 

 

 

// TODO: Add any constructor code after InitializeComponent call

 

 

 

//

 

 

 

 

private void chart1_NeedDataSource(object sender, System.EventArgs e)

 

{

Telerik.Reporting.Processing.

 

Chart chart = sender as Telerik.Reporting.Processing.Chart;

 

chart.Series.Clear();

 

 

ChartSeries s = new ChartSeries();

 

s.Type =

 

ChartSeriesType.Pie;

 

s.Appearance.LegendDisplayMode =

 

ChartSeriesLegendDisplayMode.ItemLabels;

 

chart.Series.Add(s);

}

}

}

1 Answer, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 19 Apr 2012, 09:21 AM
Hello,

Yes the code is correct. In order for the NeedDataSource event to be fired, the DataSource property of the chart should not be set and the event should be wired either through the chart item's property grid or with code e.g.:

this.chart1.NeedDataSource += new System.EventHandler(this.chart1_NeedDataSource);

You can use the Format code block tool in the RadEditor to post code instead of pasting it directly from Visual Studio.

Greetings,
Steve
the Telerik team
BLOGGERS WANTED! Write a review about Telerik Reporting or the new Report Designer, post it on your blog and get a complimentary license for Telerik Reporting. We’ll even promote your blog and help bring you a few fresh readers. Yes, it’s that simple. And it’s free. Get started today >
Tags
General Discussions
Asked by
Terry
Top achievements
Rank 1
Answers by
Steve
Telerik team
Share this question
or