Quinn-Curtis Forums
Quinn-Curtis Forums
Home | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Tools for Java
 QCChart2D for Java
 Multiple line legend

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

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

* HTML is OFF
* Forum Code is ON
Smilies
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
RunnerGirl Posted - 02 Apr 2008 : 10:50:51
Is there a way to have each legend item have multiple lines? If I don't wrap the lines, the legend goes past the edge of the view. Here's what I have right now:

ChartText sPieStrings[] = new ChartText[data.length];
for (i = 0; i < data.length; i++) {
sPieStrings[i] = new ChartText(pTransform1, font28, data[i].getDowntimeCode() + ", \n" +
(int)(data[i].getDuration()*60) + " min, " +
(int)(data[i].getDuration()/totalDuration*100.0) + "%");
}

ChartAttribute legendAttributes = new ChartAttribute(Color.black, 1,
ChartConstants.LS_SOLID, Color.white);
legendAttributes.setLineFlag(true);
m_oLegend = new StandardLegend(0.52, 0.1, 0.38, 0.5, legendAttributes,
StandardLegend.VERT_DIR);

for (i = 0; i < data.length; i++) {
m_oLegend .addLegendItem(new LegendItem(sPieStrings[i], ChartConstants.SQUARE));
m_oLegend .setChartObjAttributes(attribs[i]);
m_oLegend .setVerticalSpacing(1.0);
m_oLegend .setChartObjScale(pTransform1);
}
m_oLegend .setLegendItemUniformTextColor(Color.black);


Any suggestions?

Thanks!
1   L A T E S T    R E P L I E S    (Newest First)
quinncurtis Posted - 02 Apr 2008 : 11:41:16
The StandardLegend does not really process multiple line items. Nor is there any type of line breaker that will break up a long text strings into multiple lines.

Assuming you can break up your legend item strings into multiple lines, you can trick the StandardLegend into displaying multiple line items, by inserting the extra lines using a symbol attribute that has the symbol size set to 0. Something like:

ChartAttribute nullsymbol = (ChartAttribute) attribArray[4].clone();
nullsymbol.setSymbolSize(0);
StandardLegend legend = new StandardLegend(0.82, 0.2, 0.99, 0.6, legendAttributes, StandardLegend.VERT_DIR);
legend.addLegendItem("Item #1 First Line",ChartConstants.HBAR, attribArray[4], legendFont);
legend.addLegendItem("Item #1 Second Line", ChartConstants.HBAR, nullsymbol, legendFont);
legend.addLegendItem("CSCO", ChartConstants.HBAR, attribArray[3], legendFont);
legend.addLegendItem("TXN", ChartConstants.HBAR, attribArray[2], legendFont);
legend.addLegendItem("ADI", ChartConstants.HBAR, attribArray[1], legendFont);
legend.addLegendItem("AMAT", ChartConstants.HBAR, attribArray[0], legendFont);

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