<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Color assignment in graphs in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Color-assignment-in-graphs/m-p/1837613#M69232</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;I was taking a look at this interesting use case scenario and I was able to find a workaround that might work for you. You are right that if you have a lot of data, you will notice that the colors are repeated and I can see how this can be a confusion when you filter data and the fields with the same color appear side by side. In my workaround, I have used the function&amp;nbsp;&lt;STRONG&gt;&lt;SPAN style="color:#27ae60"&gt;RGB()&lt;/SPAN&gt;&amp;nbsp;&lt;/STRONG&gt;[1], and through the script I was able to generated different random combinations of colors for each ID.&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;For example this is my load script:&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="color:null"&gt;&lt;STRONG&gt;Data:&lt;BR /&gt;
LOAD&lt;BR /&gt;
&amp;nbsp; &amp;nbsp; OrderID,&lt;BR /&gt;
&amp;nbsp; &amp;nbsp; LineNo,&lt;BR /&gt;
&amp;nbsp; &amp;nbsp; ProductID,&lt;BR /&gt;
&amp;nbsp; &amp;nbsp; UnitPrice,&lt;BR /&gt;
&amp;nbsp; &amp;nbsp; Quantity,&lt;BR /&gt;
&amp;nbsp; &amp;nbsp; Discount&lt;BR /&gt;
FROM [...]&lt;BR /&gt;
(...);&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;As you can see, it is a dataset with data for orders. Now I want to present my data in Charts and at the same time have a different color based on the &lt;STRONG&gt;LineNo &lt;/STRONG&gt;field, so I will create a table that will have all the unique &lt;STRONG&gt;LineNo&lt;/STRONG&gt; IDs and each ID will be associated with a particular color.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;So first I am creating a temporary table with all the unique IDs:&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="color:null"&gt;&lt;STRONG&gt;TempIds:&lt;BR /&gt;
LOAD&lt;BR /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;Distinct LineNo as LineNo&lt;BR /&gt;
Resident Data;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Now I will create a new &lt;STRONG&gt;Colors &lt;/STRONG&gt;table which will contain the unique IDs with the random generated values R, G, B:&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="color:null"&gt;&lt;STRONG&gt;Colors:&lt;BR /&gt;
Load&lt;BR /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;LineNo,&lt;BR /&gt;
&amp;nbsp; &amp;nbsp; Floor(Rand() * 256) as R,&lt;BR /&gt;
&amp;nbsp; &amp;nbsp; Floor(Rand() * 256) as G,&lt;BR /&gt;
&amp;nbsp; &amp;nbsp; Floor(Rand() * 256) as B&lt;BR /&gt;
Resident TempIds;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="color:null"&gt;And then I will drop the temporary table as it is no longer needed:&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Drop Table TempIds;&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;This process will generate a table that is associated with your data table and will contain the following data:&lt;/P&gt;

&lt;P&gt;&lt;IMG src="https://lithium-response-prod.s3.us-west-2.amazonaws.com/qlik.response.lithium.com/RESPONSEIMAGE/3ad0add4-9fb9-4eb5-946e-c3936c223ba7.default.PNG" /&gt;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Then you can create a Bar chart and specify the following details:&lt;/P&gt;

&lt;OL&gt;
 &lt;LI&gt;Under &lt;STRONG&gt;Appearance &amp;gt; Colors and Legends&lt;/STRONG&gt;, un-toggle the Colors option&lt;/LI&gt;
 &lt;LI&gt;Then from the drop down menu, choose "&lt;STRONG&gt;By Expression&lt;/STRONG&gt;"&lt;/LI&gt;
 &lt;LI&gt;Inside the expression you can put "&lt;STRONG&gt;=RGB(R,G,B)&lt;/STRONG&gt;"&lt;/LI&gt;
 &lt;LI&gt;And make sure to check "&lt;STRONG&gt;The expression is a color code&lt;/STRONG&gt;"&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;The results are:&lt;/P&gt;

