Quinn-Curtis Forums
Quinn-Curtis Forums
Home | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Tools for Microsoft .Net & .Net Compact Framework
 QCChart2D and QCChart2D CF (VB and C#)
 Set length/size of symbols on StandardLegend?

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkInsert EmailInsert Image Insert CodeInsert QuoteInsert List

* Forum Code is ON
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]


T O P I C    R E V I E W
waveslam Posted - 03 Oct 2017 : 22:59:20
When adding an entry to a Standard Legend, you specify the text and symbol. Assuming i am adding just a plain or dotted line:

ChartAttribute plainLineAttr = new ChartAttribute(Color.Black, 2, DashStyle.Solid);
legend.AddLegendItem("My Legend Entry", ChartObj.LINE, plainLineAttr, legendFont);

This results in a legend entry like:
- My Legend Entry

However, the length of the "-" is quite short and when i have a number of legend entries that differ only by line style (e.g. dotted line, dash line, dash dot etc etc) then its often difficult to tell them apart in the legend.

So is there a parameter/setting on the legend or the entries where I can specify how long/wide each line should be please? I have found I can change their size after they have been added with:

for (int i = 0; i < legend.NumberLegendItems; i++)

.. but this doesnt move the legend text to make room for the larger lines, and so they overwrrite the text e.g.

- My Legend Entry

Thanks in advance!
3   L A T E S T    R E P L I E S    (Newest First)
quinncurtis Posted - 04 Oct 2017 : 20:15:49
You are correct, in that we never considered line styles when designing the legend class, and that was 15 years ago. Given that it is difficult to tell line styles apart on modern high resolution displays, and that they don't necessarily print WYSIWYG properly because of .Net scaling issues, we focused on line and text color and symbol objects for the legend. We really have never had anyone raise it as an issue in all of these years. We really don't have any workaround for displaying a line long enough to differentiate between the different line styles. So your solution is as good as any.
waveslam Posted - 04 Oct 2017 : 16:32:10
Thanks you for your reply and firstly my apologies as I realise I wasn't very clear. The legend Symbol/line is a horizontal line so when I said "wider" I meant longer horizontally, not thicker.

Having said that, I dont agree that the symbol is quite visible with the current sizing. For example, this code:
Font font = new Font("Microsoft Sans Serif", 10, FontStyle.Bold);
ChartAttribute attr = new ChartAttribute(Color.Black, 4, DashStyle.Solid);
_legend.AddLegendItem("Plain Line", ChartObj.LINE, attr, font);

attr = new ChartAttribute(Color.Black, 4, DashStyle.DashDotDot);
_legend.AddLegendItem("DashDotDot", ChartObj.LINE, attr, font);

attr = new ChartAttribute(Color.Black, 4, DashStyle.Dash);
_legend.AddLegendItem("Dash", ChartObj.LINE, attr, font);

attr = new ChartAttribute(Color.Black, 4, DashStyle.DashDot);
_legend.AddLegendItem("DashDot", ChartObj.LINE, attr, font);


Although 4 different line styles are used, when you run it you will see that it produces a legend with 4 identical symbols/lines i.e. they are indistinguishable from each other.

If the symbols/lines were longer then the different dash styles would be more easily distinguishable, but since there is no way to specify that when creating the legend, the only workaround I have been able to some up with is:
1. Create the legend entries as per above but left-pad the text with 10 (say) spaces e.g.
_legend.AddLegendItem("        Plain Line", ChartObj.LINE, attr, font);

2. This creates some whitespace between the legend symbols and the text and so once all entries have been added, loop through them and alter the symbol sizes to make them longer using this available space e.g.:
for (int i = 0; i < _legend.NumberLegendItems; i++)

That works but is of course a hack, so just wanted to confirm that there is no better way please?
quinncurtis Posted - 04 Oct 2017 : 11:01:10
You can make the legend symbol wider and longer. In the current version of the software the legend symbol tracks the line width of the associated ChartAttribute. So if your line plot has a width of 3, so will the legend line symbol. This makes the line quite visible. And you can make it longer, just not as long as you show. Try a symbol size more reasonable, such as 15, rather than 50. The positions are not recalculated so you must work within the position constraints.

Quinn-Curtis Forums © 2000-2018 Quinn-Curtis, Inc. Go To Top Of Page
Powered By: Snitz Forums 2000 Version 3.4.07