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

Chart Data Binding

1 Answer 119 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ankit Dwivedi
Top achievements
Rank 1
Ankit Dwivedi asked on 11 Jan 2010, 09:11 AM
Hi,

I have a chart and table wizard both are depended on report parameter.
Table data is refreshing when i am selecting any other value from dropdown
but chart is not refreshing based on dropdown.

I have alredy check your product line sales demo but its not clear that
where I can pass the parameter for chart refreshing.

Private Sub chart1_NeedDataSource(ByVal sender As Object, ByVal e As
System.EventArgs) Handles chart1.NeedDataSource
Dim conn = New SqlConnection("Data Source=XXXXXX;Initial
Catalog=XXX;Persist Security Info=True;User ID=XXXXXXX;Password=XXXXXXXX")
Dim adp As SqlDataAdapter
adp = New SqlDataAdapter()
Dim scomm As New SqlCommand
Dim dst As New DataSet
scomm.CommandText = "SELECT presentpost, sum(CurrentSalary) as TotalSalary
from associate where activestatus='A' group by presentpost"
scomm.Connection = conn
adp.SelectCommand = scomm
adp.Fill(dst)
Dim chart As Telerik.Reporting.Processing.Chart = TryCast(sender,
Telerik.Reporting.Processing.Chart)
chart.DataSource = dst
chart1.PlotArea.XAxis.DataLabelsColumn = "TotalSalary"
End Sub


Please help me this is really most important part for my project.
we can decide to purchase this license.

Thanks,
Ankit

1 Answer, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 11 Jan 2010, 05:30 PM
Hello Ankit,

If you review carefully the Product Line Sales demo report code behind you would notice that the chart data is filtered directly through its query e.g.:

string commandText = @"
SELECT TOP 10 C.LastName
    , C.FirstName
    ...
    , PC.Name
    ...
FROM
    Sales.SalesPerson AS SP
    INNER JOIN HumanResources.Employee AS E ON SP.SalesPersonID = E.EmployeeID
    ......
    INNER JOIN Production.ProductCategory AS PC ON PS.ProductCategoryID = PC.ProductCategoryID
WHERE
    PS.Name IN (" + FormatParam((IList)this.ReportParameters["ProductSubcategory"].Value) + ") " +
@"
GROUP BY
    C.LastName
    , C.FirstName
    , E.EmployeeID
    , PC.Name";

This is needed as the chart does not use the reporting data engine and that is the reason it cannot be bound through the report designer. As you can see from the above code, the ProductSubcategory report parameter value is used to filter the query used for binding the report.

Regards,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
General Discussions
Asked by
Ankit Dwivedi
Top achievements
Rank 1
Answers by
Steve
Telerik team
Share this question
or