cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
lukasz
Level IV

How to fill bars with patterns by using Fill Patterns in iteration?

Hello Everybody,

I would like to fill some bars for specified variables automatically with predefined fill patterns. The number of variables, however, is changing and I would like to do that in iteration depending what variables are currently saved in a datatable. In this case I need to provide argument to Fill Pattern() either as an index (which didn't seem to work) or some reference from a list but for that I would need a list of fill patterns. Then I could use index of item in a list. I would appreciate for help how to do that.

Best regards

Graph Builder(
	Size( 734, 660 ),
	Variables( //that would be good to have it in iteration
		X( :Run ),
		Y( :Param0 ),
		Y( :Param1, Position( 2 ) ),
		Y( :Param2, Position( 2 ) ),
		Y( :Param3, Position( 2 ) ),
		// there is much more of such variables to be displayed
	),
	
	Elements( Position( 1, 1 ), Points( X, Y, Legend( 455 ) ) ),
	
	Elements( //that would be good to have it in iteration
		Position( 1, 2 ),
		Bar(
			X,
			Y( 3 ),
			Y( 5 ),
			Y( 6 ),
			Y( 7 ),
			Legend( 454 ),
			Bar Style( "Stacked" )
		)
	),	
	SendToReport(
		Dispatch(
			{},
			"400",
			ScaleBox,
			{Legend Model(
				455,
				Properties( 0, {Line Color( 25 )}, Item ID( "Param0", 1 ) )
			), Legend Model(
				454,
				
				//that would be good to have it in iteration
				Properties(
					0,
					{Fill Pattern( "left slant light" )},
					Item ID( "Mittelwert(Param1)", 1 )
				),
				Properties(
					2,
					{Fill Pattern( "right slant light" )},
					Item ID( "Mittelwert(Param2)", 1 )
				),
				Properties(
					3,
					{Fill Pattern( "grid heavy" )},
					Item ID( "Mittelwert(Param3)", 1 )
				),
				// there is much more of such properties
				
			)}
		),
		Dispatch( {}, "graph title", TextEditBox, {Set Text( "" )} ),
		Dispatch(
			{},
			"400",
			LegendBox,
			{Legend Position(
				{455, [0], 454, [10, -1, 1, 11]}
			), Position(
				{0, 10, -1, 1, 11}
			)}
		)
	)
);

 

EDIT:

I started to solve the above issue by using expressions to which data can be passed.

I wanted to set properties of a legend of a bar chart in "for-loop" and insert into legend_model_expr defined before the for-loop. Then I would substitute that expression in an appropriate place in Graph Builder. In this case two problems occurred. Firstly, if both "insert into" commends are commented, an error occurs:

Name not resolved: Properties when accessing or evaluating properties. Am I using that correctly? Secondly if I uncomment both "insert into" (or even one of them), another error is displayed: Too many arguments when accessing or evaluating For.

I would appreciate for hints what am I missing. Best regards.

 

//pattern list
fill_patterns_shuffled = {"left slant light", "horizontal light", "right slant light", "vertical light"};
//list of parameters, it can change depending on data available
list2 = {"Param1", "Param2", "Param3"};

legend_model_expr = Expr( Legend Model (53) );
For( c = 1, c <= N Items( list2 ), c++,
	
	y_expr3 = Eval(Parse( "Properties( " || char(c-1) || ", {Fill Pattern( \!"" || fill_patterns_shuffled[ c ] || "\!") }, Item ID( \!"Mittelwert(" || char(list2[ c ]) || ")\!", 1 ) ),"		
						),
					),
		
	//write(y_expr3);
	//Insert Into( y_expr3, 1 );
	//Insert Into( legend_model_expr, Name Expr( y_expr3) );
);

EDIT:

Ok, by using Eval JMP looks for "Properties" function, which actually does not exist, so probably that is why an error occurs. The second error however is remaining.

1 ACCEPTED SOLUTION

Accepted Solutions
lukasz
Level IV

Re: How to fill bars with patterns by using Fill Patterns in iteration?

Ok, I got it working. Below I pasted a correct code. Best regards

//legend
legend_model_expr = Expr( Legend Model (26) );
For( c = 1, c <= N Items( list2 ), c++,	
	y_expr3 = substitute(expr( Properties( c1, {Fill Pattern( fill ) }, Item ID( "Mittelwert(" || name || ")" , 1 ), ), ), expr(c1), c, expr(fill), char(fill_patterns_shuffled[c]), expr(name), list2[c]);	
	//show(y_expr3);
	Insert Into( y_expr3, "");
	Insert Into( legend_model_expr, Name Expr( y_expr3) );
);

View solution in original post

2 REPLIES 2
lukasz
Level IV

Re: How to fill bars with patterns by using Fill Patterns in iteration?

Ok, I got it working. Below I pasted a correct code. Best regards

//legend
legend_model_expr = Expr( Legend Model (26) );
For( c = 1, c <= N Items( list2 ), c++,	
	y_expr3 = substitute(expr( Properties( c1, {Fill Pattern( fill ) }, Item ID( "Mittelwert(" || name || ")" , 1 ), ), ), expr(c1), c, expr(fill), char(fill_patterns_shuffled[c]), expr(name), list2[c]);	
	//show(y_expr3);
	Insert Into( y_expr3, "");
	Insert Into( legend_model_expr, Name Expr( y_expr3) );
);

Re: How to fill bars with patterns by using Fill Patterns in iteration?

I have not been able to get this script to work. Any advice ?

Best regards

Harald