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

unable do put datasource in chart

7 Answers 207 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
tica
Top achievements
Rank 1
tica asked on 08 Jul 2009, 10:05 AM
I´m have a problem
I can't add a datasource in a chart in order to appear on Data the combo box to choose the datasource.
anyone knows how to?
i've already read documentation but i can't find anything.
thank you

7 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 08 Jul 2009, 11:41 AM
Hello tica,

You can define the chart series, their appearance and the data binding information for them at design time and then at run-time supply the necessary data source through the NeedDataSource event.  You will find all the necessary information how to work with the Chart report item in the documentation articles. Let us know if you are experiencing any particular problems.

Best wishes,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
tica
Top achievements
Rank 1
answered on 09 Jul 2009, 08:47 AM
hi
i've seen those items that you said but my problem is that i can't add a data source. is anything in here who teachs how to make a report with a chart step by step like this: http://www.telerik.com/help/reporting/quick-start-create-simple-report.html .

i've already have in the report:

 

private void chart1_NeedDataSource(object sender, EventArgs e)

 

{

Telerik.Reporting.Processing.

Chart procChart = (Telerik.Reporting.Processing.Chart)sender;

 

procChart.DataSource = datasourcegraph;

}


thank you.
0
tica
Top achievements
Rank 1
answered on 10 Jul 2009, 10:08 AM
when i want to add a data source to chart i go to the Data and appears a message: to dynamically populate the chart with data use the NeedDataSource event.
i´ve got the event and in the graph.Designer.cs is the line:
this.chart1.NeedDataSource += new System.EventHandler(this.chart1_NeedDataSource);

i don't understand why in chart doesn't appear the data source to make a connection and get the values.
thank you
0
Steve
Telerik team
answered on 13 Jul 2009, 07:38 AM
Hi tica,

The code you've used so far is correct, but note that the chart would only show data if there is a numeric column to bind to. Additionally if you want to specify where the XAxis and YAxis get their values from, you should create chart series and set their DataYColumn and DataXColumn. Here is a sample code:

  private void chart1_NeedDataSource(object sender, EventArgs e)
        {
            string sql =
   @"SELECT TOP 20 Production.Product.ListPrice, Production.Product.Name, Production.Product.ProductID FROM Production.Product";
            string connectionString =
              "Data Source=(local)\\SQLEXPRESS;Initial Catalog=AdventureWorks;Integrated Security=True";

            SqlDataAdapter adapter = new SqlDataAdapter(sql, connectionString);
            DataSet dataSet = new DataSet();
            adapter.Fill(dataSet);
            ChartSeries series = new ChartSeries();
            series.DataYColumn = "ProductID";
            series.DataLabelsColumn = "Name";
            chart1.Series.Add(series);
            (sender as Telerik.Reporting.Processing.Chart).DataSource = dataSet.Tables[0].DefaultView;
        }

Greetings,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
tica
Top achievements
Rank 1
answered on 14 Jul 2009, 11:43 AM
hi
i've already tried that but didin't work.
i was expecting to appear something like chart Data in chart properties so i may choose the datasource.
thank you

0
Steve
Telerik team
answered on 14 Jul 2009, 11:49 AM
Hi tica,

As explained in the Chart overview page, the chart report item can be bound through the NeedDataSource event only. You cannot set a datasource through the chart properties for the time being.

Greetings,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
tica
Top achievements
Rank 1
answered on 14 Jul 2009, 12:02 PM
I understand that isn't possible but is was easier if it was possible.
thank you anyway.
I'm going to try another ways to make this works.
thank you.
Tags
General Discussions
Asked by
tica
Top achievements
Rank 1
Answers by
Steve
Telerik team
tica
Top achievements
Rank 1
Share this question
or