Blue Theme Orange Theme Green Theme Red Theme
 
Team Foundation Server Hosting
Home | Forums | Videos | Advertise | Certifications | Downloads | Blogs | Interviews | Jobs | Beginners | Training
 | Consulting  
Submit an Article Submit a Blog 
 Jump to
Skip Navigation Links
TechnologyExpand Technology
WebsiteExpand Website
DevExpress UI Controls
Search :       Advanced Search »
Home » Crystal Reports C# » Tip: How to change the text of Legends in Crystal Reports?

Tip: How to change the text of Legends in Crystal Reports?

This tip shows you how to change the text of Legends in Crystal Reports?

Author Rank :
Page Views : 37178
Downloads : 0
Rating :
 Rate it
Level : Beginner
   Print Read/Post comments Post a comment  Similar Articles  
   Email to a friend  Bookmark  Author's other articles  
 
DevExpress Free UI Controls
Become a Sponsor
Discover the top 5 tips for understanding .NET Interop
Become a Sponsor
 Tag Cloud
 Latest Jobs
More ... 
 Latest Interview Questions
More ... 


More and more I use Crystal Reports, my Sucker Level of the product (Crystal Reports, da...) is rising exponentially.

If you generate a report from a database command, XML document, or XML schema, and add a chart to the report, CR generates chart and legends automatically. In legends, it adds the table column names, which you select to get the data from.

If you use ADO.NET DataSet document (XML or .xsd files), the legend names would look like DataTableName.ColumnName for all columns you are using in the chart. Now if you want to change this default legend's text, you are out of luck. At least I wasn't able to figure it out.

After spending half a day, I gave up and came up with couple of workarounds. One was, being a GDI+ expert, I could create my own graphics which looks like legends. Alternatively, the easy approach was, create a box and color is what color your chart bars are and put a text box side by side with the name of the column. For example, if your database column names are Column1, Column2 and Column3 but you want your data legend names Fall, Summer, and Winter, you create three boxes with the color of chart bars and put TextBox with text Fall, Summer, and Winter.

This approach worked for me. If you find a better way, don't forget to share with us.

Comment Request!
Thank you for reading this post. Please post your feedback, question, or comments about this post Here.
Login to add your contents and source code to this article
 [Top] Rate this article
 
 About the author
 
Mahesh Chand
Mahesh is the founder of C# Corner and Mindcracker Network, an author of several .NET programming books and a Microsoft MVP for 6 consecutive years. In his day to day work, Mahesh is a Senior Software Consultant with over 14 years of IT industry experience building systems for Financial and Banking, Engineering & Architectural, Imaging, Construction, Biological & Pharmaceuticals, Healthcare and Education industries. His expertise is Windows Forms, ASP.NET, Silverlight, WPF, WCF, Visual Studio 2010, SQL Server, and Oracle.  If you are looking for a Sharepoint, Windows Forms, ASP.NET, WPF, Silverlight, C#, VB.NET, Oracle, and SQL Server Consultant in Philadelphia area or remote location, drop me a line at MAHESH [AT] C-SHARPCORNER [DOT] COM.
Looking for C# Consulting?
C# Consulting is founded in 2002 by the founders of C# Corner. Unlike a traditional consulting company, our consultants are well-known experts in .NET and many of them are MVPs, authors, and trainers. We specialize in Microsoft .NET development and utilize Agile Development and Extreme Programming practices to provide fast pace quick turnaround results. Our software development model is a mix of Agile Development, traditional SDLC, and Waterfall models.
Click here to learn more about C# Consulting.
 
Introducing MaxV - one click. infinite control. Hyper-V Hosting from MaximumASP.
Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Dynamic PDF
ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
Discover the top 5 tips for understanding .NET
Ricky Leeks presents the top 5 tips for understanding .NET Interoperability. Learn more.
Nevron Chart for .NET 2010.1 Now Available
The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
ASP.NET 4 Hosting
Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites – Click Here!
 
 Post a Feedback, Comment, or Question about this article
Subject:
Comment:
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor
 Comments
Question regarding text of Legend in Crystal Reports by usamaalam On April 10, 2007
I have a pie chart with dynamic pies generated based on the data. Is there a way to format the legend for this case? Thanks.
Reply | Email | Modify 
Re: Question regarding text of Legend in Crystal Reports by Mahesh On April 11, 2007
If you are just planning to change the colors and fonts, I believe it can be done using formulae.
Reply | Email | Modify 
Response From Crystal by Patrick On August 13, 2007

Comments from Business Objects between the HRs below.


Please note that there is no option available in chart to change the legend text label at design time. In Crystal Report Standalone designer (Crw32.exe), after previewing the report, we can edit the text label by right clicking on the legend label.

Please note that in .NET Crystal Report Viewer Control, we can only view the report and cannot make any changes so it is not possible to change the legend text.


What I ended up doing was creating a set of reporting tables in SQL. No longer using the XML. I tried using a mix of the XML loaded in a dataset and another connection to SQL just for charts but it did not work.

You want to talk about "suck" level, this is a 10+

SURFThru.com


Reply | Email | Modify 
Solution by Patrick On August 27, 2007

I found a work around where I threw Crystal pie charts in the garbage.

I use Infragistics in my application. What I do now is I render a web page at report run time. This page has an Infragistics Pie Chart on it built from data I pull from SQL Server. I scrape this page to find the image name, upload the images to SQL Server. Now I have wonderful dynamic pie charts in my crystal report. The second advantage of this method is that the only table you need on the report is the table that holds the image. Less code and the results blow Crystal pie charts away.

This can also be done using a free chart product on the link below.

http://www.stickler.de/PieChart.aspx

If you are interested in the code to do this work use my contact page at my web site.  http://www.SURFThru.com

 

Reply | Email | Modify 
Re: Solution by smitha On January 29, 2009

As you have said i also customized the legends with the help of the Text Boxes.But the problem what i am facing now is that when i export the graph in to excel both the Graph and Text boxes(Used Legends )  acting as two different images. i would like to behave the added text box  as the way how the default legend behaves ie both as one image.

Reply | Email | Modify 
How to Format the Legend in Chart by Pradip On August 30, 2007
I am developing a pie chart having the X-axis and Y-Axis values as X- axis Y-Axis Site1 2000 Site2 3000 Site3 4000 Total 9000 The data is in DataTable, having all four rows. While creating pie chart I bind the table directly to chart but my requirement is I don’t want to bind last row to chart but the total should be displayed at Legend. One more thing is that I want to format the Y-Axis values at Legend; 1000 should be displayed as 1,000 and 100000 should be as 100,000. Thanks and Regards Pradip.
Reply | Email | Modify 
Solution for full version by Ashutosh On April 5, 2009
see the comment by "hi_its_its" (me) http://social.microsoft.com/Forums/en-US/vscrystalreports/thread/de18e72f-4cfb-403f-87ef-d970d8061c93/
Reply | Email | Modify 
Mindcracker MVP Summit 2012
 © 2012  contents copyright of their authors. Rest everything copyright Mindcracker. All rights reserved.