Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
245
Add line to chart at a specific value on X-axis
posted

I would like to add a line on the X-axis of a 3D chart.

I currently have it placing the line in the middle of the chart.

How do I place the line where the value of X-axis is equal to "04/20/2009" (today's date).

The values in the X-axis are strings and not dates.

 

private void DeptChart_FillSceneGraph(object sender, Infragistics.UltraChart.Shared.Events.FillSceneGraphEventArgs e)

        {

 

            ILayer chartLayer = e.ChartCore.GetChartLayer();

            if (chartLayer != null)

            {

                Rectangle bounds = chartLayer.OuterBound;

                Line line = new Line(new Point(bounds.Width / 2, bounds.Bottom), new Point(bounds.Width / 2, bounds.Top));

                line.PE.Stroke = Color.Red;

                e.SceneGraph.Add(line);

            }

 

        }

 

Parents
  • 17605
    posted

    In your case you need to know the index of this label in your data. You can try using:

     

    private void ultraChart1_FillSceneGraph(object sender, Infragistics.UltraChart.Shared.Events.FillSceneGraphEventArgs e)

            {

                ILayer chartLayer = e.ChartCore.GetChartLayer();

     

                IAdvanceAxis axisX = e.Grid["X"] as IAdvanceAxis;

     

                if (chartLayer != null)

                {

                    Rectangle bounds = chartLayer.OuterBound;

     

                    int xIndex = 10; // the index of today's label

     

                    int xLoc = (int)axisX.Map(xIndex);

     

                    Line line = new Line(new Point(xLoc, bounds.Bottom), new Point(xLoc, bounds.Top));               

     

                    line.PE.Stroke = Color.Red;

     

                    e.SceneGraph.Add(line);

                }

            }

     

Reply Children