Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
ALERT: QlikView server communication interruptions following Microsoft Windows Domain Controller security updates
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Calculated color for pie chart legends

I am using QlikView 11.2 SR 1.. I would like to show calculated color to legends displayed in pie chart... it seems that QlikView does not recognize calculated font color and always uses the last applied Fixed font color..

I am changing the font color settings in

Properties --> Presentation --> Settings --> Font --> Color

Can someone help?

thanks in advance!

Labels (1)
4 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

You can't assign font colors to individual categories in the legend. All the text in the legend will have the same color.

What you can do is create a fake legend from a straight table. See here for an example. You can click on the + in front of the dimension and choose Text Color and specify an expression to assign colors to the dimension values.


talk is cheap, supply exceeds demand
Not applicable
Author

well.. i am not looking for assigning differnet font color to individual legend in pie chart..

i have a variable as - vChartFontColor - which is modified based on some selections... and i would like to use this calculated color for all the legends in pie chart..

so for example, if select blue, all legend colors should be blue..

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

I think you're out of luck. The legend doesn't accept a calculated color, only fixed colors. Perhaps you can set it with a macro. There's an example in the api guide:

Sub SetLegendColors

set Graph = ActiveDocument.Sheets("Main").CreateBarChart

Graph.AddDimension "Product"

Graph.AddDimension "Region"

Graph.AddExpression "sum(Sales)"

set p = Graph.GetProperties

set leg = p.ChartProperties.Legend

leg.BgColor.PrimaryCol.IsCalculated = false

leg.BgColor.PrimaryCol.Col = RGB(255,0,0)   'red

leg.TextColor.PrimaryCol.IsCalculated = false

leg.TextColor.PrimaryCol.Col = RGB(0,255,0)    'green

Graph.SetProperties p

   

end sub


talk is cheap, supply exceeds demand
Not applicable
Author

thanks Gysbert..

I tried using below macro.. but it fails at the line which is marked in bold... how do I evaluate the variable varVal to color object so that it can be assigned to PrimaryCol.Col ?!

Sub SetLegendColors

    set Graph = ActiveDocument.GetSheetObject("CH167")

    set p = Graph.GetProperties

    set leg = p.ChartProperties.Legend

    set v = ActiveDocument.GetVariable("vChartFontColor")

    varVal = v.GetContent.String

    msgbox(varVal)

    leg.TextColor.PrimaryCol.Col = varVal

    Graph.SetProperties p

end sub