![Image](http://www.s-iberia.com/images/tmp/pie.png)
How can i do that marks don't put over each other?
Dmitry
Code: Select all
public void doMarks()
{
com.steema.teechart.styles.SeriesMarksPosition sMarkPos =
new com.steema.teechart.styles.SeriesMarksPosition();
chart1.repaint();
sMarkPos.height = chart1.getGraphics3D().textHeight("H") + 2;
int yDisp = sMarkPos.height + 5;
int[] xPos = new int[pieSeries.getCount()];
int[] yPos = new int[pieSeries.getCount()];
for (int i = 0; i < pieSeries.getCount(); i++)
{
xPos[i] = pieSeries.getMarks().getPositions().getPosition(i).leftTop.x;
yPos[i] = pieSeries.getMarks().getPositions().getPosition(i).getBounds().y;
}
for (int i = 0; i < pieSeries.getCount(); i++)
{
sMarkPos = new com.steema.teechart.styles.SeriesMarksPosition();
sMarkPos.custom = true;
sMarkPos.height = chart1.getGraphics3D().textHeight("H") + 2;
if ((i>0) && (Math.abs(yPos[i] - yPos[i-1]) < yDisp)
&& (Math.abs(xPos[i] - xPos[i-1]) <
chart1.getGraphics3D().textWidth(pieSeries.getMarkText(i-1))))
xPos[i] = xPos[i] + chart1.getGraphics3D().textWidth(pieSeries.getMarkText(i-1));
sMarkPos.leftTop.setLocation(xPos[i],yPos[i]);
sMarkPos.width = chart1.getGraphics3D().textWidth(pieSeries.getMarkText(i)) + 5;
pieSeries.getMarks().getPositions().setPosition(i, sMarkPos);
}
chart1.repaint();
}
![]() | Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) |
![]() ![]() ![]() ![]() ![]() ![]() |
Please read our Bug Fixing Policy |
Code: Select all
Pie pie1;
private void initChart() {
commander1.setChart(tChart1.getChart());
tChart1.getAspect().setView3D(false);
pie1 = new Pie(tChart1.getChart());
pie1.add(300, "first");
pie1.add(5, "second");
pie1.add(2, "third");
pie1.add(3, "fourth");
pie1.add(4, "fifth");
tChart1.getAspect().setOrthogonal(false);
tChart1.getAspect().setElevation(280);
tChart1.getAspect().setRotation(0);
}
public void doMarks()
{
Rectangle R1,R2;
for (int i=0; i<pie1.getCount()-1; i++)
{
for (int j=0; j<pie1.getCount()-1; j++)
{
if (j!=i)
{
com.steema.teechart.styles.SeriesMarksPosition mp1 = pie1.getMarks().getPositions().getPosition(i);
com.steema.teechart.styles.SeriesMarksPosition mp2 = pie1.getMarks().getPositions().getPosition(j);
R1 = mp1.getBounds();
R2 = mp2.getBounds();
while ( (R1.getLeft() > R2.getLeft()
&& R1.getLeft() < R2.getRight())
|| (R1.getRight() > R2.getLeft()
&& R1.getRight() < R2.getRight())
|| (R1.getTop() > R2.getBottom()
&& R1.getTop() < R2.getTop())
|| (R1.getBottom() > R2.getTop()
&& R1.getBottom() < R2.getBottom()) )
{
mp1.custom = true;
mp1.leftTop.x = mp1.leftTop.x + 2;
mp1.leftTop.y = mp1.leftTop.y + 2;
mp1.arrowTo.x = mp1.leftTop.x + 2;
mp1.arrowTo.y = mp1.leftTop.y + 2;
R1 = mp1.getBounds();
R2 = mp2.getBounds();
}
tChart1.repaint();
}
}
}
}
@Action
public void ButtonClick() {
doMarks();
}
![]() | Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) |
![]() ![]() ![]() ![]() ![]() ![]() |
Please read our Bug Fixing Policy |