<?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: How to limit number of legend items? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-limit-number-of-legend-items/m-p/357977#M60813</link>
    <description>&lt;P&gt;Ok, I got it.&lt;/P&gt;&lt;P&gt;Calculate the number of categories:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Categories = NItems(Associative Array (dt:CategoriesColumn));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Set up how many legend items you want:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;LegendLevels = 3;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Construct a list that has the same number of elements as how many categories you have, fill it with consecutive numbers for the levels you want to show, and "-1" for the rest:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;p = {};
	For(i=0, i &amp;lt; Categories, i+=1,
		if(i &amp;lt;= (LegendLevels-1), p = Insert(p, i), p = Insert(p, -1))
		);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The use this list when scripting your Graph Builder, inside SendToReport():&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;		Dispatch(
			{},
			"400",
			LegendBox,
			{Set Title( "Category" ), Legend Position( {5, Matrix(p)} ),
			Position( Matrix(p) )}
		)&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 10 Feb 2021 21:09:36 GMT</pubDate>
    <dc:creator>miguello</dc:creator>
    <dc:date>2021-02-10T21:09:36Z</dc:date>
    <item>
      <title>How to limit number of legend items?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-limit-number-of-legend-items/m-p/357956#M60811</link>
      <description>&lt;P&gt;I have a plot that is overlayed by hundreds of catergorical values. When user works with it, it only makes sense to compare 2, 3, maximum 5 categories, and user id doing that through data filter.&lt;/P&gt;&lt;P&gt;But nothing prevents user from selecting all 150+ categories. In this case they all get displayed in legend, totally breaking windows. Since you wouldn't be able to see anything on the plot in this case anyways, I'm OK with just limiting number of legend items to, let's say, 20, so it doesn't break the design and still serves the purpose. Any way to specify the limit through JSL?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Jun 2023 11:11:01 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-limit-number-of-legend-items/m-p/357956#M60811</guid>
      <dc:creator>miguello</dc:creator>
      <dc:date>2023-06-11T11:11:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to limit number of legend items?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-limit-number-of-legend-items/m-p/357977#M60813</link>
      <description>&lt;P&gt;Ok, I got it.&lt;/P&gt;&lt;P&gt;Calculate the number of categories:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Categories = NItems(Associative Array (dt:CategoriesColumn));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Set up how many legend items you want:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;LegendLevels = 3;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Construct a list that has the same number of elements as how many categories you have, fill it with consecutive numbers for the levels you want to show, and "-1" for the rest:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;p = {};
	For(i=0, i &amp;lt; Categories, i+=1,
		if(i &amp;lt;= (LegendLevels-1), p = Insert(p, i), p = Insert(p, -1))
		);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The use this list when scripting your Graph Builder, inside SendToReport():&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;		Dispatch(
			{},
			"400",
			LegendBox,
			{Set Title( "Category" ), Legend Position( {5, Matrix(p)} ),
			Position( Matrix(p) )}
		)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 10 Feb 2021 21:09:36 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-limit-number-of-legend-items/m-p/357977#M60813</guid>
      <dc:creator>miguello</dc:creator>
      <dc:date>2021-02-10T21:09:36Z</dc:date>
    </item>
  </channel>
</rss>

