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

Data Binding a Chart to Access DB

7 Answers 223 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Barry
Top achievements
Rank 1
Barry asked on 03 Jun 2009, 10:05 AM
I've been using Active Reports in my applications for many years but recently instead of upgrading to the new versions I decided to look at other options. I found Telerik and was quite impressed with many of the features. I like the way the reports can render in Winforms and the Web along wiht a number of other things. I downloaded a trial and set about building several reports to make sure I can reproduce all the features I used to get from Active Reports before jumping ship. I found the reports side of things quite good although I did have some issues trying to get a simple date field to display by setting a format on the properties of the field.

Anyway, when I got to the report that needed to have a chart I became frustrated. I just wanted to bind a simple chart to the same data source as my report and I foudn this was not easy to do. I searched through all the documentation and tutorials and found there is very little explanation on how to data bind a chart. The examples show binding to a data adaptor or a data table but it doesn't say how the data should be structured to bind it to the report. I tried copying from some of the samples but I can't get a simple chart to show any data. 

I gave up trying to bind to my report data source adn tried to create an independant data sourtce to bind to. I am trying to bind to an Access database using OLDB.

I got down to the most simple code but every time I try to run the report it just sits there displaying "Generating report" forever. There is no error message and no clue as to why it doesn't work. I'm just guessing at the SQL I thougth i'd put two simple fields in and it might bind to them.

