Horizontal Bar?

10 posts, 0 answers
  1. Joel
    Joel avatar
    166 posts
    Member since:
    Oct 2006

    Posted 18 Dec 2007 Link to this post

    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?
  2. Chavdar
    Admin
    Chavdar avatar
    898 posts

    Posted 19 Dec 2007 Link to this post

    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
  3. DevCraft banner
  4. Joel
    Joel avatar
    166 posts
    Member since:
    Oct 2006

    Posted 09 Jan 2008 Link to this post

    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
  5. Chavdar
    Admin
    Chavdar avatar
    898 posts

    Posted 09 Jan 2008 Link to this post

    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
  6. Joel
    Joel avatar
    166 posts
    Member since:
    Oct 2006

    Posted 09 Jan 2008 Link to this post

    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
  7. Joel
    Joel avatar
    166 posts
    Member since:
    Oct 2006

    Posted 09 Jan 2008 Link to this post

    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.
  8. Joel
    Joel avatar
    166 posts
    Member since:
    Oct 2006

    Posted 09 Jan 2008 Link to this post

    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 

  9. Joel
    Joel avatar
    166 posts
    Member since:
    Oct 2006

    Posted 09 Jan 2008 Link to this post

    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 

  10. Milen
    Admin
    Milen avatar
    163 posts

    Posted 10 Jan 2008 Link to this post

    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
  11. Joel
    Joel avatar
    166 posts
    Member since:
    Oct 2006

    Posted 10 Jan 2008 Link to this post

    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
Back to Top
DevCraft banner