Hi,
I'm looking for a method to consistently target and modify legend items in graph builder.
After I've added variables to generate the basic graph, I use the dispatch statements to modify the line-style/color/size.
The issue that I'm running into is that the legend text (or the item Ids) change depending on what rows I have included/excluded in the data table, and therefore the dispatch statement will work for some selections but not for others.
Example:
LHS, I have multiple rows per x-category (YearMonth). The legend text has the format - "Mean(ColumnName)" | RHS, with rows excluded I only have a single row per x-category. The legend text has the format - "ColumnName" |
| |
To modify the legend items I'm using the legend Model (...) statement as below, where Item ID( "Mean(Yield_A)", 1 ) identifies the item to modify.
gb << send to report (
Dispatch(
{},
"400",
ScaleBox,
{Legend Model( 15,
Level Name( 0, "Yield_A", Item ID( "Mean(Yield_A)", 1 ) ),
Properties( 0, {Line Color( "red" ), Line Width( 6 )}, Item ID( "Mean(Yield_A)", 1 ) ),
)
}
));
I use a data table filter to include/exclude rows to narrow down the graph to a single segment or product.
When filtered to a single product, there is a single row per YearMonth, and the legend text changes as highlighted in the above RHS graph.
The original Item ID( "Mean(Yield_A)", 1 ) used in the dispatch statement will not find a matching item (the columnname is no longer wrapped in mean())
One workaround is to duplicate the legend model () statement/s, to target legend text with format of "ColumnName", e.g. Item ID( "Yield_A", 1 )
This works but it is cumbersome.
Qs:
- Is there an alternative / better method to target the legend items that will work for both cases noted above?
- Is there any standalone documentation for the legend model() statement or its components (I couldn't find it)?
One last thought... I'm assuming that when there is only a single row/value for each x-category, dropping of the Mean() wrapper in the legend text is intentional, but perhaps it would make sense still have the legend item display as "Mean(columnName)", even when there is only a single value? After all, the summary statistic for the line element is still set to "Mean".
Thanks,
Ray