zoom and scroll the panel image

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Sharkann
Newbie
Newbie
Posts: 17
Joined: Fri Apr 22, 2022 12:00 am

zoom and scroll the panel image

Post by Sharkann » Wed Jun 28, 2023 11:30 am

Hi,

I am currently designing a digitizer, which is based on the panel image.
I then use the onbackground click event to calculate the points that the user wants to scan, by playing with the scales and the dimensions of the picture.

My problem is that when I zoom or scroll the graph, the panel image won't follow the zoom/scroll and remains still.

Do you know how to do ?

Thanks
Sharkann

Marc
Site Admin
Site Admin
Posts: 1274
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Re: zoom and scroll the panel image

Post by Marc » Fri Jun 30, 2023 8:23 am

Hello,

If you are associating an image with the start panel axes (before zoom) then I assume that you have already checked that the default coordination between image and x,y chart coordinates is correct. For that to coordinate correctly after zoom I suggest that you set it up in the following way:

This example is somewhat simplified. It starts with a Chart that has a scale of 100 on the Y axis and 100 on the x axis. The principles can be generically applied to any axis scales.

These steps:
- load the image as an image draw in the BeforeDrawAxes event (for the image to appear below the grid). Don't load the image as a Panel or BackWall image. The image should have the same Pixel dimensions as the axes enclosed space to which it renders.
- Confirm the required start axes sizes; the min, max for each Axis. The image will locate to this start size and will have knowledge of this start size throughout any subsequent zooms or scrolls.

ie:
This example runs a simple straight line with 100 values across a chart. It loads a back image whose dimensions are the same as the chart rectangle (the rectangle enclosed by the axes).

Code: Select all

private void Form1_Load(object sender, EventArgs e)
{
    for (int i = 0; i < 100; i++)
        fastLine1.Add(i, i);

    tChart1.Axes.Left.SetMinMax(0, 100);
    tChart1.Axes.Bottom.SetMinMax(0, 100);
}

private void tChart1_BeforeDrawAxes(object sender, Steema.TeeChart.Drawing.Graphics3D g)
{
    Image myBackImage = Image.FromFile(@"D:\myBackImages\imyImage.png");

    Rectangle rect = new Rectangle(tChart1.Axes.Bottom.CalcPosValue(0), tChart1.Axes.Left.CalcPosValue(100),
        tChart1.Axes.Bottom.CalcPosValue(100) - tChart1.Axes.Bottom.CalcPosValue(0),
        tChart1.Axes.Left.CalcPosValue(0) - tChart1.Axes.Left.CalcPosValue(100));

    g.Draw(rect, myBackImage, false);
}
Note that the rectangle used to plot the image takes the original start values of the image as related to axes, even if those values are way off the chart after a zoom or scroll.

Regards,
Marc
Steema Support

Post Reply