Page 1 of 2

Zooming of Annotation tool

Posted: Tue Oct 27, 2009 11:01 pm
by 15654246
Hi,
I have used the Annotation tool for highlighting a section of data in my chart control.
I have 10 Fastline series data. User can move the mouse at the bottom of the control to select or highlight a section of data.
I have to provide the top, left, height and width to the Annotation tool for highlighting the data.
See the image below.
DataSelectionUsingMouseMove.JPG
DataSelectionUsingMouseMove.JPG (81.52 KiB) Viewed 20332 times
Now, when i am zooming the trend control - the Annotation tool is not getting resized. In the below image, i have zoomed the data but the Annotation tool is still of same size.
AnnotationToolAfterZoom.JPG
AnnotationToolAfterZoom.JPG (59.12 KiB) Viewed 20329 times
In the RectangleTool this problem is not there. It is only specific to Annotation tool.
Can you suggest me a way to solve this problem.

Regards,
Avijit

Re: Zooming of Annotation tool

Posted: Wed Oct 28, 2009 3:10 pm
by yeray
Hi Avijit,

First of all, I'd like to suggest you to use a ColorBandTool that, if I understand you well, was designed for doing what are you exactly trying to achieve.
And with annotations, the problem is that you have to reposition them each time the chart is resized or repainted using positions relative to the chart. For example, for the Zoom you could use Zoomed event:

Code: Select all

tChart1.Zoomed += new EventHandler(tChart1_Zoomed);
And do something like this:

Code: Select all

        void tChart1_Zoomed(object sender, EventArgs e)
        {
            tChart1.Draw();
            RecalcAnnotation();
        }
        private void RecalcAnnotation()
        {
            annot1.Left = tChart1.Axes.Bottom.CalcPosValue(5);
            annot1.Width = tChart1.Axes.Bottom.CalcPosValue(10) - annot1.Left;
            annot1.Top = tChart1.Axes.Left.IStartPos;
            annot1.Height = tChart1.Axes.Left.IEndPos - annot1.Top;
        }

Re: Zooming of Annotation tool

Posted: Wed Oct 28, 2009 4:57 pm
by 15654246
Hi Yeray,

Please let me know if i can specify the left, width, top and height of the ColorBand tool.
Please have a look at the screenshot below from our own product that has been developed using MFC-
Marking.JPG
Marking.JPG (57.58 KiB) Viewed 20285 times
Now let me know if it is possible to use the ColorBand tool to do these kind of highlightings in TeeChart control.
I think ColorBand tool is always associates with a axis. It is really a disadvantage of the usage of the tool.
For the markings shown in the screen shot i have to specify the left, width, top and height for the tool.

Please let me know if you have any alternative solutions for this problem.
Also please allow the users to specify the left, width,top and height of the ColorBand tool. It is really required.

Regards,
Avijit

Re: Zooming of Annotation tool

Posted: Wed Oct 28, 2009 10:17 pm
by 15654246
Hi,
Is it possible to specify the left, top, width and height of a Rectangle tool or Annotation tool in float?
Presently it is only accepting integers.
How can i specify the points as float?

Regards,
Avijit

Re: Zooming of Annotation tool

Posted: Fri Oct 30, 2009 4:48 pm
by yeray
Hi Avijit,

Yes, as you've noticed, ColorBandTool was designed to be assigned to an axis so that it could highlight the whole width or the whole height (depending of if the axis is horizontal or vertical) from a value to another value.
As you need a rectangle, you need the rectangle tool or the annotation tool and you have to reposition it relatively to the chart axes. For example:

Code: Select all

        Steema.TeeChart.Styles.Line line1;
        Steema.TeeChart.Tools.RectangleTool rectangle1;

        private void InitializeChart()
        {
            chartController1.Chart = tChart1;
            tChart1.Aspect.View3D = false;

            line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);

            Random rnd = new Random();
            line1.Add(1000);
            for (int i = 1; i < 25; i++)
            {
                line1.Add(line1.YValues.Value[i - 1] + rnd.Next(10));
            }

            rectangle1 = new Steema.TeeChart.Tools.RectangleTool(tChart1.Chart);
            tChart1.AfterDraw += new Steema.TeeChart.PaintChartEventHandler(tChart1_AfterDraw);

            tChart1.Draw();
        }

        void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
        {
            rectangle1.Left = tChart1.Axes.Bottom.CalcPosValue(10);
            rectangle1.Width = tChart1.Axes.Bottom.CalcPosValue(15) - rectangle1.Left;
            rectangle1.Top = tChart1.Axes.Left.CalcPosValue(1070);
            rectangle1.Height = tChart1.Axes.Left.CalcPosValue(1050) - rectangle1.Top;
        }

