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

Free Support Forum - aspose.com

Adding Constant Lines to chart


Is there any support of adding constant lines to chart similar to below.


Thanks for the details.

We have logged an investigation ticket with an id “CELLSNET-50658” for your issue/requirement. We will look into it and get back to you with updates on it.


Please try the following code for your reference.

Sample code:

Workbook workbook = new Workbook("test.xlsx");
            Chart chart = workbook.Worksheets[0].Charts[0];
            double targeValue = 150;
            double lineLeftScale = (double)chart.PlotArea.InnerX / 4000 + targeValue / (double)chart.ValueAxis.MaxValue;
            double lineTopScale = (double)chart.PlotArea.InnerY / 4000;
            double lineBottomScale = lineTopScale + (double)chart.PlotArea.InnerHeight / 4000;
            LineShape shape = (LineShape)chart.Shapes.AddShapeInChartByScale(MsoDrawingType.Line, PlacementType.MoveAndSize, lineLeftScale, lineTopScale, lineLeftScale, lineBottomScale);
            shape.Line.DashStyle = MsoLineDashStyle.RoundDot;
            shape.Line.SolidFill.Color = Color.Red;
            shape.Line.Weight = 2;