&lt;P&gt;&lt;IMG src="https://lithium-response-prod.s3.us-west-2.amazonaws.com/qlik.response.lithium.com/RESPONSEIMAGE/6bd7cda0-7f51-4582-bd37-4c94aee90fe2.default.PNG" /&gt;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;And since there are many combinations with the RGB codes, it will be very difficult to get an occasion where the color is exactly the same with another field. Additionally, this means that the colors are not repeated, no matter how many values you have.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;I hope that this information was helpful&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;---&lt;/P&gt;

&lt;P&gt;[1]&amp;nbsp;&lt;A href="https://help.qlik.com/en-US/sense/August2021/Subsystems/Hub/Content/Sense_Hub/ChartFunctions/ColorFunctions/RGB.htm" target="_blank"&gt;https://help.qlik.com/en-US/sense/August2021/Subsystems/Hub/Content/Sense_Hub/ChartFunctions/ColorFunctions/RGB.htm&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 20 Sep 2021 14:11:06 GMT</pubDate>
    <dc:creator>Andrei_Cusnir</dc:creator>
    <dc:date>2021-09-20T14:11:06Z</dc:date>
    <item>
      <title>Color assignment in graphs</title>
      <link>https://community.qlik.com/t5/App-Development/Color-assignment-in-graphs/m-p/1837573#M69223</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;For a graph that I have, we have more then 100 products. If I understood correctly, Qlik only assigns 100 different colors unless you take the time in giving each value a different color making use of a master Item.&amp;nbsp;&lt;BR /&gt;For the big picture it isn't that kind of a big deal, but when you make some selections, we have the problem that sometimes, different values use the same color.&amp;nbsp;&lt;BR /&gt;Is there a way that Qlik like change the colors it assigned at first when making some kind of selections so that if the filter narrows the products down to less then 100, they all have a different color?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you all for your help.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Sep 2021 12:24:54 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Color-assignment-in-graphs/m-p/1837573#M69223</guid>
      <dc:creator>quintansjoel</dc:creator>
      <dc:date>2021-09-20T12:24:54Z</dc:date>
    </item>
    <item>
      <title>Re: Color assignment in graphs</title>
      <link>https://community.qlik.com/t5/App-Development/Color-assignment-in-graphs/m-p/1837613#M69232</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;I was taking a look at this interesting use case scenario and I was able to find a workaround that might work for you. You are right that if you have a lot of data, you will notice that the colors are repeated and I can see how this can be a confusion when you filter data and the fields with the same color appear side by side. In my workaround, I have used the function&amp;nbsp;&lt;STRONG&gt;&lt;SPAN style="color:#27ae60"&gt;RGB()&lt;/SPAN&gt;&amp;nbsp;&lt;/STRONG&gt;[1], and through the script I was able to generated different random combinations of colors for each ID.&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;For example this is my load script:&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="color:null"&gt;&lt;STRONG&gt;Data:&lt;BR /&gt;
