16 Replies Latest reply: May 20, 2016 1:26 AM by Pranjal Gharat RSS

    How to define Chart colours

      Dear community,

       

      another rahter basic question for you,

       

      I am trying to analyse the colours of the Bikes i sel in a Pie Chart,

      The values in the "colour" field are of course: 'black','pink','white etc....

       

      Now when i have a chart of COURSE i want the chart segments to have exactly that colour and not blue for 'black'

       

      I guess this is really easy but i have no idea how to do this

       

      Thanx for your help

      Seb

        • Re: How to define Chart colours
          Jonathan Dienst

          Hi

           

          You could apply the colours like this. Click the + next to the expression in the Expression tab. Then enter the following colour expression:

           

          =pick(match(Colour, 'black', 'white', 'pink', ...etc), RGB(0,0,0), White(), RGB(128, 0, 0), ...etc)

           

          Hope that helps

          Jonathan

          • Re: How to define Chart colours

            Hi,

             

            Go to properties of the chart object and go to colors tab.

             

            For Eg:

             

            if you are using pie chart and it having 6 different value in one dimension.

             

            Jan,Feb,March,April,May and June.

             

            If you want to change the color , you have to change the (Colors 1-6) in Data Appearance in "Color tab". Just click the color which you don't want and change the color and click apply.

             

            Hope it will help you,

            Selva

            • Re: How to define Chart colours
              Jose Tos

              You can change the colours in the properties of the graphic, 'Colour' sheet, so I think you need to have all the colurs in the chart, put them in the same order of your colours in the properties and select de checkbox Persistent colours

               

              Tell me if this works.

               

              Regards

              • Re: How to define Chart colours
                John Witherspoon

                I suggest building a table for the colors instead of handling it in expressions.  You're surely going to want these colors in multiple places, which means repeating the expression.  You could create a variable to hold the expression and use the variable, but I'd build a color table instead.  I just think it's cleaner, and would allow you to load colors from an external source like a spreadsheet if desired.  It requires script access and a reload to change, of course, which might occasionally be an issue.

                 

                The attached example allows you to explicitly assign colors to customers by RGB values, and then automatically builds random colors for any customers you didn't assign.  You don't want the random color part in this case, so skip that and make certain that all colors are assigned.

                 

                The color expressions in these charts are also more complicated than you'd likely need.  All you'd need is rgb(R,G,B) in most cases.  These charts were doing more complicated things like highlighting the weekday data.

                 

                Edit: Ooops, sorry, I see you're in personal edition.  I'll make another edit to tell you all the relevant information.

                 

                Edit 2: Actually, rather than describe the example I posted, let me just give you what I think you should do.  Consider a spreadsheet instead of an inline load, but here's the idea.  In the script:

                 

                [Colours]:
                LOAD * INLINE [
                colour,R,G,B
                Red,255,0,0
                Pink,255,150,150
                Green,0,255,0
                etc.
                ];

                 

                Then in the chart, in the background colour expression:

                 

                rgb(R,G,B)

                  • Re: How to define Chart colours
                    Pranjal Gharat

                    Hi John,

                     

                    This is great!!.

                     

                    We have similar scenario where we are applying colors to charts using ColorTable.

                     

                    We have two tables in QV

                    Data table with all facts and dimensions

                    ColorT table with mapping dimension and RGB values

                     

                    1.JPG

                     

                    ColorT table doesn't have all the values from my dimension column hence it will apply colors to values which are present in ColorT table.

                     

                    After applying formula in background color:

                    =RGB(R,G,B)

                    2.JPG

                     

                     

                    We need to change the color for other values to default colors.

                     

                    Could you please help us to tackle this?

                      • Re: How to define Chart colours
                        John Witherspoon

                        Maybe something like if(R+G+B,rgb(R,G,B)). As long as you assign null to the color, it should use the defaults.

                         

                        However, if you look closely at the example, I gave an arguably more robust solution to the same problem, which was to assign random colors to values that you haven't assigned explicit colors to. That way you're still using the same colors for those values across charts, even when you don't know what the values will be ahead of time to explicitly assign colors to them. On the down side, random colors won't always look very good, but if you reload the example over and over, I think the way I assigned random colors produces pretty good results for customers D & E.