Quinn-Curtis Forums
Quinn-Curtis Forums
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Tools for Microsoft .Net & .Net Compact Framework
 QCChart2D and QCChart2D CF (VB and C#)
 Set length/size of symbols on StandardLegend?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

waveslam

New Zealand
7 Posts

Posted - 03 Oct 2017 :  22:59:20  Show Profile  Reply with Quote
Hi
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++)
{
legend.GetLegendItem(i).GetLegendItemSymbol().SetSymbolSize(50);
}

.. 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!

quinncurtis

1555 Posts

Posted - 04 Oct 2017 :  11:01:10  Show Profile  Reply with Quote
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.
Go to Top of Page

waveslam

New Zealand
7 Posts

Posted - 04 Oct 2017 :  16:32:10  Show Profile  Reply with Quote
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);

_chartView.AddChartObject(_legend);


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++)
{
  _legend.GetLegendItem(i).GetLegendItemSymbol().SetSymbolSize(50);
}


That works but is of course a hack, so just wanted to confirm that there is no better way please?
Thanks!

Edited by - waveslam on 04 Oct 2017 16:35:37
Go to Top of Page

quinncurtis

1555 Posts

Posted - 04 Oct 2017 :  20:15:49  Show Profile  Reply with Quote
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.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Quinn-Curtis Forums © 2000-2018 Quinn-Curtis, Inc. Go To Top Of Page
Powered By: Snitz Forums 2000 Version 3.4.07