ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Scrollable legend entry?
Posted by Tony on Oct-25-2021 16:36
Hi again,

I regularly see users that have over 16 entries in a legend. Up until now, we've had a scrollable legend box, but I don't think that's possible with ChartDirector.

So my question, is it possible to create the LegendBox independently of the chart? That way I could put it in a separate window and scroll it.

Thanks in advance,

Tony.

  Re: Scrollable legend entry?
Posted by Peter Kwan on Oct-26-2021 00:30
Hi Tony,

Yes, you can have an independent LegendBox.

Some of our customers simply use a "list box" or even a "tree view" (like in the File Explorer) as the independent LegendBox. Some GUI frameworks support list box items with icons or even check boxes, so they can use the checkbox to hide/show the data in the main chart.

However, this kind of list box is difficult to do in MFC. I am not familiar with wxWidgets. If it is difficult, may be we can just create another small chart as an independent legend box.

The most general method to create an independent legend box is to create a chart with the same layer types, but with all the data set to empty array, and with the plot area set to transparent and 1 pixel in size, and remove all unnecessary objects (eg. axis title), so that only the legend box is visible.

Another method is to add a legend box to the chart and use LegendBox.addKey to populate the legend box. This is easy for simple legend icons (a square box with color), but is more difficult if the icons are complex (eg. a dash line with a data symbol at the center).

Regards
Peter Kwan

  Re: Scrollable legend entry?
Posted by Tony on Oct-26-2021 00:43
Attachments:
Thanks, I can do it using wxWidgets easily enough, probably using a grid so I can capture any clicks.

Tony.

One other note. When I've created a legend, not everything lines up nicely. Is there a way to get them nicely laid out in a grid?
Image1.jpg

  Re: Scrollable legend entry?
Posted by Peter Kwan on Oct-26-2021 03:20
Hi Tony,

Yes, you can use grid layout in ChartDirector too. The API is BaseChart.addLegend2. See:

https://www.advsofteng.com/doc/cdcpp.htm#BaseChart.addLegend2.htm

For your case, you can specify to use 4 columns. In this case, the legend items will still flow from left to right, top to bottom, but the items in the same column will be vertically aligned.

Regards
Peter Kwan

  Re: Scrollable legend entry?
Posted by Tony on Oct-26-2021 16:37
Thanks. addLegend2 adds a border around the legend, is there a way to remove it? I've tried legendBox->setKeyBorder(Chart::Transparent) but it does not seem to work for me.

Tony.

  Re: Scrollable legend entry?
Posted by Peter Kwan on Oct-26-2021 22:34
Hi Tony,

You may try Box.setBackground (which also sets the broder color). It is like:

LegendBox *b = c->addLegend2(.....);
b->setBackground(Chart::Transparent, Chart::Transparent);

Regards
Peter Kwan