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

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

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.****

600

400

200

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

Hopefully it is more clear with my pathetic graph example.


Thanks
0
parikaa
Asked:
parikaa
  • 2
  • 2
1 Solution
 
mrichmonCommented:
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.

<cfchart
     chartheight="600"
     chartwidth="750"
     yaxistitle="Hit Count"
     format="jpg"
     scalefrom="0"
     scaleto="300"
     gridlines="13">
     <cfoutput query="MyQuery" group="Month">
          <cfchartseries type="bar" paintstyle="shade" serieslabel="#Month#">
               <cfoutput>
                    <cfchartdata item="#Month#" value="#Hits#">
               </cfoutput>
          </cfchartseries>
     </cfoutput>
</cfchart>
0
 
parikaaAuthor Commented:
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):


600

400

200

0
           RED                  BLUE                  GREEN                      YELLOW
           BAR                  BAR                    BAR                           BAR      
_____________________________________________________________
                     JAN         FEB            MAR                APR
0
 
mrichmonCommented:
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.
0
 
parikaaAuthor Commented:
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 .
0
 
blacksquareCommented:
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.



0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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