Page 1 of 1

Dragpoints and mass editting

Posted: Wed Sep 21, 2011 3:30 pm
by 8739068
I am using TeeChart for .NET version 3.5

I have a DragPoint series that I only allow dragging in the Vertical direction. Typically I have 10 points evenly dispersed horizontally across my 2D chart. I would like to quickly edit the vertical values (Y Axis).

With the mouse, starting from the top/left side of the chart, Click and hold the left mouse button while dragging a path from left to right side, not necessarily in a straight line but some varying path. Once I reach the right side of the chart or I stop clicking the mouse button, the drag points snap to the vertical path I just created with the mouse drag/click path.

I can see this working 1 of 2 ways

#1 as I drag/click the mouse I draw a mouse path, when I release the mouse button, the points snap vertically to the line and the line disappears

#2 as I drag/click the mouse, as I pass above (or below) a point, the drag point snaps to that point in the vertical direction. Once I let off the mouse button, the behavior stops.

Before I start this action, I will click on a custom button in the Chart toolbar, similar to how we use the Zoom Rectangle feature. . I will click on a different button to take it out of this mode.

I am looking for thoughts on how I might add this feature. I could not find an existing feature that would suite my needs.

Keep in mind we own the source code for 3.5, so if there is some internal code changes required, we can do that.

Re: Dragpoints and mass editting

Posted: Thu Sep 22, 2011 1:41 pm
by narcis
Hi Mike,

There would be a number of ways to do that but it all ends up in calculating screen positions, convert them to axes coordinates and assign them to the series, for example:

Code: Select all

    public Form1()
    {
      InitializeComponent();
      InitializeChart();
    }

    private void InitializeChart()
    {
      tChart1.Aspect.View3D = false;
      tChart1.Series.Add(new Steema.TeeChart.Styles.Points()).FillSampleValues(5);

      tChart1.MouseMove += new MouseEventHandler(tChart1_MouseMove);
    }

    void tChart1_MouseMove(object sender, MouseEventArgs e)
    {
      for (int i = 0; i < tChart1[0].Count; i++)
      {
        if (tChart1[0].CalcXPos(i) == e.X)
        {
          tChart1[0].YValues[i] = tChart1.Axes.Left.CalcPosPoint(e.Y);
          tChart1.Invalidate();
          break;
        }
      }
    }