Custom the Legend

Hello Everyone,

I'm looking to create a custom legend using a value that is on the same row for each bar in the chart and also wanting to eliminate the color key.

Data Fields

PeriodName (x axis label), Revenue (y axis label and bar topper), AverageAmount (want to use for legend)

Current legend


Proposed Legend

All help is appreciated.

Best regards,

John

Comments

  • G'day John,

    I am making a lot of assumptions here because you don't say anything about versions of software or technique(s) for producing the Chart(s), so...

    Assuming you have a "modern" version of FastReport / RAD Studio installed, and the Chart(s) are built with the bundled version of TeeChart, you should be able to access the "Legend" Property for the Chart Object (either in the IDE or from Code) and set its "Visible" Variable to "False". Not knowing how you have created the Report / Chart makes it hard to say precisely how to do this, but (for example) you may be able to double-click on the Chart Object and then use TeeChart's Dialog Box to clear the "Visible" Checkbox.

    However re-reading your question just now I realised you don't want to turn the Legend "off", just render it without the "colour code" and with different currency amounts.

    Have you tried "playing with" the "Legend Style" Combo-box? It is also available via the "Legend" Property. This might get you closer to your goal...

    If not, I doubt that you can do the "customisation" with FastReport / RAD Studio and may require you to have a TeeChart "Pro" licence (with access to the source code).

    Cheers, Paul


  • Thanks Paul,

    I'm using XE7 with FR 2022.2.11

    I came close with the legend properties, but in the end couldn't display the value I wanted.

    I've had a couple of ideas...

    1. Create a sub-report and format it to fit in a small window, then overlay that above the chart in design mode
    2. Manually fill a TfrxTableObject from code

    What do you think? I'm partial to the Table Object idea but I'm certainly open to anything which helps me accomplish the goal.

    All my best, John

  • Hey everyone!

    I didn't do it the way I wanted, but I figured out a work around. I hope this helps someone else.

    1. Create a 2nd series with the same attributes as the first; including Values | Label, Values | X (optional), and Label | Color (optional)
    2. Set the 2nd series Values | Y to the other value you'd like to display in the legend
    3. Change the 2nd's Transparency to 100
    4. Change the 1st series' ShowInLegend to false

    And now you have it! Essentially you're hiding the legend for the 1st series and the bars for the 2nd series to create a composite chart.

    Series 1

    Series 2

    Result

    Best to you all!

    John

  • G'day John,

    That is a very neat solutiion! I hadn't got my head around this, but was going for something more complex Glad you "beat me to it"!

    Chheers, Paul

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.