This project is read-only.

Percentage Zoom

Apr 2, 2010 at 1:40 AM


I need to add a slider (like in MS Office) to zoom in / out the viewport, i wanna bind (in two way) the value of my slider to a zoom percentage of chart, how i can do this?



Apr 2, 2010 at 5:56 PM

Below is how I sent my Visible bounds based on what I want to show.  So for you, do your zoom calculation to get your Region or Interest, and go from there.


        private void setVisibleBounds(double minX, double minY, double width, double height, bool addRestriction) {
            if ((width > 0) && (height > 0)) {
                DataRect v = plotter.Visible;
                v.XMin = minX;
                v.Width = width;
                v.YMin = minY;
                v.Height = height;

                plotter.Visible = v;

                if (addRestriction) {
                    BoundViewport bvp = new BoundViewport();
                    bvp.MinXValue = minX;
                    bvp.MaxXValue = minX + width;
                    bvp.MinYValue = minY;
                    bvp.MaxYValue = minY + height;





Apr 3, 2010 at 3:06 AM

Hi Tiago!


I've uploaded a sample showing the feature you want:

Best regards,


Sep 10, 2010 at 1:47 PM
Edited Sep 10, 2010 at 2:14 PM

Hi !

I wish to read somewhere the zoom value currently used by the plotter. Does anyone knows which property to read? Thanks!

The compressed folder give me "Error in compressed file" when I try to open it...

Sep 10, 2010 at 2:35 PM

Here is the source code from the Zoom slider example (I can't remember if I changed anything but it is working and will show you what you need to know)

As you can see it is just a matter of setting the ChartPlotter's Visible property to an appropriate DataRect


<Window x:Class="ZoomSliderSample.Window1"
    Title="Zoom Slider Sample">
        <d3:ChartPlotter Name="plotter">
using System.Windows;
using System.Windows.Controls;
using Microsoft.Research.DynamicDataDisplay;

namespace ZoomSliderSample
	/// <summary>
	/// Interaction logic for Window1.xaml
	/// </summary>
	public partial class Window1 : Window
		private Slider zoomSlider = new Slider
			Margin = new Thickness(20),
			Orientation = Orientation.Vertical,
			Height = 200,
			Minimum = 1,
			Maximum = 3

		public Window1()

			zoomSlider.ValueChanged += zoomSlider_ValueChanged;

		void zoomSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
			DataRect visible = new DataRect(0, 0, 1, 1).ZoomInToCenter(e.NewValue);
			plotter.Visible = visible;

Feb 3, 2011 at 9:05 PM

I can not find ZoomInToCenter() function. Is there an alternative way?

Feb 4, 2011 at 10:34 PM
ZoomInToCenter() is in the source, in DataRectExtensions.cs.