<?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: scripting a bar chart in graph builder in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/scripting-a-bar-chart-in-graph-builder/m-p/35024#M20674</link>
    <description>The graph builder behaves 'smartly' based on the column data types and type of graph selected. When I have done this myself, I have found it easier to build the graph builder code up as a text string, and then parsing the string to run the code. This can be a little tricky as you need to replace the " character using \!".&lt;BR /&gt;&lt;BR /&gt;I did this by building the plot I wanted manually and looking at the code. I used a loop to build up the text string bit by bit for each column.</description>
    <pubDate>Fri, 27 Jan 2017 11:59:06 GMT</pubDate>
    <dc:creator>stephen_pearson</dc:creator>
    <dc:date>2017-01-27T11:59:06Z</dc:date>
    <item>
      <title>scripting a bar chart in graph builder</title>
      <link>https://community.jmp.com/t5/Discussions/scripting-a-bar-chart-in-graph-builder/m-p/35012#M20667</link>
      <description>&lt;P&gt;Hello. I am scripting a bar chart in graph builder because using a standard chart does not eliminate empty bars where as the graph builder does. I am allowing for the&amp;nbsp;use of continuous modeling types as an X factor. Let me explain how I am approaching this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The user selects some columns by which to plot a bar chart. I create the chart using graph builder and the first column selected. Then if there are more than one columns selected, I go in and &amp;lt;&amp;lt;add variables to the graph builder. This works exactly as I want it except when one of the selected columns is continuous. Then the graph builder replaces the entire X with the continuous variable and says there are more variables there but it is only plotting versus the one. When I create the chart manually like this by changing the continuous variable to ordinal, it works the way I want it. So I change each continuous column to oridinal but the graph still does not add the variable but replaces it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone have any ideas how I can make this work the way I want it? Here is a simplified version of my script:&lt;/P&gt;&lt;PRE&gt;myWin = Column Dialog( FactorCol = Col List( "Multivariate Factor(s)" ) );

myFactor = myWin["FactorCol"];

myPlot = Graph Builder(
	Show Control Panel( 0 ),
	Show Legend( 0 ),
	Variables( X( Eval( myFactor[1] ) ), Y( yCol ), Color( Eval( myColor ) ) ),
	Elements( Bar( X, Y, Summary Statistic( "Std Dev" ), Label( "Label by Value" ) ) ),
	SendToReport(
		Dispatch(
			{},
			ScaleBox,
			{Label Row( 1, {Automatic Tick Marks( 0 ), Show Major Ticks( 1 ), Lower Frame( 1 ), Tick Mark Style( "Long Divider" )} )}
		)
	)
);

//If there is more than one factor then need to add variables to the graph
If( N Items( myFactor ) &amp;gt; 1,
	myRep = Report( myPlot )[Graph Builder Box( 1 )];
	For( j = 2, j &amp;lt;= N Items( myFactor ), j++,
		xcol = Column( dtmm, myFactor[j] );
		If( xcol &amp;lt;&amp;lt; Get Modeling Type == "Continuous", 
//set a column property so I can change it back later
			xcol &amp;lt;&amp;lt; Set Property( "change", 1 );
			xcol &amp;lt;&amp;lt; Modeling Type( "Ordinal" );
		);
		myRep &amp;lt;&amp;lt; Add Variable( {xcol, Role( "X" ), Position( 1 )} );
	);
//now I have to adjust all the x-axis for the way I want it
	For( j = 1, j &amp;lt;= N Items( myFactor ), j++,
		Report( myPlot )[Axisbox( 1 )] &amp;lt;&amp;lt; {Label Row(
			j,
			{Automatic Tick Marks( 0 ), Show Major Ticks( 1 ), Lower Frame( 1 ), Tick Mark Style( "Long Divider" )}
		)}
	);
);




&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jan 2017 21:55:55 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/scripting-a-bar-chart-in-graph-builder/m-p/35012#M20667</guid>
      <dc:creator>hlazar</dc:creator>
      <dc:date>2017-01-26T21:55:55Z</dc:date>
    </item>
    <item>
      <title>Re: scripting a bar chart in graph builder</title>
      <link>https://community.jmp.com/t5/Discussions/scripting-a-bar-chart-in-graph-builder/m-p/35024#M20674</link>
      <description>The graph builder behaves 'smartly' based on the column data types and type of graph selected. When I have done this myself, I have found it easier to build the graph builder code up as a text string, and then parsing the string to run the code. This can be a little tricky as you need to replace the " character using \!".&lt;BR /&gt;&lt;BR /&gt;I did this by building the plot I wanted manually and looking at the code. I used a loop to build up the text string bit by bit for each column.</description>
      <pubDate>Fri, 27 Jan 2017 11:59:06 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/scripting-a-bar-chart-in-graph-builder/m-p/35024#M20674</guid>
      <dc:creator>stephen_pearson</dc:creator>
      <dc:date>2017-01-27T11:59:06Z</dc:date>
    </item>
    <item>
      <title>Re: scripting a bar chart in graph builder</title>
      <link>https://community.jmp.com/t5/Discussions/scripting-a-bar-chart-in-graph-builder/m-p/35029#M20677</link>
      <description>&lt;P&gt;Thank you. Yes, I know creating a string script is an option but I am always reluctant to do that. But it may be necessary in this case.&amp;nbsp;I am disappointed that is the case.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;best&lt;/P&gt;&lt;P&gt;H&lt;/P&gt;</description>
      <pubDate>Fri, 27 Jan 2017 15:24:00 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/scripting-a-bar-chart-in-graph-builder/m-p/35029#M20677</guid>
      <dc:creator>hlazar</dc:creator>
      <dc:date>2017-01-27T15:24:00Z</dc:date>
    </item>
    <item>
      <title>Re: scripting a bar chart in graph builder</title>
      <link>https://community.jmp.com/t5/Discussions/scripting-a-bar-chart-in-graph-builder/m-p/35045#M20684</link>
      <description>&lt;P&gt;Actually, I figured out how to do this by checking the variables of the graph builder box step by step. If the column is continuous, I change it to ordinal and when adding a variable, you have to add an inner position term. Here is the pertinant script bit.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;//graph builder can not add factors unless they are ordinal or nominal
//so if it is continuous, change to ordinal, and set a column property to change back later
			If( xcol &amp;lt;&amp;lt; Get Modeling Type == "Continuous",
				xcol &amp;lt;&amp;lt; Set Property( "change", {1} );
				xcol &amp;lt;&amp;lt; Modeling Type( "Ordinal" );
				myRep &amp;lt;&amp;lt; Add Variable( {xcol, Role( "X" ), Position( 1 ), Inner Position[i]} ),
			,
				myRep &amp;lt;&amp;lt; Add Variable( {xcol, Role( "X" ), Position( 1 )} )
			);&lt;/PRE&gt;&lt;P&gt;This does exactly what I want it to do.&lt;/P&gt;&lt;P&gt;H&lt;/P&gt;</description>
      <pubDate>Fri, 27 Jan 2017 19:06:02 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/scripting-a-bar-chart-in-graph-builder/m-p/35045#M20684</guid>
      <dc:creator>hlazar</dc:creator>
      <dc:date>2017-01-27T19:06:02Z</dc:date>
    </item>
  </channel>
</rss>

