Vertical position of Y-Axis tick mark labels / Text annotations on Y-Axis

Unanswered Vertical position of Y-Axis tick mark labels / Text annotations on Y-Axis

  • Thursday, May 24, 2012 3:57 PM
     
      Has Code

    Hi,

    I'm charting some financial prices in realtime with the following code, but it's not working out too well for me.

    (a) I put the Y-axis over to the right-hand side, but now the major tick mark labels are on the wrong side of the Axis. 

    (b) I'm not doing a great job of creating a moving/scrolling window of 25 points. There might be a better way of doing this than the approach I took below.

    (c) I want to show the current price over on the Y-Axis beside the tick mark labels: basically outside the chart. The prices are moving so quickly, an indication of the current level, moving up and down the Axis as price updates come in is needed. Any suggestions on how I can achieve this? I'm setting the Y-value correctly (as below), but can't seem to anchor the textannotation to the Y-axis (preferably Y-Axis + a few pixels).

    (d) IS there a better way to hook up the x axis? I just chose datatype=time in the designer in VS2010. SHould it be 'X-AxisIndexed' or any other way?

                   if (this.chart1.Series[0].Points.Count > 25)
                    {
                        this.chart1.Series[0].Points.RemoveAt(0);
                        this.chart1.Series[1].Points.RemoveAt(0);
                        this.chart1.ChartAreas[0].RecalculateAxesScale();
                    }
                    this.chart1.Series[Series].Points.AddXY(timestamp, Math.Round(value,2));
    
    
    TextAnnotation textAnnotation = new TextAnnotation();
                    textAnnotation.Text = level.ToString();
                    textAnnotation.AxisX = this.chart1.ChartAreas[0].AxisX;
                    textAnnotation.AxisY = this.chart1.ChartAreas[0].AxisY;                
                    textAnnotation.AnchorX = this.chart1.ChartAreas[0].AxisX.Maximum;
                    textAnnotation.AnchorY = level;
    
                    chart1.Annotations.Clear();  
                     chart1.Annotations.Add(textAnnotation);
    chart1.Invalidate();

    Would appreciate any help at all on this.

    Thanks.


    • Edited by tobriain Thursday, May 24, 2012 3:57 PM
    •