• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 759
  • Last Modified:

Populating different types of charts dynamically

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)

1 Solution
 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.
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.

Ido MilletProfessor of MIS at Penn State Erie and Owner, Millet SoftwareCommented:
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.
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

YogeshupAuthor Commented:
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.
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?

YogeshupAuthor Commented:
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.?
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.

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.

Forced accept.

EE Admin
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now