BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
CousinIt
Fluorite | Level 6

Hello! In VA, how do I create a bar chart with each bar having a different color? In the picture, the x-axis range from "11" (bad) to "1" (good).... and I'd like to add a color gradation dimension to my visualization.... say make "11" red and slowly change the bars in color to a green "1". Is this possible in VA? Thanks in advance for everyone's reply!! I'm hoping someone has done this before and will be able to assist me. Thank you in advance for your assistance!

1 ACCEPTED SOLUTION

Accepted Solutions
Sam_SAS
SAS Employee

Hello,

 

You can make a bar chart with a Color role by using SAS Graph Builder (select Build Custom Graphs from the top left menu). Then, you can import the custom graph into your report:

 

custom.png

 

If you want the same measure to be used for both the bar height and the bar color, you can change those roles to a single shared role in Graph Builder.

custom2.png

 

 

I don't think you can easily change the gradient fill colors for a bar chart, however. You can set the gradient colors by making a custom theme, but I think this would apply to every object in your report? I don't have much experience with this and I might be wrong.

 

A different approach would be to make a series of display rules to color the bars, but you would have to hard-code the interval values.

 

Let us know if that helps,

Sam

View solution in original post

11 REPLIES 11
Sam_SAS
SAS Employee

Hello,

 

You can make a bar chart with a Color role by using SAS Graph Builder (select Build Custom Graphs from the top left menu). Then, you can import the custom graph into your report:

 

custom.png

 

If you want the same measure to be used for both the bar height and the bar color, you can change those roles to a single shared role in Graph Builder.

custom2.png

 

 

I don't think you can easily change the gradient fill colors for a bar chart, however. You can set the gradient colors by making a custom theme, but I think this would apply to every object in your report? I don't have much experience with this and I might be wrong.

 

A different approach would be to make a series of display rules to color the bars, but you would have to hard-code the interval values.

 

Let us know if that helps,

Sam

CousinIt
Fluorite | Level 6
Thank you very much!!
Teo_ita
Calcite | Level 5

Hi Sam!

could you kindly pass me some examples about this?
In particular, I can't insert different colors for the bar graph with the trend:

image (6).png

is it possible to do it like this?

image (5).png

thx a lot!

Sam_SAS
SAS Employee

Hello @Teo_ita,

If I understand correctly, it looks like you want to create a color-mapped display rule for a bar-line chart, using the category that is assigned to the Lattice Columns role (Priorita in your example below.) Is that right?

 

You can create such a display rule for a regular bar chart, but it looks like this is not supported for a bar-line chart (or a custom graph with those elements). I will investigate to see whether the documentation for display rules should be updated.

 

Thanks,

Sam

Teo_ita
Calcite | Level 5
Yeah, yeah, that's right... You understand very well

I can't do it: it doesn't give me the possibility to create Rules on the
Category, but only on the Measures, why?
[image: image.png]
only this one:
[image: image.png]
Is there any configuration and/or variable assignment problem?
How do you create a Display Rule for a Category data item?



Sam_SAS
SAS Employee

I think it is just a limitation of the software. I am not a developer but I seem to understand there are difficulties applying display rules for a category when there are multiple response (measure) variables.

 

The documentation says:

  • Color-mapped display rules are not applied if there are two measures assigned to the same axis.

I suspect that this is the same limitation you are seeing for bar-line charts and the doc should be phrased differently. I will look into that.

 

You can create a feature request here:

https://communities.sas.com/t5/SASware-Ballot-Ideas/idb-p/sas_ideas/label-name/sas%20visual%20analyt...

It is possible that a request already exists for this. All feature requests are reviewed by the product management team.

 

Thanks,

Sam

BrunoMueller
SAS Super FREQ

It is possible when you use "Build Custom Graph"

Bruno_SAS_0-1672754616413.png

Here are the steps I used:

  • create a new empty custom graph
  • add a bar chart
  • add a line chart
  • add a new data lattice role
    Bruno_SAS_5-1672755114531.png

     

  • In the options for "A1", the first cell, change the setting for
    Bruno_SAS_1-1672754750523.png

     

  • In the options for the line chart, change the color for the line

    Bruno_SAS_2-1672754827922.png

     

  • In the options for the bar chart, switch on data labels

    Bruno_SAS_3-1672754885605.png

     

  • save the custom graph template
  • import it in the objects pane
  • now you can assign display rules
    Bruno_SAS_4-1672755006961.png

     

Give it a try.

 

 

 

Sam_SAS
SAS Employee

@BrunoMueller I was able to get your version working in Viya 4. When I tried it before, it didn't work. I guess that the options you specified in the custom graph are critical for the display rules to work.

 

@Teo_ita , let us know if you are able to get this working.

 

Thanks,

Sam

Teo_ita
Calcite | Level 5

Hi Bruno, thx!

but I can't do what you tell me...

I have Viya 3.4 and I don't have '...the options for the line chart, change the color for the line'

graf1.jpg

 

but I solved it by using Display Rules and creating a Numeric variable from my Category variable...
A thousand thanks!

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
Tips for filtering data sources in SAS Visual Analytics

See how to use one filter for multiple data sources by mapping your data from SAS’ Alexandria McCall.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 11 replies
  • 2199 views
  • 4 likes
  • 5 in conversation