How to Format a HorizontalLineAnnotation to graph frame

Viewed 14

I have a code for making two horizontal line annotations to my graph:

public void populate()
{
    HorizontalLineAnnotation hl = new HorizontalLineAnnotation();
    hl.AllowMoving = false;
    hl.IsInfinitive = true;
    hl.LineColor = System.Drawing.Color.Red;
    hl.AnchorY = Convert.ToDouble(USLText.Text);
    hl.AxisX = DataChart.ChartAreas[0].AxisX;
    hl.AxisY = DataChart.ChartAreas[0].AxisY;
    DataChart.Annotations.Add(hl);

    HorizontalLineAnnotation hllsl = new HorizontalLineAnnotation();
    hllsl.AllowMoving = false;
    hllsl.IsInfinitive = true;
    hllsl.LineColor = System.Drawing.Color.Blue;
    hllsl.AnchorY = Convert.ToDouble(LSLText.Text);
    hllsl.AxisX = DataChart.ChartAreas[0].AxisX;
    hllsl.AxisY = DataChart.ChartAreas[0].AxisY;
    DataChart.Annotations.Add(hllsl);

(There is more code below it which doesnt concern the question hence not included so not getting any error)

The line plotted seems to extend beyond the graph end axis and is going end to end on the window as in the below picture

screenshot

how do I correct this

0 Answers
Related