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

Horizontal Bar?

9 Answers 185 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Joel
Top achievements
Rank 2
Joel asked on 18 Dec 2007, 02:08 PM
So..I was just handed an example of what the client wants now...  I cannot figure out how to do it with telerik reporting.  They want it exportable as PDF so I have to use telerik reporting.  Any suggestions would be greatly appreciated.

I have a 3 column detail table with N rows.  Widget Name, Widgets Sold, Sold %. Telerik Reporting is great at this!

Now client wants a graphical representation (horizontal bar chart with just 1 bar) between widget name and widgets sold (Think progress bar) representing sold %.  In standard asp/aspx front end, I could take a 1 px wide graphic and stretch it's width to Sold %, or repeat x Sold%.

Sales Territory X
Widget 1                                 0      0
widget  2        xxxxxx              6      60%
widget  9        xxxx                  4      40%

Is there a best practice with Telerik Reporting someone could suggest?

9 Answers, 1 is accepted

Sort by
0
Chavdar
Telerik team
answered on 19 Dec 2007, 01:29 PM
Hi Joel,

The best approach to do the task is to use the Chart report item. You can create a horizontal stacked bar series with the specified values and configure it to display as required.

I have attached a sample report which illustrates a possible implementation. Try it and let me know if you have any other questions.

Best wishes,
Chavdar
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Joel
Top achievements
Rank 2
answered on 09 Jan 2008, 03:35 PM
I have been unable to access this link to download the sample.  Could you perhaps send it again for forward it via email please?

Thank you.

-Joel
0
Chavdar
Telerik team
answered on 09 Jan 2008, 05:11 PM
Hello Joel,

The file is attached again. Let me know if there is still a problem.

Sincerely yours,
Chavdar
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Joel
Top achievements
Rank 2
answered on 09 Jan 2008, 06:40 PM
Thank you Chavdar.  I appreciate your quick response.

I don't really have the space for the example as you sent unfortunately, but the code was quite helpful for another project.

Would it be possible to pass an image path to display from the database?  I could make 100 different graphics of the same size, but each colored part of the bar incremented by .5px with the right side being clear, and pass which one to display with each detail record perhaps?


example:  If % is 11 then pass as a record from the database ~/images/11.gif
0
Joel
Top achievements
Rank 2
answered on 09 Jan 2008, 08:10 PM
I am finding other similar examples like this so I guess I am on the right track: http://www.telerik.com/community/forums/thread/b311D-tmabc.aspx

Does anyone have a VB example for binding on the detail record?  I would be more than happy with a single box in the detail pane, nothing fancy.

Also, where is the best place to put these graphics?  I cannot really hardcode a path on the filesystem.  I saw you can add graphics to the "Resources" folder, but it was not immediately obvious how to access them, or if that was the best method.

Any help as always is appreciated.
0
Joel
Top achievements
Rank 2
answered on 09 Jan 2008, 09:09 PM
Getting closer perhaps.  How do I bind to the datasource value in this?

    Private Sub detail_ItemDataBinding(ByVal sender As Object, ByVal e As System.EventArgs) Handles DetailSection1.ItemDataBinding 
        Dim myroot As String 
        myroot = "C:\temp\" 
        Dim myfile As String 
        myfile = "12.gif"  'something from the db indicating current row 
        Dim mypath As String 
        mypath = myroot & myfile 
        Me.pb2.MimeType = "image/gif" 
        Me.pb2.Value = Bitmap.FromFile(mypath) 
    End Sub 

0
Joel
Top achievements
Rank 2
answered on 09 Jan 2008, 09:45 PM
Last post on this.  Sorry for the spam.

This would actually be a much easier implementation if it were possible. (And would avoid making 100 graphics.)  I set the backcolor of the picture box to a color and if I could set the size of the box for each row, that would be easiest.  In testing on this, if I incremented barwidth, and they all end up that wide in the end.

    Private Sub detail_ItemDataBinding(ByVal sender As Object, ByVal e As System.EventArgs) Handles DetailSection1.ItemDataBinding 
        Dim barwidth As Double = 55 
        Me.pb2.MimeType = "image/gif" 
        Me.pb2.Value = Bitmap.FromFile("C:\temp\clear.gif") 
        Me.pb2.Size = New Telerik.Reporting.Drawing.SizeU(New Telerik.Reporting.Drawing.Unit(barWidth, CType(Telerik.Reporting.Drawing.UnitType.Pixel, Telerik.Reporting.Drawing.UnitType)), New Telerik.Reporting.Drawing.Unit(15, CType(Telerik.Reporting.Drawing.UnitType.Pixel, Telerik.Reporting.Drawing.UnitType))) 
    End Sub 

0
Milen | Product Manager @DX
Telerik team
answered on 10 Jan 2008, 03:54 PM
Hello Joel,

There are many solutions to the scenario you are facing. What you have done is really creative.

I have attached a report with two ways to implement a single horizontal bar on each detail row.

First of them is using a Chart reporting item. The chart contains only one series, with one item. This way the chart contains only one bar. The properties of the chart are setup so that it does not show labels, legend, etc. The good think about this approach is that the bar's look is fully customizable, you can set gradients, shadows, etc.

The second approach is based on your idea to resize an item according to the value you want do display. In the example is used TextBox item with background color. The good thing about it is that it is really simple. However, there is one hitch. The current release does not allow you to change the size of a Telerik.Reporting.Processing item (and that are the items you access in the OnDataBound events). The good news is that next week service pack will be released that will untie your hands. So you will only have to uncomment the row

            'bar.Size = size

and it will be fully functional.

It is up to you to decide between customizability and simplicity.

I hope this information helps. Please do not hesitate to write us again if you have any further questions.

Greetings,
Milen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Joel
Top achievements
Rank 2
answered on 10 Jan 2008, 06:50 PM
The chart you provided is a perfect solution.  The deadline is before the fix release date, so that made the decision easy.

Thank you very much for your efforts
Tags
General Discussions
Asked by
Joel
Top achievements
Rank 2
Answers by
Chavdar
Telerik team
Joel
Top achievements
Rank 2
Milen | Product Manager @DX
Telerik team
Share this question
or