LOAD&lt;BR /&gt;
&amp;nbsp; &amp;nbsp; OrderID,&lt;BR /&gt;
&amp;nbsp; &amp;nbsp; LineNo,&lt;BR /&gt;
&amp;nbsp; &amp;nbsp; ProductID,&lt;BR /&gt;
&amp;nbsp; &amp;nbsp; UnitPrice,&lt;BR /&gt;
&amp;nbsp; &amp;nbsp; Quantity,&lt;BR /&gt;
&amp;nbsp; &amp;nbsp; Discount&lt;BR /&gt;
FROM [...]&lt;BR /&gt;
(...);&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;As you can see, it is a dataset with data for orders. Now I want to present my data in Charts and at the same time have a different color based on the &lt;STRONG&gt;LineNo &lt;/STRONG&gt;field, so I will create a table that will have all the unique &lt;STRONG&gt;LineNo&lt;/STRONG&gt; IDs and each ID will be associated with a particular color.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;So first I am creating a temporary table with all the unique IDs:&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="color:null"&gt;&lt;STRONG&gt;TempIds:&lt;BR /&gt;
LOAD&lt;BR /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;Distinct LineNo as LineNo&lt;BR /&gt;
Resident Data;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Now I will create a new &lt;STRONG&gt;Colors &lt;/STRONG&gt;table which will contain the unique IDs with the random generated values R, G, B:&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="color:null"&gt;&lt;STRONG&gt;Colors:&lt;BR /&gt;
Load&lt;BR /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;LineNo,&lt;BR /&gt;
&amp;nbsp; &amp;nbsp; Floor(Rand() * 256) as R,&lt;BR /&gt;
&amp;nbsp; &amp;nbsp; Floor(Rand() * 256) as G,&lt;BR /&gt;
&amp;nbsp; &amp;nbsp; Floor(Rand() * 256) as B&lt;BR /&gt;
Resident TempIds;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="color:null"&gt;And then I will drop the temporary table as it is no longer needed:&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Drop Table TempIds;&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;This process will generate a table that is associated with your data table and will contain the following data:&lt;/P&gt;

&lt;P&gt;&lt;IMG src="https://lithium-response-prod.s3.us-west-2.amazonaws.com/qlik.response.lithium.com/RESPONSEIMAGE/3ad0add4-9fb9-4eb5-946e-c3936c223ba7.default.PNG" /&gt;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Then you can create a Bar chart and specify the following details:&lt;/P&gt;

&lt;OL&gt;
 &lt;LI&gt;Under &lt;STRONG&gt;Appearance &amp;gt; Colors and Legends&lt;/STRONG&gt;, un-toggle the Colors option&lt;/LI&gt;
 &lt;LI&gt;Then from the drop down menu, choose "&lt;STRONG&gt;By Expression&lt;/STRONG&gt;"&lt;/LI&gt;
 &lt;LI&gt;Inside the expression you can put "&lt;STRONG&gt;=RGB(R,G,B)&lt;/STRONG&gt;"&lt;/LI&gt;
 &lt;LI&gt;And make sure to check "&lt;STRONG&gt;The expression is a color code&lt;/STRONG&gt;"&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;The results are:&lt;/P&gt;

&lt;P&gt;&lt;IMG src="https://lithium-response-prod.s3.us-west-2.amazonaws.com/qlik.response.lithium.com/RESPONSEIMAGE/6bd7cda0-7f51-4582-bd37-4c94aee90fe2.default.PNG" /&gt;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;And since there are many combinations with the RGB codes, it will be very difficult to get an occasion where the color is exactly the same with another field. Additionally, this means that the colors are not repeated, no matter how many values you have.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;I hope that this information was helpful&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;---&lt;/P&gt;

&lt;P&gt;[1]&amp;nbsp;&lt;A href="https://help.qlik.com/en-US/sense/August2021/Subsystems/Hub/Content/Sense_Hub/ChartFunctions/ColorFunctions/RGB.htm" target="_blank"&gt;https://help.qlik.com/en-US/sense/August2021/Subsystems/Hub/Content/Sense_Hub/ChartFunctions/ColorFunctions/RGB.htm&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Sep 2021 14:11:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Color-assignment-in-graphs/m-p/1837613#M69232</guid>
      <dc:creator>Andrei_Cusnir</dc:creator>
      <dc:date>2021-09-20T14:11:06Z</dc:date>
    </item>
    <item>
      <title>Re: Color assignment in graphs</title>
      <link>https://community.qlik.com/t5/App-Development/Color-assignment-in-graphs/m-p/1837837#M69246</link>
      <description>&lt;P&gt;This works, thanks.&lt;BR /&gt;Although it deletes the legend from the graph. Do you maybe know a way so that I can still display the legend and have different colors?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Sep 2021 08:03:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Color-assignment-in-graphs/m-p/1837837#M69246</guid>
      <dc:creator>quintansjoel</dc:creator>
      <dc:date>2021-09-21T08:03:52Z</dc:date>
    </item>
    <item>
      <title>Re: Color assignment in graphs</title>
      <link>https://community.qlik.com/t5/App-Development/Color-assignment-in-graphs/m-p/1838614#M69350</link>
      <description>&lt;P&gt;I am glad that it helped you achieve the outcome that you were looking for. Regarding the legend, you are absolutely right that it is hidden with this option. I was checking if there is any way of having the legend there, but I was unable to do so. I have noticed that:&lt;/P&gt;

