having a different color for each bar in a cfchart --- Try 2

Posted on 2005-04-27
Last Modified: 2013-12-24
Previously I was given an answer that was close to the solution that I wanted, but not exactly.
An example of a graph that I want is the following:
The count of hits on a homepage by month.
I want the graph to display the # of hits and months.
It should be a bar graph.
****The most important part is that all the bars should be different colors.****




                   RED          BLUE        GREEN               YELLOW
                  BAR            BAR          BAR                     BAR
                     JAN         FEB            MAR                APR

Hopefully it is more clear with my pathetic graph example.

Question by:parikaa
    LVL 35

    Expert Comment

    I do not understand - what did not work in the previous solution?

    If you do not specify the seriescolor at all then cold fusion automatically chooses a different color for each bar.  Using the mehtod I shoed you can specify colors for each series instead of letting CF pick the colors

    I am guessing that you treated all months as one series.  In that case they would all be the same color.

    You need to break it apart so that each month is a spearate series to get different colors.

         yaxistitle="Hit Count"
         <cfoutput query="MyQuery" group="Month">
              <cfchartseries type="bar" paintstyle="shade" serieslabel="#Month#">
                        <cfchartdata item="#Month#" value="#Hits#">
    LVL 5

    Author Comment

    Sir, it is one series though.
    When I do it as it is above then my graph has very narrow bars and they are placed ackwardly above the months
    with colored labels above the graph as well.  It seems to be making a simple graph into a more complicated one where the graph would have more than one piece of data for each month; this is not the case.
    If you could imagine the chart below as the chart I see, this is what's happening (bars above months misplaced):




               RED                  BLUE                  GREEN                      YELLOW
               BAR                  BAR                    BAR                           BAR      
                         JAN         FEB            MAR                APR
    LVL 35

    Accepted Solution

    CF has it so that one series is colored one color.

    If you want each month a separate color then they need to be treated as separate series.  This is the way coloring in CF works

    You can play with the labelling and scaling to get it the way you want, but I don't think you can tell cold fusion to color each datapoint within a series a different color.  At least not that I have seen.
    LVL 5

    Author Comment

    It makes sense for each series to have it own color.  Unfortuantely the company wants everything to look relatively the same as it did w/ the older version. I used your method and also changed the graph to be in 3-D format; it looks a lot nicer. Thanks again for the help .

    Expert Comment

    I've run into the same problem, and have a workaround.

    Basically I have a separate series for each bar (your months) with a different color.

    Then use stacked in the CFCHART: seriesPlacement="stacked", then the bars won't offset for each series.


    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
    If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    734 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

    17 Experts available now in Live!

    Get 1:1 Help Now