Label names on charts

Hi,

I have two questions:

1) Is it possible to add labels to the XY-scatter chart?

I would like to specify the quadrant numbers like Quadrant 1,Quadrant 2,Quadrant 3 and Quadrant 4.

Pls see my attached worksheet.

2)Is it possible to add autoshapes to the chart at a specifc position?

Pls see the attached worksheet.The green colored rectangle is what I require in the chart.

Thanks in advance,

Jagan V

Hi Jagan,

Thanks for asking.

How did you add Quadrant1, 2,3,4. Seems to me you have added a textboxes.

For your both answers, please see Working with Other Drawing Objects.

Hi,

For your questions:

1) Is it possible to add labels to the XY-scatter chart?

Sure, it is easy to add labels for every ChartPoint:

ASeries as = chart.getNSeries().get(0);
ChartPoints cps = as.getChartPoints();
int count = cps.size();
for(int i=0; i<count; i++)
{
ChartPoint cp = cps.getChartPoint(i);
cp.getDataLabels().setText(“Quadrant” + (i+1));
}



And of course you can add TextBox or Rectangle as label, see following code for your second question.

2)Is it possible to add auto-shapes to the chart at a specific position?

Sure, the code like following:

Shapes shapes = chart.getShapes();
shapes.addRectangle(0, 0, 100, 100, 500, 500);

For more details about the APIs of adding shapes, please see corresponding javadoc.


You can also try our latest version/fix Aspose.Cells for Java v2.5.1.2
Thank you.