Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Web Design & Development > Adobe ColdFusion

This chapter is from the book

Dressing Up Your Charts

Building a chart and populating it with data is only half the battle. You also need to ensure that your chart tells the story that you want it to tell. ColdFusion's default settings usually get you reasonably close, but you'll find that you often need to make adjustments.

The <cfchartseries> tag offers eleven types of chart: bar, cylinder, horizontal bar, line, area, cone, pyramid, curve, step, and scatter. Your charts can be flat or three-dimensional. As you'll see in this section, selecting the proper chart type is one of the most important factors in determining whether your chart communicates your information clearly.

In addition to the chart's type, you can change almost any feature in your chart's appearance. You can change your chart's colors and fonts to integrate into your Web site's color scheme. You can adjust the grid's numbers to ensure that your chart makes sense.

To change a graph's grid values:

  1. Open the page you created in the last section, and preview the page in a browser. Notice that, by default, ColdFusion ends the y-axis with the largest value in the data set (Figure 13.9).

    Figure 13.9Figure 13.9 By default, the chart stops at the greatest value in the y-axis.


  2. In the <cfchart> tag, add this attribute and preview the change in your browser:

    scaleto="600"

    Notice that the graph's y-axis now scales to 600, giving the graph a less cluttered appearance (Figure 13.10).

    Figure 13.10Figure 13.10 The y-axis changes with the scaleto attribute.


    There's another problem with this graph, though: The numbers along the y-axis don't make much sense. Nobody really wants to see a grid line at 133.3 million.

    Telling Stories

    What does it mean to "tell a story" with a graph?

    Often, graphs are most useful when they communicate a change across some vector. In our Census example, you saw that it wasn't very informative to include a single population figure for one year in the United States. But a remarkable, visual story emerged when you included data for two regions over the next fifty years: By this projection, the population of the United States will overtake Western Europe sometime between 2025 and 2030, and the gap will continue to widen thereafter.

  3. In the <cfchart> tag, add this attribute and preview the change in your browser:

    gridlines="7"

    Figure 13.11 shows the <cfchart> tag with the newly added attributes. Notice that the y-axis numbers have changed to something more user-friendly: 100, 200, 300, etc (Figure 13.12). The gridlines attribute, naturally enough, specifies the number of lines in your grid. We set the number to 7 in order to get nice intervals up to a maximum value of 600. By setting the scaleto and gridlines attributes of the <cfchart> tag, you can make your graph much easier to read.

    Figure 13.11Figure 13.11 The code has scaleto and gridlines attributes.

    Figure 13.12Figure 13.12 Setting the gridlines attribute can make your graph easier to read.


  4. Save your file with a new name.

    As you work through this section, you'll be able to compare the different charts you've created.

Tips

  • Don't be confused by the way ColdFusion counts gridlines. The x-axis is included in the gridlines number. Thus, for a value of 600, we want seven gridlines: 0, 100, 200, 300, 400, 500, and 600.

  • We cheated a bit with the example in this section because we knew what our maximum value would be. As you'll see in the next section, you also can retrieve data from a query. This means that you won't know ahead of time the best values for your scaleto or gridlines attributes. By the time you finish this book, you should know enough ColdFusion to be able to set those values programmatically.

