Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

setting colorlist in pie chart

Guest
Apr 20, 2008 Apr 20, 2008
I built a likert survey with a scale of 1 to 5 - the old strongly disagree, disagree, neutral, agree, strongly agree thing. There are 20 statements in the likert survey. I am displaying the results in a pie chart using cfchart. The following is more of an annoyance than a problem. I have set my colorlist to be Yellow, Red, Green, Blue, Purple. This is great if each statement has a full range of responses of 1-5. Yellow will represent strongly disagree, Red - disagree, green- neutral, etc. However, if everyone responded to a statement with a 4 or 5, and there are no 1, 2, or 3's, then Yellow will represent Agree and Red - strongly agree for that question. Is there anyway to set the colorlist so that yellow will always represent strongly disagree? Here's a link to the results of the survey:

http://www.nyk12schools.com/results.cfm

If you scroll down, you'll see what I am talking about.

Thanks for the response and help.

Laurie
324
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Apr 20, 2008 Apr 20, 2008
One option is to determine the chart colors inside your query using a CASE statement. If you have several queries that utilize these same chart colors, you may wish to consider storing the colors in a database table instead.

<cfquery name="getResponses" ...>
SELECT CASE WHEN ResponseText = 'Strongly Agree' THEN 'Purple'
WHEN ResponseText = 'Agree' THEN 'blue'
WHEN ResponseText = 'Strongly Disagree' THEN 'red'
WHEN ResponseText = 'Disagree' THEN 'Yellow'
WHEN ResponseText = 'Neutral/No Opinion' THEN 'Green'
END AS ResponseColor,
... OtherColumns ...
FROM YourTable
WHERE ...
</cfquery>

Then pass the color list to your cfchartseries tag

<cfchartseries
type="pie"
query="getResponses"
colorlist="#valueList(getResponses.responseColor)#"
...
/>
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 20, 2008 Apr 20, 2008
Thank you, thank you, thank you! It was such an easy solution, but I guess I couldn't see the forest through the trees. I decided to put the colors in a database table I already had and presto, got the colors I wanted. I have to give a presentation using these pie charts next month. This will make it so much easier to read and understand. Thanks again!

Laurie
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Apr 21, 2008 Apr 21, 2008
Yes, it is nice when there is a simple solution. I am glad I could help :)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 21, 2008 Apr 21, 2008
LATEST
An FYI for anyone searching the forum for answers on how to use colors from a database to set the colorlist in a pie chart. Make sure you use the valuelist function.

For example, in your pie chart use colorlist="#valuelist(query.column)#"
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources