<?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: Graph Builder Stacked Bar Chart in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Graph-Builder-Stacked-Bar-Chart/m-p/679325#M86553</link>
    <description>&lt;P&gt;Changing to the % of Total is a simple math formula, give the columns in the stacked data table.&amp;nbsp; I just added a new column called % of Total, and then used it in the graph as the Y Axis&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_0-1695142547483.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/56758i15426224F9DB596F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_0-1695142547483.png" alt="txnelson_0-1695142547483.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Current Data Table();
dtStack = dt &amp;lt;&amp;lt; Stack(
	columns(
		:Parm 1 # Fails, :Parm 2 # Fails, :Parm 3 # Fails, :Parm 1 % Fail,
		:Parm 2 % Fail, :Parm 3 % Fail
	),
	Source Label Column( "Parameter" ),
	Stacked Data Column( "Counts" ),
	Number of Series( 2 ),
	Contiguous
);

// Change the name of the column that has the % values
dtStack:Counts 2 &amp;lt;&amp;lt; set name( "Percent" );

dtStack &amp;lt;&amp;lt; New Column( "% of Total", Format( "Percent", 7, 0 ) );

// Divide each row value for the percent column to conform
// to the percent values for a JMP column
For Each Row(
	:Percent = :Percent / 100;
	:"% of Total"n = :counts / :Total Fails * (:total % Fail / 100);
);

// Change the display format for the percent column to 
// display a % sign in the values
dtStack:Percent &amp;lt;&amp;lt; Format( "Percent", 7, 1 );

// A column needs to be set to have the correct display values for
// the legend.  Also, the alphabetical ordering will determine the
// order of the subbar values.  So recode the column to meet those
// specifications
// Recode column: Parameter
Local( {dt},
	dt = dtStack;
	dt &amp;lt;&amp;lt; Begin Data Update;
	dt &amp;lt;&amp;lt; Recode Column(
		dt:Parameter,
		{Map Value(
			_rcOrig,
			{"Parm 1 # Fails", "3. Parm 1", "Parm 2 # Fails", "2. Parm 2",
			"Parm 3 # Fails", "1. Parm 3"},
			Unmatched( _rcNow )
		)},
		Update Properties( 1 ),
		Target Column( :Parameter )
	);
	dt &amp;lt;&amp;lt; End Data Update;
);

// Label column: Percent to be used to label the graph
dtStack:Percent &amp;lt;&amp;lt; Label( 1 );
// Label all rows to show which values from the percent column
// to label
dtStack &amp;lt;&amp;lt; Select All Rows &amp;lt;&amp;lt; Label( 1 );
dtStack &amp;lt;&amp;lt; clear selection;
dtStack &amp;lt;&amp;lt; invert row selection;

// Draw the graph
Graph Builder(
	Size( 528, 450 ),
	Show Control Panel( 0 ),
	Variables( X( :Month ), Y( :"% of Total"n ), Overlay( :Parameter ) ),
	Elements(
		Bar( X, Y, Legend( 7 ), Bar Style( "Stacked" ), Label( "Label by Row" ) )
	),
	SendToReport(
		Dispatch(
			{},
			"400",
			ScaleBox,
			{Legend Model(
				7,
				Properties( 0, {Fill Color( 73 )}, Item ID( "1. Parm 3", 1 ) ),
				Properties( 1, {Fill Color( 25 )}, Item ID( "2. Parm 2", 1 ) ),
				Properties(
					2,
					{Fill Color( -7183127 )},
					Item ID( "3. Parm 1", 1 )
				)
			)}
		)
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 19 Sep 2023 16:56:11 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2023-09-19T16:56:11Z</dc:date>
    <item>
      <title>Graph Builder Stacked Bar Chart</title>
      <link>https://community.jmp.com/t5/Discussions/Graph-Builder-Stacked-Bar-Chart/m-p/679082#M86530</link>
      <description>&lt;P&gt;JMP 17 Attached is a simple data table containing monthly numbers of Total # of Parts, Total Fails, % Total Fails and then individual numbers for which Parameter failed. The stacked bar chart I want is Month on the X-axis and % Total Fails on Y-axis. Then I would like those bars to be stacked with the break out of which Parameter failed by the monthly percentage of each parameter. Below is a screen shot, see Fig 1, of something I drew up in ppt. I was unable to get this in Graph Builder. I tried stacking the data, manipulating columns but no go.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In summary I want the overall total % of failed parts on the Y-axis as a bar, then that bar showing the percentage of each parameter that failed for each month. Sample data table is attached below. Thank you.&lt;/P&gt;&lt;P&gt;Fig. 1&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="WoHNY_0-1695077305371.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/56753iD64C4C422521576E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="WoHNY_0-1695077305371.png" alt="WoHNY_0-1695077305371.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Sep 2023 22:51:42 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Graph-Builder-Stacked-Bar-Chart/m-p/679082#M86530</guid>
      <dc:creator>WoHNY</dc:creator>
      <dc:date>2023-09-18T22:51:42Z</dc:date>
    </item>
    <item>
      <title>Re: Graph Builder Stacked Bar Chart</title>
      <link>https://community.jmp.com/t5/Discussions/Graph-Builder-Stacked-Bar-Chart/m-p/679156#M86533</link>
      <description>&lt;P&gt;The chart that you want requires a change in the structure of your data table and the setting of some data table RowStates and Column States.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_0-1695094507351.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/56754i1CB5EB4DE2746847/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_0-1695094507351.png" alt="txnelson_0-1695094507351.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The script below changes the structure of the data table and then draws the above final graph.&amp;nbsp; Everything in the script can be done interactively.&amp;nbsp; In fact, everything was done interactively and then I just took the script that JMP provided and copied into one final script.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default to here(1);
dt = current data table();
dtStack = dt &amp;lt;&amp;lt;
Stack(
	columns(
		:Parm 1 # Fails, :Parm 2 # Fails, :Parm 3 # Fails, :Parm 1 % Fail,
		:Parm 2 % Fail, :Parm 3 % Fail
	),
	Source Label Column( "Parameter" ),
	Stacked Data Column( "Counts" ),
	Number of Series( 2 ),
	Contiguous
);

// Change the name of the column that has the % values
dtStack:Counts 2 &amp;lt;&amp;lt; set name("Percent");

// Divide each row value for the percent column to conform
// to the percent values for a JMP column
for each row(
	:Percent = :Percent / 100;
);

// Change the display format for the percent column to 
// display a % sign in the values
dtStack:Percent &amp;lt;&amp;lt; format("Percent", 7, 0);

// A column needs to be set to have the correct display values for
// the legend.  Also, the alphabetical ordering will determine the
// order of the subbar values.  So recode the column to meet those
// specifications
// Recode column: Parameter
Local( {dt},
	dt = dtStack;
	dt &amp;lt;&amp;lt; Begin Data Update;
	dt &amp;lt;&amp;lt; Recode Column(
		dt:Parameter,
		{Map Value(
			_rcOrig,
			{"Parm 1 # Fails", "3. Parm 1", "Parm 2 # Fails", "2. Parm 2",
			"Parm 3 # Fails", "1. Parm 3"},
			Unmatched( _rcNow )
		)},
		Update Properties( 1 ),
		Target Column( :Parameter )
	);
	dt &amp;lt;&amp;lt; End Data Update;
);

// Label column: Percent to be used to label the graph
dtStack:Percent &amp;lt;&amp;lt; Label( 1 );
// Label all rows to show which values from the percent column
// to label
dtStack &amp;lt;&amp;lt; Select All Rows &amp;lt;&amp;lt; Label(1);
dtStack &amp;lt;&amp;lt; clear selection;
dtStack &amp;lt;&amp;lt; invert row selection;

// Draw the graph
Graph Builder(
	Size( 528, 450 ),
	Show Control Panel( 0 ),
	Variables( X( :Month ), Y( :Counts ), Overlay( :Parameter ) ),
	Elements(
		Bar( X, Y, Legend( 7 ), Bar Style( "Stacked" ), Label( "Label by Row" ) )
	),
	SendToReport(
		Dispatch(
			{},
			"400",
			ScaleBox,
			{Legend Model(
				7,
				Properties(
					0,
					{Fill Color( 73 )},
					Item ID( "1. Parm 3", 1 )
				),
				Properties(
					1,
					{Fill Color( 25 )},
					Item ID( "2. Parm 2", 1 )
				),
				Properties(
					2,
					{Fill Color( -7183127 )},
					Item ID( "3. Parm 1", 1 )
				)
			)}
		)
	)
);

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here is the restructured data table that was used to create the final chart.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_1-1695094803771.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/56755i5590B06949779BE2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_1-1695094803771.png" alt="txnelson_1-1695094803771.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Sep 2023 15:45:17 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Graph-Builder-Stacked-Bar-Chart/m-p/679156#M86533</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2023-09-19T15:45:17Z</dc:date>
    </item>
    <item>
      <title>Re: Graph Builder Stacked Bar Chart</title>
      <link>https://community.jmp.com/t5/Discussions/Graph-Builder-Stacked-Bar-Chart/m-p/679307#M86551</link>
      <description>&lt;P&gt;Jim:&lt;/P&gt;&lt;P&gt;Thank you for your response. I was unaware of the Multiple Series Stack option so that is a great tip. The only issue with the graph you generated was the Y-axis. I was looking for the Total % by Month as the overall height of the bar. So for Jan it would be 10%, Feb 4% &amp;amp; March 15%. The Y-axis would the monthly overall percent of fails. Then each of those bars would be subdivided into the percentages of the failing Parameters. The Jan 10% overall bar would be subdivided 20% Parm 1 / 80% Parm 2. The Feb 4% overall bar would be subdivided 16.7% Parm 1 / 50% Parm 2 / 33.3% Parm 3. Then the March 15% overall bar would be subdivided 37% Parm 1 / 29.6% Parm 2 / 33.3% Parm 3. I may need to adjust the table further because I cannot make it happen via Graph Builder as of yet. Thanks again.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Sep 2023 14:28:23 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Graph-Builder-Stacked-Bar-Chart/m-p/679307#M86551</guid>
      <dc:creator>WoHNY</dc:creator>
      <dc:date>2023-09-19T14:28:23Z</dc:date>
    </item>
    <item>
      <title>Re: Graph Builder Stacked Bar Chart</title>
      <link>https://community.jmp.com/t5/Discussions/Graph-Builder-Stacked-Bar-Chart/m-p/679314#M86552</link>
      <description>&lt;P&gt;Jim:&lt;/P&gt;&lt;P&gt;I finally got something to work via Graph Builder. Thank you for the solution you provided. The Multiple Series you pointed out is a big help going forward as well as the code for this exercise. Thank you again.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Sep 2023 15:48:13 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Graph-Builder-Stacked-Bar-Chart/m-p/679314#M86552</guid>
      <dc:creator>WoHNY</dc:creator>
      <dc:date>2023-09-19T15:48:13Z</dc:date>
    </item>
    <item>
      <title>Re: Graph Builder Stacked Bar Chart</title>
      <link>https://community.jmp.com/t5/Discussions/Graph-Builder-Stacked-Bar-Chart/m-p/679325#M86553</link>
      <description>&lt;P&gt;Changing to the % of Total is a simple math formula, give the columns in the stacked data table.&amp;nbsp; I just added a new column called % of Total, and then used it in the graph as the Y Axis&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_0-1695142547483.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/56758i15426224F9DB596F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_0-1695142547483.png" alt="txnelson_0-1695142547483.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Current Data Table();
dtStack = dt &amp;lt;&amp;lt; Stack(
	columns(
		:Parm 1 # Fails, :Parm 2 # Fails, :Parm 3 # Fails, :Parm 1 % Fail,
		:Parm 2 % Fail, :Parm 3 % Fail
	),
	Source Label Column( "Parameter" ),
	Stacked Data Column( "Counts" ),
	Number of Series( 2 ),
	Contiguous
);

// Change the name of the column that has the % values
dtStack:Counts 2 &amp;lt;&amp;lt; set name( "Percent" );

dtStack &amp;lt;&amp;lt; New Column( "% of Total", Format( "Percent", 7, 0 ) );

// Divide each row value for the percent column to conform
// to the percent values for a JMP column
For Each Row(
	:Percent = :Percent / 100;
	:"% of Total"n = :counts / :Total Fails * (:total % Fail / 100);
);

// Change the display format for the percent column to 
// display a % sign in the values
dtStack:Percent &amp;lt;&amp;lt; Format( "Percent", 7, 1 );

// A column needs to be set to have the correct display values for
// the legend.  Also, the alphabetical ordering will determine the
// order of the subbar values.  So recode the column to meet those
// specifications
// Recode column: Parameter
Local( {dt},
	dt = dtStack;
	dt &amp;lt;&amp;lt; Begin Data Update;
	dt &amp;lt;&amp;lt; Recode Column(
		dt:Parameter,
		{Map Value(
			_rcOrig,
			{"Parm 1 # Fails", "3. Parm 1", "Parm 2 # Fails", "2. Parm 2",
			"Parm 3 # Fails", "1. Parm 3"},
			Unmatched( _rcNow )
		)},
		Update Properties( 1 ),
		Target Column( :Parameter )
	);
	dt &amp;lt;&amp;lt; End Data Update;
);

// Label column: Percent to be used to label the graph
dtStack:Percent &amp;lt;&amp;lt; Label( 1 );
// Label all rows to show which values from the percent column
// to label
dtStack &amp;lt;&amp;lt; Select All Rows &amp;lt;&amp;lt; Label( 1 );
dtStack &amp;lt;&amp;lt; clear selection;
dtStack &amp;lt;&amp;lt; invert row selection;

// Draw the graph
Graph Builder(
	Size( 528, 450 ),
	Show Control Panel( 0 ),
	Variables( X( :Month ), Y( :"% of Total"n ), Overlay( :Parameter ) ),
	Elements(
		Bar( X, Y, Legend( 7 ), Bar Style( "Stacked" ), Label( "Label by Row" ) )
	),
	SendToReport(
		Dispatch(
			{},
			"400",
			ScaleBox,
			{Legend Model(
				7,
				Properties( 0, {Fill Color( 73 )}, Item ID( "1. Parm 3", 1 ) ),
				Properties( 1, {Fill Color( 25 )}, Item ID( "2. Parm 2", 1 ) ),
				Properties(
					2,
					{Fill Color( -7183127 )},
					Item ID( "3. Parm 1", 1 )
				)
			)}
		)
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 19 Sep 2023 16:56:11 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Graph-Builder-Stacked-Bar-Chart/m-p/679325#M86553</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2023-09-19T16:56:11Z</dc:date>
    </item>
  </channel>
</rss>

