Skip to main content

Hi, I read some topics about setting the colors of a legend widget. However, I think that those topics are related to a fixed color for a specific item. 

For example, parameter pDemand(iscen), I use an color per scenario to show different colors in a line chart via an annotation spAnnotion(iscen).

Now I want to show the same colors in the legend widget, So I made a parameter pLegend(iscen) with the same annotation spAnnotation(iscen). I would expect that the legend is using the same colors as the line chart. 

But the colors of the legend are not changing?

Hello @OlmoVerhagen , at this moment, the legend does not listen to the Annotation (see also for widget that do support it https://documentation.aimms.com/webui/folder.html#widgets-and-css-properties-supported-for-annotation). Thanks for the suggestion!


@Gertjan okay, is there another way to set the colors of a legend widget dynamically? 


There is a way with custom CSS using properties of the items that are generated in the legend. Formally not supported, but easily achievable. 

Below an example where I used the annotation-sc1 that was added to line, bar and legend items in the charts to change the colors. Here I skipped the WebUI::AnnotationIdentifier part as well, as in my case I just refer to the scenario name that is already propagated (btw, this does not work for all pivots of the bar chart, but if that is important, you can of course extend with a custom WebUI::AnnotationIdentifier and align colors with the legend.

Also attached an example.

 

 


Just want to add that the legend widget indeed listens to annotations and CSS. See screenshot, the “testing” job is yellow in the gantt chart but red in the legend widget. Use .tag-legend-widget as selector. 

.tag-legend-widget .annotation-color6 {

    fill: red;

    background: red;

}

color6 is a webui::AnnotationIdentifier added to the set but you can also use the set element name in the legend widget. 

 


Reply


Didn't find what you were looking for? Try searching on our documentation pages:

AIMMS Developer & PRO | AIMMS How-To | AIMMS SC Navigator