Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
325
How to override Legend Items, when two legends exist?
posted

Hi all,

I'm aware of how to override legend items through various examples, but all those examples are based on the fact that only one legend exists.

I'm using a composite chart to show a column and line chart, and am showing legend items for each.  However I need to override the legend for the column chart (I need it to show the series labels), but leave the line legend intact.

Iterating through the primitives, I can't seem to find a way of working out which primitives apply to which legend.  I thought either the layer, or chart property might give me this, but the layer always appears to be null, and the chart always appears to be 'ColumnChart'.

How can I differentiate primitives belonging to the appropriate legends?

Thanks in advance...

Parents
No Data
Reply
  • 325
    Suggested Answer
    posted

    In the meantime....I have a workaround.

    Splitting the chart width into 2 (taking into account the YAxis and Y2Axis extents, I'm aligning the LineChart legend against the Y2 Axis, setting a width to consume the chart horizontal mid-point to the Y2Axis point.

    In the FillSceneGraph I capture the LineChart legend (the only one visible) - and use it's (rect.Left - rect.Width) as the new offset for a custom box of the same width and height.

    I also capture the first polyLine, which is first legend item line associated with the line chart.  This line's points[0].point.Y is then used as an offset to position the first new item text.  For each item being added to the new legend the offset is then incremented by the labelStyle.Font.Height.

    The result, ignoring my horrendous testing colour scheme, is pretty pleasing:

    Not forgetting of course to set the relevant bounds for the text items in order to activate the label styling for trimming:

Children