Here's the code:
Private Sub ChartDailyTotals_NeedDataSource(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ChartDailyTotals.NeedDataSource
        Try
            Dim Mychart As Telerik.Reporting.Processing.Chart = TryCast(sender, Telerik.Reporting.Processing.Chart)
            Dim commandText As String = "SELECT top 5 TriggerDate, TriggerCount from triggers"
            Dim MyAdapter As New OleDb.OleDbDataAdapter(commandText, My.Settings.WinCounterReportsDataConnection)
            Dim MyDataSet As New DataSet()

            MyAdapter.Fill(MyDataSet)
            Mychart.DataSource = MyDataSet
        

Catch ex As System.Exception
            System.Diagnostics.Debug.WriteLine(ex.Message) 
        End Try
    End Sub


I don't give up easily but I've been trying to do this for two days. If I don't get an answer soon I will have to go back to Active Reports. It's a shame because I really liked what Telerik had to offer.

Perhaps someone can point me to some documentation or show me what I should do.


7 Answers, 1 is accepted

Sort by
0
Barry
Top achievements
Rank 1
answered on 03 Jun 2009, 11:51 PM
Well i've spent some more time on this. I decided to make a new project. I created a single report and put a chart on it. I linked to an Access data source which is just a file on the local hard drive. I made this simple query as a datatable:

SELECT  Top 20 CDate(36526 + TriggerDate) AS RealTriggerDate, SUM(TriggerCount) AS TotalTriggers
FROM         Triggers
GROUP BY CDate(36526 + TriggerDate)

I tried linking the chart to this data table using this code:

Private Sub Chart1_NeedDataSource(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Chart1.NeedDataSource
        Dim MyChart As Telerik.Reporting.Processing.Chart = TryCast(sender, Telerik.Reporting.Processing.Chart)
        MyChart.DataSource = Me.TriggerDataTableAdapter1.GetData()
End Sub

So at this point it was good news the chart displayed some data. I tried adjusting the TOP 20 to Top 40 then Top 100.
That's when things went bad. I found when i had 40 records in the data table the report generation started to slow down. If I made the query return 100 records it took 3.5 minutes to build the report.

I took the "TOP" command out or the SQL query so it would return 403 values. The report sat there for 20 minutes saying "Generating report" There is not much point in finding out how long it takes because everyone knows 20 minutes is far too long. 

If I run the query in the query builder it returns the results instantly. So why does the Telerik chart take so long?

The reports seem to run fast. It is jsut the charts that let the product down.

Has anyone else found this? Is this jsut an Access thing? I havn't tried a SQLServer data source yet.

I'm still willing to give the product a fair go, but I have to find a way to get the charts working.

If I could I would rename this thread "Data binding to a chart is sooooooo slow!"

Any comments???

0
Barry
Top achievements
Rank 1
answered on 04 Jun 2009, 02:13 AM
Just in case anyone is reading this:

I thought i'd experiment with a SQL Server connection. I opend the example project provided by Telerik adn looked at the dashboard report. All the queries have "TOP 5" in them so I removed it from the SQL statement. These queries then returned around 200 records. I ran the report and the charts all load in a couple of seconds. So it is possible to display charts with hundreds of records.

I went back and tried modifying the query in my original test to the most basic query i could use. I made this query:
SELECT    TriggerDate, SUM(TriggerCount) AS TotalTriggers
FROM         Triggers
GROUP BY TriggerDate

I get the same results. If i load it into a chart with 20 records it is fast if i load it with more than 100 it becomes too slow for practical use. i.e something like 30 minutes to build a chart.

Does Telerik just not work if you try to use an Access file to load data from? I'm still trying to find something in the documentation but there is not much at all about Charts in Telerik Reports.

I'll just wait to see if I get any answers now I can't rally do much more to find out the cause of this.


0
Barry
Top achievements
Rank 1
answered on 04 Jun 2009, 08:34 AM
Ok I know I said I was going to leave it but I just had to find out more. I thought I'd try loading the data into an array and binding the chart to the array to see if it was quicker. I started by settign up a simple report with a single chart and built an array in code to bind to. I set the array as the data source just to get the chart binding to it. I found I was getting the same problems. If I made a 10 element array it loaded the chart in less than a second. When i increased it to 20 elements it took just over a second but 30 took 21 seconds. 40 took 1.4 minutues and 50 took 8 minutes. I didn't try 60 as I know it would probably sit there for half an hour or more.

So this exponential decrease in performance seems to apply to binding to an array as well as an Acess data source. 

Does this mean tha the Telerik charts just can't be used if there is more than just a few records in the data? 

I'm still waiting for someone to comment. If i don't get any answer I might try posting this with a different thread topic because this is not really just an Access DB problem it seems to be a design fault in the way the chart binds to data.

I'm afraid this is still looking like a show stopper for me using the product :( 

I think it is only reasonable to expect a chart to be able to handle a few hundred records.

Here is the code:

Public DataSize as integer 

Private Sub Chart1_NeedDataSource(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Chart1.NeedDataSource
        BuildComplete = False
        Dim MyChart As Telerik.Reporting.Processing.Chart = TryCast(sender, Telerik.Reporting.Processing.Chart)

' make a two dimensional array and fill it with some numbers
        Dim MyArray(DataSize, 2) As Integer
        For i As Integer = 0 To DataSize
            MyArray(i, 0) = i
            MyArray(i, 1) = i * 10
        Next
        MyChart.DataSource = MyArray
    End Sub
0
Barry
Top achievements
Rank 1
answered on 08 Jun 2009, 12:57 AM
If anyone is reading I thought I'd see if this was something to do with the computer it was running on. I ran the project on a different machine and got similar results. The first machine is a quad core Intel machine running XP and the second machine was a dual core AMD running Vista.

THe XP machine results were slightly faster which I presume is just because of the better cpu.

Using just an array to bind to with no database the results on the vista machine were:

Array elements

Time in  seconds

up to 10 

<1

20

2

25

4

30

27

35

29

40

121

45

326

50

597


As you can see there is still an exponential decrease in speed to build the chart. This quickly degrades to an unusable time.

I haven't had any comments from anyone on this and I need to make a decision about whether or not to go with Telerik for a new product we are building. At this stage it appears I don't have any choice but to go back to Active Reports because it seems the Telerik chart is just letting down the rest of the product.

I'll try submitting a support ticket to see if I get any response but otherwise i'm disappointed. The product showed so much potential.
0
Accepted
Ves
Telerik team
answered on 08 Jun 2009, 11:37 AM
Hi Barry,

Please, accept our apologies for the delayed reply.

While the chart would have problems displaying thousands of items, a set of 50 or 100 items should be displayed instantly. One possible reason for experiencing such heavy performance issues with so small datasource would be IntelligentLabelsEnabled property set to true. Indeed, this would force the chart to re-arrange the item labels, so that they do not overlap. However, the more labels are present in the chart, the more complex the calculations become. Given that using the default chart size it would be hard to read 50 labels anyway, I would suggest that you disable the intelligent labels and give it another try.

If that is not the case, please provide more details on the chart configuration, so we can further investigate the issue. Thank you.

Kind regards,
Ves
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
Barry
Top achievements
Rank 1
answered on 09 Jun 2009, 01:23 AM
Hi Ves
I had the IntelligentLabelsEnabled property set to False in the designer but it didn't seem to make any difference. I was going to post back and I thought I'd try setting it to false in code again on the line before I bind the report. Doing that seemed to make it work! Excellent, that now makes a huge difference. It will do 500 records in a couple of seconds! 

I'm not sure why it doesn't work when I set it in the designer. I guess I will jsut need to set all the properties in code jsut to be sure they work.

I'll now need to do some more research to find out how to switch things like this off. I had a look at the documentation and I can't find anything that tells me how to switch off labels (the ones that  show the amount of each data point) alltogether. I'm sure it is there somewhere but it seems like there are a lot of properties with no documentation. For example the help file just says there is a property called IntelligentLabelsEnabled but there is no description of what it does. Is there some documentation that has some sort of description of what the properties do other than their name? Can you point me in the right direction?

Otherwise, I am delighted that I can put Telerik back on the shortlist. I had already started looking at building hte project with Active Reports but I still prefer Telerik if it can perform. I am now going to build one of out real reports to see how it runs on real data.

Thanks for your help.
0
Ves
Telerik team
answered on 10 Jun 2009, 10:24 AM
Hi Barry,

Generally, you should not be forced to set every property in the code, but I guess the current case makes it seem so. I will make sure our developers are notified about this.

The chart item labels -- you can wire the DataBound event, so that the ChartSeries object is available and use a line like this:

chart.Series[0].Appearance.LabelAppearance.Visible = false;

I must say, we are aware our documentation is not complete, but we are continuously working on it. I am afraid we do not have a detailed description of every property for the moment. Still, we will be glad to help with any specific question that might arise.

I am glad we still have credit and I believe our products will match your requirements.

Best regards,
Ves
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.
Tags
General Discussions
Asked by
Barry
Top achievements
Rank 1
Answers by
Barry
Top achievements
Rank 1
Ves
Telerik team
Share this question
or