To change your chart's type:

  1. Open the file you created in the previous section if it isn't already open and, in the <cfchart> tag, add this attribute and then preview the page in your browser:

    show3d="yes"

    You'll see that your chart has taken on a three-dimensional appearance (Figure 13.13). Your charts can either be flat or 3-d. It's up to you to decide which appearance provides the most useful information.

    Figure 13.13Figure 13.13 You should choose to use a 3-D chart only when that format is best for presenting your data.


  2. Add this attribute to the <cfchart> tag and preview the change in your browser:

    format="jpg"

    You'll see that the chart is considerably less smooth than before.

  3. Change the format attribute back to Flash and save your file.

  4. Change the type attribute of both <cfchartseries> tags to bar and preview your page in a browser (Figure 13.14). You'll see that the bars for the United States obscure the bars for Western Europe. This problem also occurs when you set your type attribute to area (Figure 13.15).

    Figure 13.14Figure 13.14 A 3-D bar chart can hide your data if you're not careful...


    Figure 13.15Figure 13.15 ... so can a 3-D area chart.


  5. Change Western Europe's type attribute to curve.

  6. Cut your entire Western Europe <cfchartseries> and paste it before the United States <cfchartseries>. Figure 13.16 shows how the code should appear in Dreamweaver.

    Figure 13.16Figure 13.16 shows how the code should appear in Dreamweaver.


  7. Save your page and view it in your browser (Figure 13.17).

    Figure 13.17Figure 13.17 You can assign a different chart type to each chart series.


    By using a different chart Type for each series, and by changing the order in which the series appear, you've created a chart that clearly shows the demographic trends of each region. As you've seen, you can change your charts to tell almost any story you like.

  8. Try experimenting with the different attributes for the <cfchart> and <chartseries> tags to see which effects you can create.

    Fun with Chart Junk

    Charts can confuse just as easily as they can enlighten. Edward Tufte of Yale University has a name for the gimcracks and doodads that designers use to dress up graphs: "chart junk." Just because you can deck out your design with a hundred grid lines and lavender snowflakes doesn't mean you should. Instead, concentrate on presenting your data as simply and clearly as possible. If you'd like to learn more about information design, go to your local library and look for Edward Tufte's The Visual Display of Quantitative Information, Cheshire, CT: Graphics Press, 1992.

Tips

  • Would you prefer to de-emphasize Western Europe's shrinking population relative to the United States? Experiment with the seriesplacement attribute of the <cfchart> tag (Figure 13.18).

  • Be careful when changing your chart's colors. ColdFusion will generate an error when reading hexadecimal color values such as #0000FF. You can avoid this error by escaping the hash character; to do so add a second hash: ##0000FF. Note that the Tag Editor escapes the hashes for you.

    Figure 13.18Figure 13.18 Emphasize different data with the seriesplacement attribute.


  • By default, ColdFusion draws its charts using Flash. You can use the format attribute to specify flash, jpg, or png. Flash movies are generally clearer, with smaller file sizes, than jpgs. Your choice of format will depend on your target audience, and the medium in which your use your graph. Your users must have Flash 5 Player or higher installed to view the Flash files generated by <cfchart>.

  • Generating an area chart can consume a lot of your server's resources. If you plan to serve area charts to many site users, consider different strategies to lessen the load on the processor, including caching your charts with the CF Administrator or building your charts ahead of time. See Administering Charts in the ColdFusion MX Documentation.

Graphs in the Real World: A Case Study

In this section, you've seen how to build static charts to present more than one series of data. You've also seen how to clarify or obscure the information, depending on the story you want to tell. But how do these skills apply to you, a ColdFusion developer, in the real world?

Assume that you work at a large financial institution. Your boss comes to you Friday afternoon and says the following:

"We're at a crossroads as a lender. Although we operate in the United States and Western Europe, the last few years have been hard on us. We've decided we have the resources to offer new mortgages in only one market, and it's critical that we pick the market that's most likely to grow. This decision is for the long term and will influence the financial health of our institution over the next thirty to fifty years, not to mention your holiday bonus. I think we should focus on United States, but I need to persuade the board in a presentation later today. Put something together for me."

And she didn't even say please!

Mortgages are financial instruments that typically have a life of twenty to thirty years. Other things being equal, as a country's population grows, its demand for mortgages will grow as well. (More people need more houses, and more houses mean more people borrowing to pay for their houses).

After gathering your data, you could type a table that lists the projected population in Western Europe and the United States. In fact, you'd better do so because board members like to throw around numbers in order to sound authoritative. But look at the table on the left (Figure 13.19). It's good to have the information at hand, but it requires that you study the data yourself and try to understand what it means.

Figure 13.19Figure 13.19 Textual data has its purpose...


You quickly decide to build a graph to accompany your table. After experimenting with different graph types, you decide that a graph with one curve series and one area series tells a dramatic and simple story: Demand for mortgages in the United States will grow strongly over the next fifty years, while growth in Western Europe will stagnate and eventually decline (Figure 13.20). If you were giving the presentation, would you rather do so with or without the chart?

Figure 13.20Figure 13.20 but graphical data can quickly tell the story.


Peachpit Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from Peachpit and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about Peachpit products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites; develop new products and services; conduct educational research; and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email ask@peachpit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by Adobe Press. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.peachpit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020