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

Message ListMessage List     Post MessagePost Message

  Multiple Legends in one line.
Posted by MrCOLOMBO on Apr-28-2010 13:55
Attachments:
I use Java's FinanceChart.
I'm looking for the way to make Multiple Legends stay in one line and truncate text when it has the maximum width .

I was trying to use this code in FinanceChart.addIndicator().

    //configure legend box
    LegendBox box = ret.addLegend(m_leftMargin, m_topMargin, false, m_legendFont, m_legendFontSize);
    int size = m_totalWidth - m_leftMargin - m_rightMargin;
    box.setBackground(m_legendBgColor);
    box.setFontColor(m_legendFontColor);
    box.setMargin2(5, 0, 2, 0);
    box.setTruncate(size, 1);  <- Added this line


But Legend box truncates into 2 lines and it works for a single legend box only.

Please tell me how can I make it for multiple legends?
Legend.png

  Re: Multiple Legends in one line.
Posted by Peter Kwan on Apr-29-2010 00:45
Hi MrCOLOMBO,

Unluckily, ChartDirector does not current support truncating a legend box.

For your case, the only method I can think of is to set a very large width for the legend box. The legend box will then be in one line, and flow outside the right edge of the chart (that is, truncated at the right edge of the chart).

If you want the legend box to be truncated at the right edge of the plot area, you may consider to just put a rectangle at the top right corner to block that part of the legend text. I have not tried myself, but I think it is like:

    LegendBox box = ret.addLegend(m_leftMargin, m_topMargin, false, m_legendFont, m_legendFontSize);
    box.setMaxWidth(999999999);

    ChartDirector.TextBox t = ret.addText(m_totalWidth - m_rightMargin, 0, "");
    t.setSize(m_rightMargin, m_topMargin);
    t.setBackground(0x003333, 0x003333);

    box.setBackground(m_legendBgColor);
    box.setFontColor(m_legendFontColor);
    box.setMargin2(5, 0, 2, 0);

    //you may need to add some margin to avoid the top label of the y-axis being
    //blocked by the box.
    ret.yAxis().setMargin(8);

Hope this can help.

Regards
Peter Kwan

  Re: Multiple Legends in one line.
Posted by MrCOLOMBO on Apr-29-2010 12:34
Ok. Thanks.
Probably you will make a built-in solution for the further versions.

  Re: Multiple Legends in one line.
Posted by Peter Kwan on Apr-29-2010 18:00
Hi Mr COLOMBO,

Thanks for your suggestion. I have already entered this into our feature request list for future versions of ChartDirector.

Regards
Peter Kwan