overlay an image in sync with the plotter

Aug 10, 2009 at 9:15 PM

is it possible to overlay an image and keep it in sync with the plotter axis variations.

Editor
Aug 11, 2009 at 2:48 AM
Edited Aug 11, 2009 at 2:50 AM

Hi,

if you need to have simply a static background image behind the plotter - that in C# execute the following code:

            ImageSource img = new BitmapImage(new Uri(@"C:\Users\Mikhail\Pictures\Wallpapers\img20.jpg"));

            Image image = new Image { Source = img, Stretch = Stretch.Fill, StretchDirection = StretchDirection.Both };

            Panel.SetZIndex(image, -10);

            plotter.CentralGrid.Children.Insert(0, image);

 

And you'll get smth like this http://www.youtube.com/user/Thecentury1986#play/all/uploads-all/1/r0rrhRTLzQg

 

And if you need your image move inside the viewport according to all Viewport.Visible changes, you should write the following in XAML:
<d3:ChartPlotter Name="plotter">
<d3:ViewportHostPanel>
<Image Source="C:\Users\Mikhail\Pictures\Wallpapers\img20.jpg" Stretch="Fill" StretchDirection="Both" d3:ViewportPanel.ViewportBounds="0.1,0.1,0.3,0.3"/>
</d3:ViewportHostPanel>
</d3:ChartPlotter>
		<d3:ChartPlotter Name="plotter">
			<d3:ViewportHostPanel>
				<Image Source="C:\Users\Mikhail\Pictures\Wallpapers\img20.jpg" Stretch="Fill" StretchDirection="Both" d3:ViewportPanel.ViewportBounds="0.1,0.1,0.3,0.3"/>
			</d3:ViewportHostPanel>
		</d3:ChartPlotter>

and you'll get the following:

http://www.youtube.com/user/Thecentury1986#play/all/uploads-all/0/8bwS0nWehb8

 

 

To get the described behaviour, you should use the latest version of DynamicDataDisplay from 'Source code' page, and make one correction in class ViewportHostPanel: in MeasureOverride

 insert the following body:

 

            AvailableSize = availableSize;

 

            if (plotter == null)

                return availableSize;

 

            var transform = plotter.Viewport.Transform;

 

            foreach (FrameworkElement child in InternalChildren)

            {

                if (child != null)

                {

                    Size elementSize = GetElementSize(child, availableSize, transform);

                    child.Measure(elementSize);

                }

            }

 

            if (availableSize.Width.IsInfinite())

                availableSize.Width = 0;

            if (availableSize.Height.IsInfinite())

                availableSize.Height = 0;

            return availableSize;

 

 

Best regards,

Mikhail.

Aug 27, 2009 at 11:36 PM

Thank You. Works like a charm.. Very impressed.

I also have to add some user editable shapes to select regions on the bitmap.