Page 1 of 1

Marking of data using Color Band

Posted: Fri Sep 04, 2009 5:59 am
by 9346725
Hi TeeChart Team,
Is it possible to select a range of data and show to the user with different color coding using mouse move over the bottom axis legend area?

What actually I want is –
I have 10 fastlineseries in one control in 10 different custom axes.
My X-axis is common for all the 10 fastlineseries. It is of type Date/Time.
Now i just want to move my mouse with left button down in the bottom axis label area and once the mouse is released the area between mouse down point and the mouse up point should get selected with different color coding. Please see the image below -
[img]
Marking.PNG
Marking.PNG (192.83 KiB) Viewed 8125 times
[/img]

I have tried using the ColorBand tool to do it. But the problem with the colorband tool is - i have to mention the axis for putting it. But as you can see in the image - the middle selection it is not associated with any axis. It is just like drawing a box inside the control with the start and end position provided by the mouse move operation in time axis rectangle.
Please let me know if i am able to make my things clear.:)

Re: Marking of data using Color Band

Posted: Fri Sep 04, 2009 6:13 am
by 9346725
One more very critical point -
What ever i am doing in the control, i cant call refresh or invalidate for the whole control. Otherwise it will be a performance issue if i have a huge amount of data. Drawing any item in the chart should be done without refreshing the control.

Re: Marking of data using Color Band

Posted: Fri Sep 04, 2009 8:10 am
by narcis
Hi Nitin,

In that case I'd try using Rectangle or annotation tools without text for that. You'll have to specify left, top, width and height values for them which you can get from mouse events.

Re: Marking of data using Color Band

Posted: Fri Sep 11, 2009 1:02 pm
by 9346725
Hi,
I tried using rectangle tool to do it but once the tool is getting created, the control is getting refreshed.
I have huge data. So, refreshing the control is taking 5-8 seconds.
Dont know if i can use this tool on mouse move event or not.
Any idea?

Re: Marking of data using Color Band

Posted: Mon Sep 14, 2009 10:21 am
by narcis
Hi Nitin,

Yes, Rectangle tool supports mouse dragging and resizing. For preventing the whole chart to repaint and only painting a small region you can do as in this example:

Code: Select all

    private Annotation anno;

    private void InitializeChart()
    {
      timer1.Enabled = true;
      tChart1.Graphics3D.BufferStyle = BufferStyle.DoubleBuffer;
      //tChart1.AfterDraw += new PaintChartEventHandler(tChart1_AfterDraw);

      tChart1.Aspect.View3D = false;
      tChart1.Series.Add(typeof(Line));
      tChart1[0].FillSampleValues(10000);

      CursorTool cursor;
      tChart1.Tools.Add(cursor = new CursorTool());
      cursor.Style = CursorToolStyles.Vertical;
      cursor.FollowMouse = true;
      cursor.FastCursor = true; //try false
      cursor.Change += new CursorChangeEventHandler(cursor_Change);


      tChart1.Tools.Add(anno = new Annotation());
      anno.AutoSize = false;
      anno.Top = 10;
      anno.Left = 10;
      anno.Height = 20;
      anno.Width = 110;
      r1 = anno.Shape.ShapeBounds;
      tChart1.AutoRepaint = false;
    }

    void cursor_Change(object sender, CursorChangeEventArgs e)
    {
      anno.Text = e.XValue.ToString();
      tChart1.Invalidate(r1);
    }

    private Rectangle r1;