Re: Zooming of Annotation tool

Posted: Mon Jul 26, 2010 1:07 pm
by 15654246
Hello,
I just saw that the ColorBand tool does not occupy the Axis offset area. Is that intended?
For one fastline series i set the offset to 25%.
I have one ColorBand tool associated with the Custom Vertical axis of the fastline series.
I am seeing the ColorBand tool occupying only 50% of the Custom axis height.
Please let me know how to solve this issue.

Regards,
Avijit

Re: Zooming of Annotation tool

Posted: Mon Jul 26, 2010 4:23 pm
by yeray
Hi Avijit,

Could you please arrange a simple example project we can run as-is to reproduce the problem here?
I'm not sure to understand what exact offset you have set to 25%.

Re: Zooming of Annotation tool

Posted: Tue Jul 27, 2010 9:25 am
by 15654246
Hello Yerey,
Please see the attached project. I have created one ColorBand tool and associated with a vertical custom axis and added offset to the Axis. See the ColorBand is not starting from the begining of the Axis nor it is ending at the end of the axis.

-Avijit

Re: Zooming of Annotation tool

Posted: Tue Jul 27, 2010 12:38 pm
by 15654246
Hi,
One more thing i want to know.
Is it possible to calculate the Start and End position of the ColorBand tool without calling the TChart.Draw() function?
This might be a performance issue in our case.

-Avijit

Re: Zooming of Annotation tool

Posted: Wed Jul 28, 2010 11:17 am
by 10050769
Hello Avijit,

I have checked your application, and I seem that ColorBand doesn't paint correctly, because you initialize Minimum and Maximum Offsets of custom axis to 25% and ColorBand behaves according to the axis where is assigned. So if you want that ColorBand paint full, you will need change Offset of custom axis by default. You could modify your code so:

Code: Select all

 public void DrawTrend()
    {
      FastLine _FastLIne = new FastLine();
      _FastLIne.FillSampleValues(100);
      
      Axis _Axis = new Axis();
      ChartControl.Axes.Custom.Add(_Axis);
      _Axis.StartEndPositionUnits = PositionUnits.Percent;
      _Axis.StartPosition = 0;
      _Axis.EndPosition = 100;
      //_Axis.MaximumOffset = 25;
      //_Axis.MinimumOffset = 25;
      _FastLIne.CustomVertAxis = _Axis;
      ChartControl.Series.Add(_FastLIne);
      _Axis.Automatic = true;
      _Axis.SetMinMax(_FastLIne.MinYValue(), _FastLIne.MaxYValue());
...
Hi,
One more thing i want to know.
Is it possible to calculate the Start and End position of the ColorBand tool without calling the TChart.Draw() function?
This might be a performance issue in our case.
I check your code and I removed next line in DrawTrend(),because it is not necessary, for calculate start and end position of ColorBandTool :

Code: Select all

 ChartControl.Draw();//is not necessary
So, I think if you remove this line, your application will work fine.

I hope will helps.

Thanks,

Re: Zooming of Annotation tool

Posted: Tue Aug 03, 2010 11:26 am
by 15654246
Hello Sandra,
I removed the line. But now the colorbands are not getting drawn.
While checking the Axis sizes, i came to know that the Custom Axis IStartPos, IEndPos and IAxisSize is ZERO before calling the ChartControl.Draw function.
Please, let me know how to solve this.

Regards,
Avijit

Re: Zooming of Annotation tool

Posted: Tue Aug 03, 2010 12:00 pm
by 10050769
Hello Avijit,


I have tested again it and I confirm that here, previous code works fine with last version of TeeChart .Net. Can you please, tell us what version of TeeChart.Net you are using? Because, we can try to find a solution for it.


Thanks,

Re: Zooming of Annotation tool

Posted: Tue Aug 03, 2010 12:09 pm
by 15654246
Hello,
i am using
Version - 4.0.0.30764

Regards,
Avijit

Re: Zooming of Annotation tool

Posted: Wed Aug 04, 2010 8:27 am
by 10050769
Hello Avijit,

I recommend you, update your version 4 of TeeChart .Net for last version 4 release that could download in this link. When you've updated version, you could check again, if my previous code works as you want.

Thanks,

Re: Zooming of Annotation tool

Posted: Thu Aug 05, 2010 7:23 am
by 15654246
Hello Sandra,
I have installed the latest release (4th August, 2010)
I commented out the Offset part.
Also commented out the ChartControl.Draw().
As i told you, ColorBand tool is not at getting drawn at all.
For the Custom Axis - IStartPos, IEndPos and IAxisSize is ZERO now.
Please run the attached project as is and see for yourself.

regards,
Avijit