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

Free Support Forum - aspose.com

X position of Value Axis in a chart


I have a chart and i want to insert on it specific shapes on specific intervals of the category axis. So i need to know the X-position of the Value Axis in order to specify the correct position for these shapes. Currently i can only know the X-position of the chart but the value axis’s position depends on the its values how big or small they are. Can you please help?


Hi Nazha,

I have observed the requirements shared by you and like to share that the chart X,Y position refers to top left corner of chart. Inside chart the maximum width and height of chart has value 1,1. If the chart Plot area X,Y position is 0,0 then maximum height and width o plot area is 1,1.The value and category axis are part of plot area and are aligned on vertical and horizontal boundaries of plot area respectively. I have created the sample code for your kind reference that add the text box along side value axis of the charts. Please use that as reference on your end and tailor that as per your requirements.

public static void TestChart()
Presentation pres = new Presentation();
ISlide slide = pres.Slides[0];

IChart chart = slide.Shapes.AddChart(ChartType.ClusteredColumn, 100, 100, 400, 300);

//The value and category axis are assocaited with chart Ploat area.
//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.

// chart.PlotArea.X =-1 ;
// chart.PlotArea.Y = -1;

float xPos = chart.PlotArea.X;
float yPosMin = chart.PlotArea.Y;
float yPosMax = chart.PlotArea.Height;
if (xPos < 0)
xPos+= 1;

if (yPosMin < 0)
yPosMin += 1;
yPosMax += 1;
float X_RelativePos = chart.X + (xPos * chart.Width)-15;
float Y_Min_RelativePos = chart.Y + (yPosMin * chart.Height) - 12;
float Y_Max_RelativePos = chart.Y + (yPosMax * chart.Height) + 12;

// IAutoShape ashp = slide.Shapes.AddAutoShape(ShapeType.Rectangle, X_RelativePos, Y_Min_RelativePos, 30, 40);
IAutoShape ashp = slide.Shapes.AddAutoShape(ShapeType.Rectangle, X_RelativePos, Y_Max_RelativePos, 30, 40);
IAutoShape ashp2 = slide.Shapes.AddAutoShape(ShapeType.Rectangle, X_RelativePos, Y_Min_RelativePos, 30, 40);

ashp.LineFormat.FillFormat.FillType = FillType.NoFill;
ashp.FillFormat.FillType = FillType.NoFill;
ashp.TextFrame.Text = “test”;
ashp.TextFrame.Paragraphs[0].Portions[0].PortionFormat.FillFormat.FillType = FillType.Solid;
ashp.TextFrame.Paragraphs[0].Portions[0].PortionFormat.FillFormat.SolidFillColor.Color = Color.Black;
ashp.TextFrame.Paragraphs[0].Portions[0].PortionFormat.FontHeight = 8.0f;

ashp2.FillFormat.FillType = FillType.NoFill;
ashp2.TextFrame.Text = “test”;
ashp2.TextFrame.Paragraphs[0].Portions[0].PortionFormat.FillFormat.FillType = FillType.Solid;
ashp2.TextFrame.Paragraphs[0].Portions[0].PortionFormat.FillFormat.SolidFillColor.Color = Color.Black;
ashp2.TextFrame.Paragraphs[0].Portions[0].PortionFormat.FontHeight = 8.0f;

pres.Save(“D:\Aspose Data\GenChart.pptx”, SaveFormat.Pptx);

Many Thanks,