Example #1
0
        private void chart1_PostPaint(object sender, System.Windows.Forms.DataVisualization.Charting.ChartPaintEventArgs e)
        {
            if (sender is ChartArea)
            {
                ChartArea area = (ChartArea)sender;
                if (area.Name == "Default")
                {
                    Point3D [] pt3d = new Point3D[4];
                    pt3d[0] = new Point3D();
                    pt3d[1] = new Point3D();
                    pt3d[2] = new Point3D();
                    pt3d[3] = new Point3D();

                    float depth = (float)area.GetSeriesDepth(chart1.Series[0]);
                    float zpos  = (float)area.GetSeriesZPosition(chart1.Series[0]);

                    pt3d[0].Y = (float)area.AxisX.ValueToPosition(chart1.Series["Estimated"].Points[7].XValue);
                    pt3d[0].X = (float)area.AxisY.ValueToPosition(chart1.Series["Estimated"].Points[7].YValues[1]);
                    pt3d[0].Z = depth;

                    pt3d[1].Y = (float)area.AxisX.ValueToPosition(chart1.Series["Estimated"].Points[6].XValue);
                    pt3d[1].X = (float)area.AxisY.ValueToPosition(chart1.Series["Estimated"].Points[6].YValues[0]);
                    pt3d[1].Z = depth;

                    pt3d[2].Y = (float)area.AxisX.ValueToPosition(chart1.Series["Estimated"].Points[3].XValue);
                    pt3d[2].X = (float)area.AxisY.ValueToPosition(chart1.Series["Estimated"].Points[3].YValues[1]);
                    pt3d[2].Z = depth;

                    pt3d[3].Y = (float)area.AxisX.ValueToPosition(chart1.Series["Estimated"].Points[2].XValue);
                    pt3d[3].X = (float)area.AxisY.ValueToPosition(chart1.Series["Estimated"].Points[2].YValues[0]);
                    pt3d[3].Z = depth;


                    area.TransformPoints(pt3d);

                    PointF ptF1 = new PointF();
                    PointF ptF2 = new PointF();
                    PointF ptF3 = new PointF();
                    PointF ptF4 = new PointF();
                    PointF ptF5 = new PointF();
                    PointF ptF6 = new PointF();

                    ptF1 = e.ChartGraphics.GetAbsolutePoint(pt3d[0].PointF);
                    ptF3 = e.ChartGraphics.GetAbsolutePoint(pt3d[1].PointF);
                    ptF4 = e.ChartGraphics.GetAbsolutePoint(pt3d[2].PointF);
                    ptF6 = e.ChartGraphics.GetAbsolutePoint(pt3d[3].PointF);

                    ptF2.X = ptF3.X;
                    ptF2.Y = ptF1.Y;

                    ptF5.X = ptF6.X;
                    ptF5.Y = ptF4.Y;

                    // Take Graphics object from chart
                    Graphics graph = e.ChartGraphics.Graphics;

                    graph.DrawLine(new Pen(Color.Black, 1), ptF1, ptF2);
                    graph.DrawLine(new Pen(Color.Black, 1), ptF2, ptF3);
                    graph.DrawLine(new Pen(Color.Black, 1), ptF4, ptF5);
                    graph.DrawLine(new Pen(Color.Black, 1), ptF5, ptF6);

                    DrawArrow(graph, Color.Black, ptF3, ptF2, 22.5);
                    DrawArrow(graph, Color.Black, ptF6, ptF5, 22.5);
                }
            }
        }