Link to home
Start Free TrialLog in
Avatar of parikaa
parikaaFlag for United States of America

asked on

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
Avatar of mrichmon
mrichmon

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>
Avatar of parikaa

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of mrichmon
mrichmon

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of parikaa

ASKER

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