|
Version 7 : CDML Text Item in "Legend Box" |
Posted by DanieldeParis on Nov-14-2023 02:11 |
|
Hi Peter,
A short question concerning items in legend box. Version 7.0 release notes state:
"A legend item in ChartDirector's legend box typically contains an icon, followed by text that describes what the icon means. ChartDirector 7.0 adds support for a pure text item. The text can be CDML (ChartDirector Mark Up Language) formatted. It can be used to add headings or empty lines to separate the legend items into sections, or to add legend items with icons in non-standard positions."
Great! I am trying to improve the legend in some of hand-made visuals. Hand-made meaning that all entries in the legendbox are set with commands such as:
addKey(text, color [, lineWidth [, drawarea ]])
That allows us to include the text and color required for most items we insert. Colored boxes and associated texts are clear and clean solutions. But I have an issue in two specific cases:
1) when I wish to include a non-box item such as a diamond, a cross, sphere or whatever as a replacement for the standard box. I understand that CD would include such symbols when the legend item is created automatically. But that not the case as the chart is hand-made - not a line or a scatter standard CD chart - and I want a very specific visual item.
2) a related case : I want a "text with zero symbol". I can certainly include a blank box. But I have never found the way to drop the symbol altogether.
Is there a way either with the new CDML scheme or via the optional fourth parameter [, drawarea ]
I hope that I am clear enough. And I also hope that there is some solution with the standard legendbox. I found very comfortable to work with, especially once you've learned to lay it out in due time:-)
Daniel |
Re: Version 7 : CDML Text Item in "Legend Box" |
Posted by Peter Kwan on Nov-14-2023 12:01 |
|
Hi DanieldeParis,
ChartDirector 7 comes with an example called "Surface Lines and Zones". It demonstrates building a customized legend box. As I am not sure which programming language you are using, I just randomly include the link to the .NET version. See:
https://www.advsofteng.com/doc/cdnet.htm#surfacelinezone.htm
If you are creating an XYChart, by default, ChartDirector will add a legend entry for all datasets that have names. If you do not want these automatic entries, you can disable them by using Layer.setLegendOrder to set to "NoLegend" (or Chart.NoLegend in .NET syntax).
https://www.advsofteng.com/doc/cdnet.htm#Layer.setLegendOrder.htm
For text with zero symbol, if you use addKey to add text with a completely transparent symbol, the symbol is not visible but it still occupies space. It is because ChartDirector will align the text of the legend entries (assuming the legend box is vertical), so all the text will have the same left offset even for the text with no symbol.
If you need text with no left offset, there is an API LegendBox.addText. (Due to our mistake, the current documentation does not mention it.) It is like (in C#/Java):
myLegendBox.addText("<*font=Arial Bold*>AAAAA");
If you need more flexibility, you can consider not to use the LegendBox object, but simply create your own legend box using pure CDML. Some of our sample code use this method. See:
https://www.advsofteng.com/doc/cdnet.htm#trackbox.htm
Best Regards
Peter Kwan |
Re: Version 7 : CDML Text Item in "Legend Box" |
Posted by DanieldeParis on Nov-14-2023 16:20 |
|
Hi Peter,
Extensive answer that made it. Thanks a lot. Even more so since I did not clarify my question in full.
It relates to a desktop development, no Web, within a highly specific UI layer. CD fits the bill as it allowed us to fully control production/refreshing of the image material. The speed is really great including on massive scatter points, really a differentiating factor ![:-)](icons/icon7.gif)
The legend is CD legendbox that we indeed control via the extensive list functions that it offers. But yes I missed addText as your documentation is generally more than enough!
I found addText2 that made it!
oLegend.AddText2(MyPlacement,MyLegendHeader)
Cheers
|
|