Hi,
I build a graph (bar chart) and changed the legend color (and therfore the bar color) by right-clicking and copy the script
SendToReport(
Dispatch(
{},
"400",
ScaleBox,
{Legend Model(
8,
Properties( 0, {Fill Color( 10 )}, Item ID( "category", 1 ) ),
This is part of a bigger graph.
When I run the script and include a local data filter, the color for the categories are changing. This is detrimental because I want to have the same color for a category independently of a filter.
Kind regards,
You can not change the Fill Color by changing the Cell Color nor by changing the Row State of Color to a specified color. A bar chart is a calculated column, that does not have a direct relationship from the display and each individual row. Therefore, you need to deal with the whole bar by changing the Fill Color within the Graph Builder Code. Below is an example on how to do this:
Graph Builder(
Size( 534, 418 ),
Show Control Panel( 0 ),
Variables( Y( :height ), Y( :weight, Position( 1 ) ) ),
Elements( Bar( Y( 1 ), Y( 2 ), Legend( 3 ) ) ),
SendToReport(
Dispatch(
{},
"400",
ScaleBox,
{Legend Model(
3,
Properties( 0, {Fill Color( 5 )}, Item ID( "Mean(height)", 1 ) ),
Properties( 1, {Fill Color( 5 )}, Item ID( "Mean(weight)", 1 ) )
)}
)
)
);
Thanks,
I'm afraid that the answer of the next question is obviously, but how can I change all values in a column to a single color, via script?
I colored all cells in two columns (heigt and weight) to get the same color in a bar chart but it didnt work
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
:height << Color Cell By Value( 1 ); // turn on the cell coloring
For( i = 1, i <= N Row( dt ), i++,
If( Column( dt, "height" )[i] >= 0,
Column( dt, "height" ) << Color Cells( 5, {i} ),
Column( dt, "height" ) << Color Cells( 0, {i} )
));
:weight << Color Cell By Value( 1 ); // turn on the cell coloring
For( i = 1, i <= N Row( dt ), i++,
If( Column( dt, "weight" )[i] >= 0,
Column( dt, "weight" ) << Color Cells( 5, {i} ),
Column( dt, "weight" ) << Color Cells( 0, {i} )
));
Graph Builder(
Size( 534, 418 ),
Show Control Panel( 0 ),
Variables( Y( :height ), Y( :weight, Position( 1 ) ) ),
Elements( Bar( Y( 1 ), Y( 2 ), Legend( 3 ) ) )
);
You can not change the Fill Color by changing the Cell Color nor by changing the Row State of Color to a specified color. A bar chart is a calculated column, that does not have a direct relationship from the display and each individual row. Therefore, you need to deal with the whole bar by changing the Fill Color within the Graph Builder Code. Below is an example on how to do this:
Graph Builder(
Size( 534, 418 ),
Show Control Panel( 0 ),
Variables( Y( :height ), Y( :weight, Position( 1 ) ) ),
Elements( Bar( Y( 1 ), Y( 2 ), Legend( 3 ) ) ),
SendToReport(
Dispatch(
{},
"400",
ScaleBox,
{Legend Model(
3,
Properties( 0, {Fill Color( 5 )}, Item ID( "Mean(height)", 1 ) ),
Properties( 1, {Fill Color( 5 )}, Item ID( "Mean(weight)", 1 ) )
)}
)
)
);