Page 1 of 1

### Pie and marks

Posted: Tue Aug 18, 2009 11:55 am

How can i do that marks don't put over each other?

Dmitry

### Re: Pie and marks

Posted: Fri Aug 21, 2009 11:06 am
Hi Dmitry,

We are finding some problems in 3D that we are trying to solve but in 2D it seems to work fine:

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();
} ``````

### Re: Pie and marks

Posted: Sun Aug 23, 2009 9:13 pm
This problem is for 2d too.
What will i do with this code?
Dmitry

### Re: Pie and marks

Posted: Wed Aug 26, 2009 11:18 am
Hi Dmitry,

Here you have a simple example of how you could move the marks. As you'll see, when this application is started, some marks overlap the others but clicking the button we calculate new positions moving them more to the right-bottom until there is enough space to draw them:

Code: Select all

``````    Pie pie1;

private void initChart() {
commander1.setChart(tChart1.getChart());

tChart1.getAspect().setView3D(false);

pie1 = new Pie(tChart1.getChart());

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();
}``````

### Re: Pie and marks

Posted: Wed Aug 26, 2009 1:29 pm
ok.
I hope next release will be with bugfix