We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to get axis coordinate

Hello friends,



I am trying to add text box around the chart, therefore need to get the position of the 4 corners in the attached chart.



Any sample code to use?



Thanks



John

Hi John,


I have observed the requirements shared by you and like to share that the position inside the chart has position from (0,0) to (1,1). (0,0) refers to top left corner of chart where as (1,1) refers to bottom right corner of chart. In order to get the position w.r.t chart of corners inside chart, one need to map the position. Please try using following sample code to serve the purpose. Please share, if I may help you further in this regard.

public static void getChartPlotAreaHeight()
{
String path=“C:\Presentations\”;
Presentation pres=new Presentation(path+“LocationOfLineEnd.pptx”);
ISlide slide=pres.getSlides().get_Item(0);

IChart chart=(IChart)slide.findShapeByAltText(“chart”);

//The primary value axis is on left border to plot area and primary category axis is on bottom border of plot area
//The positions inside chart are from 0 to 1. (0,0)(x,y) is top left corner of chart, (1,1) is bottom right corner
//Since the chart value axis is on left border so we will take two points (0,0) top left and (0,1) bottom left.
//Now we will find position mapping of value axis w.r.t actual slide.
float ix = chart.getPlotArea().getX();

float iy = chart.getPlotArea().getY();
if (ix < 0)
ix = 0;
if (iy < 0)
iy = 0;

float X_RelativePos = chart.getX() + (chart.getPlotArea().getX() * chart.getWidth());
if (X_RelativePos < 0)
X_RelativePos *= -1;

float Y_Min_RelativePos = chart.getY() + (chart.getPlotArea().getY() * chart.getHeight());
float Y_Max_RelativePos = chart.getY() + (chart.getPlotArea().getHeight() * chart.getHeight());

if (Y_Min_RelativePos < 0)
Y_Min_RelativePos *= -1;
if (Y_Max_RelativePos < 0)
Y_Max_RelativePos *= -1;
}


Many Thanks,