Page 1 of 1

Legend Alignment

Posted: Thu Jul 10, 2008 8:05 pm
by 7667581
Using the Java version of Teechart, I am mimicing what my company has previously done with the ocx version of Teechart. We are developing a large web based Java application and using midtier Java code, creating graphs and exporting to jpg files which are inserted into pdfs viewed by the user.

The graph I'm currently working on is a piechart. When I use the legend set alignment to TOP the legend prints centered above the piechart. The VB code manually positions the legend using the following code

.Legend.Top = .Header.Top + 20
.Legend.Left = 10

Then in the onbeforedrawseries method uses annotation to add in another column of text to the right of the legend.

If I use the following Java Code

myChart.getLegend().setCustomPosition(true);
myChart.getLegend().setLeft(10);
myChart.getLegend().setTop(myChart.getHeader().getTop()+20);

instead of the setalignment(TOP), my piechart and legend print on top of each other.

The VB code also has this method
Private Sub TChart1_OnSeriesBeforeDrawValues(ByVal SeriesIndex As Long)

If TChart1.Series(SeriesIndex).SeriesType = scPie Then
With TChart1
.ChartRect .Canvas.Width / 10, ((.Series(SeriesIndex).CountLegendItems + 5) * _
(.Legend.Font.Height)), .Canvas.Width - (.Canvas.Width / 10), .Canvas.Height

End With

End If

Is that what is moving the piechart down????

I have experimented with the java annotate and can insert text. Do I have to use the event dobeforedrawseries? Or can I do everything I need to do in one method. I'm not sure how or why I would need to add eventing in java backend code.

I cannot easily post my desired look and feel (ie the VB graph) using a website. I'm going to email what I'm trying to achieve to Mr. Calvet.

Any help would be most appreciated.

Posted: Fri Jul 11, 2008 8:09 am
by narcis
Hi cathy,

Yes, exactly. You need to position the pie series as done with the ActiveX version. You'll find an example of how to do that at Chart Styles\Standard\Pie\Multiple Pies example in TeeChart.Features.jar shipped with TeeChart's installation.

BTW: You can post your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.

Thanks in advance.