AspAlliance.com LogoASPAlliance: Articles, reviews, and samples for .NET Developers
URL:
http://aspalliance.com/articleViewer.aspx?aId=1838&pId=-1
Geographic Data with Crystal Reports
page
by Jeff McWherter
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 26695/ 46

Introduction

In the past few years the ability to report on geographical data has become a task that does not require an army of developers to accomplish. Before the mapping functionality in Crystal Reports and other services, such as Google maps and the new Geography data types in SQL Server 2008, developers spent a great deal of time working to visualize geographical data on a map.

Crystal Reports has had mapping functionality built in for the past few versions. This functionality is provided from a third-party company named MapInfo. Currently, Crystal Reports contains a limited number of map types, but additional map types and "layers" can be purchased from MapInfo.

The default mapping functionality is also limited in what types of geographical data can be interpreted. Currently the default functionality can interpret state names/abbreviations, country names/abbreviations and limited city names. Additional functionality to support interpretation of geographical data, such as postal code and latitude/longitude points, can be purchased from MapInfo or a different tool can be used to render a map as an image and include it in the report, which we will discuss later in this article.

Using the Crystal Reports Map Expert

If you have ever added a chart to a Crystal Report, adding a map is a very similar concept.  Crystal Reports provides a tool called the "Map Expert" that will allow you to set the type of map, data and other options to help you render the map on in the report. The chart expert can be accessed from "Insert menu" by selecting the "Map" option.

Specifying Map Data

The "Data" tab of the Map Expert allows you to select which data you would like visualized in the map. This tab allows you to perform summary options such as a "count" and "Sum" for the values that are shown on the map. The summary options can be evaluated (calculated) on change of field in the provided set of data.

Figure 1: Data tab of the map expert

Setting the Map Type

The map "type" tab in the chart expert allows you to select which type of map will be rendered. By default, Crystal Reports supports three types: Ranged, Dot Density and graduated. MapInfo, the company that created the existing map functionary included in Crystal reports, provides other types of maps that can be purchased and integrated into Crystal Reports.

Figure 2: The Map Expert Type tab

Navigating the map

Crystal Reports provides functionality to allow the user to navigate the map through a few different interfaces. As with other types of Crystal Reports summaries, maps also support "drill down" navigation. Another very common navigation element of a Crystal Reports map is the ability to zoom in and out on map details. When a user views a map on a Crystal Report, they can click on the geographic region they would like to see more detail and the cursor then turns into a magnifying glass (or a finger cursor when the report is rendered on a web page) to allow the user to zoom in to see more detail.

The other navigation option that is very helpful is the "Map Navigator." The Map Navigator is a smaller representation of the map which allows the user to move the cursor to find a geographical region quickly. The Map Navigator is great for providing a navigation interface for large maps, such as world maps.

Figure 3: The Map Navigator

Data Mismatches

Sometimes data sets get passed to Crystal Reports with data that has not been cleaned, meaning data exists that Crystal Reports cannot process. For example, if a state name was misspelled or an uncommon abbreviation was used, the "Data Mismatch" tool will help resolve these issues.  The Data Mismatch tool can be found by Right clicking on the map and selecting "Resolve Mismatch."

Figure 4: Resolving data mismatches

Figure 5: Map created with Crystal Reports 2008 showing Customer Distribution

 

Beyond the Default Crystal Reports Map

Sometimes the mapping tools that are provided with Crystal Reports and MapInfo will not satisfy a particular business requirement. The maps included inside of Crystal Reports are functional and provide a very easy interface to render geographical data, but their appearance can leave something to be desired. Crystal Reports 2008 has responded and extends upon the existing Crystal mapping functionality, but there are still gaps for some companies. Sometimes having the ability to create maps that are aesthetically pleasing, like the maps in Figures 6 and 7, outweighs the ease of use of the Crystal Reports mapping functionality.

Figure 6: Map created with Dundas mapping control

Figure 7: Map created with .NET charting map control

There are many third party controls that will allow you to pass a set of data to the control, set a few options and the control will render a map. Controls such as .net Charting and Dundas provide a very powerful API to create maps that display complex data and are very stylish. Most of these third party mapping controls have the ability to save the map as an image, such as PDF, PNG or JPG. Since Crystal Reports XI, the Dynamic Image feature has allowed us to set the path of an image dynamically and, therefore, allows us to include charting images from 3rd party controls.

Using this pattern has some drawbacks with maps. Since the map created with the 3rd party control is an image, you do not gain navigation features such as zoom and pan, which you get by default when using the Crystal Reports mapping control.

Adding a dynamic image to your report

• Add an image to your report.

• Right click on the image and selected "Format Graphic."

• On the "Picture Tab," Click the formula button (X+2 button).

• Create a formula to pull the chart image path from the dataset.

 

 

 

 

 

 

Figure 8: Graphic location

 

Figure 9: Graphic location formula

http://aspalliance.com/ArticleFiles/1787/image011.jpg

Conclusion

The default mapping functionality that is built into Crystal Reports is a great place to start when you need to render geographical data in a report. We have learned in the article that the options that are included in the default controls are somewhat limited, but we have explored other sources that let us extend the mapping functionality to help meet specific particular business requirements.


Product Spotlight
Product Spotlight 

©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-04-18 4:24:06 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search