I even tried the (seemingly obvious) solution of using a legend widget. If this will work, I can't figure out how.
Is there a way to show the legend? And if you don't have on yet, is there a workaround and do you have it in the plans in the future?
Best answer by MathFourView original
I suppose you have multiple identifiers in a linechart and you want to show a legend to display what line represents what quantity. For this, you will need to create a subset of AllIdentifiers, include the identifiers in your linechart in this subset and create an element parameter in this subset.
Use this element parameter as the contents of the legend widget. The example in this answer does the same.
Here are the details of my situation. Perhaps I am missing something?
Here's what I have in AIMMS Developer:
Then for the linechart in webui.json, I have:
Then for the legend in webui.json:
From your instructions, this is what I understand. But the colors don't match. I wonder if I have to do something special with the css. Currently I have this for line one (and similar css for the others):
Perhaps I need a similar annotation on the element parameter e_LineChart_Identifier?
For the line chart, you need to use path.annotation and/or circle.annotation to apply the colors. This has been mentioned in the documentation page https://how-to.aimms.com/Articles/49/49-webui-css-color.html
Sorry, I understand the original post wrong. For the legend colors, you need to add the annotations to your set.
Using my example, I have the identifiers of the linechart widget as p_WUI_LineOne, p_WUI_LineTwo, and p_WUI_LineThree. Each of these are colored red, blue and green, respectively.
So I need the set along with the webui::AnnotationsIdentifier as follows:
Then for the annotation I'll use in CSS, I put in AIMMS:
And finally in CSS:
This now gets the color block in the legend to be red next to the words "p_WUI_LineOne" to match the red line of the linechart that is associated with p_WUI_LineOne. Likewise for the blue and green lines.
Of course, the CSS attribute might not be stroke here, but when I learn what it actually is, I'll come edit this post to reflect that.
See the screenshot - I highlighted the coloring elements of the bottom color in Legend Bar Chart 2. This has annotations para2 (the default identifier name) and "olive" which was applied from webui::AnnotationsIdentifier.
The yellow color applied through below code is applied to all the legend color elements.
So, I suppose you are trying some code like
However, the individual coloring elements of the legend widget doesn't seem to take the identifier name or custom added annotations into account - see the pink coloring highlighted in the screenshot.
So, you either use the code which will change the color of p_WUI_LineOne to #ff0099 throughout the project (including the legend widget)
or, you add webui::annotationsidentifier to your legend set like below and then use