Populating different types of charts dynamically

Posted on 2007-10-08
Last Modified: 2011-10-03
My application stores the chart details like Title, Number of the charts, type of each chart, etc. onto a database table. For example,
Number of Charts : 2
Chart - 1 Title  :  Efficiency Comparison
Chart - 1 Type : Bar chart
Chart - 2 Title  :  Sector Allocation
Chart - 1 Type : Pie chart

At the time of report generation, it should be able to identify the type of the chart to draw, and the appropriate chart should be displayed. For example,
             Efficiency Comparison                             Sector Allocation
                   (Bar Chart)                                            (Pie Chart)

Question by:Yogeshup
    LVL 10

    Expert Comment

     str = "SELECT QUERY [select title and type of chart] FROM [tablename]"

                    DropDownList1.DataSource = [connectionstring]
                    DropDownList1.DataTextField = "title"
                    DropDownList1.DataValueField = "type"

    Then based on TYPE [in DataValueField], you can display different charts.
    LVL 42

    Expert Comment

    Are you trying to have crystal create a chart dynamically at runtime?  Afaik the object model doesn't support this.  You could create a report with different types of charts on it already and then conditionally suppress them at runtime so only the ones you need are visible.

    LVL 22

    Expert Comment

    Use a parameter to pass into the report the choice of which chart should be visible.

    Use the parameter in the suppress attribute expression of the chart or of the section within which it is placed to control which chart or section is visible.
    LVL 1

    Author Comment

    Hi Frodomam / IdoMillet,
    From your comments, i noticed that you have misunderstood my requirement. That is, you have thought based on one particular type of chart, the report will be generated dynamically with that chart type - by passing the chart type as a parameter, suppressing the sub-report. etc.

    But, my requirement is, i can have 'N' number of charts in the report created dynamically with appropriate chart-types. Hence, there can be a possibility of 4 pie charts in the same report or all different charts in a report, etc.

    Please advise us.
    LVL 42

    Expert Comment

    Perhaps I'm still not understanding but let me respond this way:

    There isn't a way to dynamically create reports at runtime so if you have a situation where you need 1 to n charts on your report the solution is to create n reports at design time and then at runtime suppress the ones that you don't need.  

    Another possibility is that you simply create multiple different reports - each formatted the way you need it - and then have your application determine which report should be loaded based on the chart(s) that you need to see.  This is probably going to be more efficient than generating a lot of charts that end up being suppressed.

    If this answer doesn't help you, can you explain a little more your needs - perhaps give 2 real world examples to help us understand what you're trying to accomplish?

    LVL 1

    Author Comment

    Here you are with my exact requirement of the application.

    The "Profitability Comparison" of 2 companies is to be shown in Line chart, whereas the "Cost Break-Up" is to be shown in Pie chart, and the "ROE & ROA comparison" is to be shown in Bar chart.

    Similar to this, there can be 'N' number of charts which is not defined in the design time (neither the type of charts nor the number of charts nor the order of placement too).

    At the querypad page of this report generation only, the user will specify the details of these charts - type, number and order.

    Hence, i could not design the all possible scenarios of charts in reports and suppress them at runtime. But hope this should be possible if we create the report itself dynamically at runtime. Please let me know how we can create the RPT file dynamically at runtime using Report Designer / CrystalReportViewer, etc.?
    LVL 100

    Expert Comment

    Crystal doesn't lend itself well to allowing the user to specify the requirements at that point.  

    What version of Crystal do you have?  If it is the version that comes with Visual Studio you may not be able to do it.  This will require runtime licenses for Crystal for all users and may even require all users to have Crystal installed.

    LVL 42

    Accepted Solution

    Hi Yogeshup,

    I understand your requirements, but as I've said you aren't going to be able to do that with Crystal.  You may want to consider using MS Reporting Services instead - you can build a completely dynamic report within your .Net app using MSRS.

    LVL 1

    Expert Comment

    Forced accept.

    EE Admin

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
    User art_snob ( encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now