&lt;UL&gt;
 &lt;LI&gt;For&lt;STRONG&gt; &lt;SPAN style="color:#2980b9"&gt;Single color&lt;/SPAN&gt; &lt;/STRONG&gt;the legend is hidden, because there is no use of it. Since there is only one color displayed.&lt;/LI&gt;
 &lt;LI&gt;For&lt;SPAN style="color:#2980b9"&gt; &lt;STRONG&gt;By dimension&lt;/STRONG&gt;&lt;/SPAN&gt; the legend is present and you get the option to disable it, if needed. Because now each color represents a different dimension value.&lt;/LI&gt;
 &lt;LI&gt;For&lt;SPAN style="color:#2980b9"&gt; &lt;STRONG&gt;By measure&lt;/STRONG&gt;&lt;/SPAN&gt;, the legend is present and you also get the option to disable it, if needed. Because each color represents a different range.&lt;/LI&gt;
 &lt;LI&gt;For &lt;SPAN style="color:#2980b9"&gt;&lt;STRONG&gt;By expression&lt;/STRONG&gt;&lt;/SPAN&gt;, the only options that you have is to set the expression and to set whether the expression is a color or no. You can enable the legend, but only by changing the option "The expression is a color code" off. This means that if you are specifying the color of the bars in the expression then Qlik Sense can't know which values you are representing. This is mainly, because expressions can also be super complicated and can have multiple if conditions. I believe this is the reason that this is not supported and this is a feature request that you can submit by following article [1].&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;One workaround that you can implement, which is not an optimal solution but it works, is to have a combination of the chart with the Table chart that will act as a legend. In the Table chart you can add the same Dimension as the other chart and in the properties of the dimension you can set the "Background color" to "=RGB(R,G,B)" again. This will mean that you can easily see the value and the color that is representing that value. Even if you do some selections, the Table chart will be updated as well.&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;For example:&lt;/P&gt;

&lt;P&gt;&lt;IMG src="https://lithium-response-prod.s3.us-west-2.amazonaws.com/qlik.response.lithium.com/RESPONSEIMAGE/c47cff6d-9a45-4813-8d50-d893403463ac.default.PNG" /&gt;&lt;/P&gt;

&lt;P&gt;and with selected values:&lt;/P&gt;

&lt;P&gt;&lt;IMG src="https://lithium-response-prod.s3.us-west-2.amazonaws.com/qlik.response.lithium.com/RESPONSEIMAGE/5af80b73-bbf2-4c07-a9aa-ed7729c6d863.default.PNG" /&gt;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;I hope that this information was helpful!&amp;nbsp;&lt;/P&gt;

&lt;P&gt;---&lt;/P&gt;

&lt;P&gt;[1]&amp;nbsp;&lt;A href="https://community.qlik.com/t5/Knowledge-Base/How-To-Submit-Feature-Requests-For-Qlik-Products/ta-p/1712581" target="_blank"&gt;https://community.qlik.com/t5/Knowledge-Base/How-To-Submit-Feature-Requests-For-Qlik-Products/ta-p/1712581&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Sep 2021 10:12:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Color-assignment-in-graphs/m-p/1838614#M69350</guid>
      <dc:creator>Andrei_Cusnir</dc:creator>
      <dc:date>2021-09-23T10:12:25Z</dc:date>
    </item>
  </channel>
</rss>

