Hi,
I am trying to zoom user selected portion of chart.
user can draw rectangle or square by dragging mouse mouse.
startPosition : Mouse Down
End Position : Mouse Up or MouseMove
i draw rectangle from startPosition to End Position in FillSceneGraph event.
basically on MouseMove event i store EndPosition as current mouse location and call InvalidateLayers function on chart.
In FillSceneGraph event i draw rectangle from startPosition to EndPosition and add it to SceneGraph.
Every thing works fine except the delay in displaying rectangle.
is there any way to avoid the delay..or is FillSceneGraph is right place to add primitives on mousemove event.
as mousemove event is called for every few milliseconds ..
Thanks,
Kk
Sure, you can store the scrolling and scaling variables in some temporary location. Then, when you need to undo the zooming/scrolling set the axis scrollscale scroll and zoom to those stored variables.
Very Good article,after zooming,is there any way to undo my latest change..
No, the feature request page is still the same. I made an attempt to write a code sample. It's not exactly perfect, but hopefully will prove useful.
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Windows.Forms;using Infragistics.UltraChart.Core.Primitives;using Infragistics.UltraChart.Data;using Infragistics.UltraChart.Core.Layers;using Infragistics.UltraChart.Resources.Appearance;using Infragistics.UltraChart.Shared.Styles;using Infragistics.UltraChart.Core;using Infragistics.UltraChart.Resources;namespace WindowsFormsApplication1{public partial class Form1 : Form{ public Form1() { InitializeComponent(); }
Point startPoint, endPoint;bool mouseDown = false;bool valid = true;double scaleX, scrollX, scaleY, scrollY;bool updateChartScale = true;
private void ultraChart1_FillSceneGraph(object sender, Infragistics.UltraChart.Shared.Events.FillSceneGraphEventArgs e){ valid = true; if (e.Grid.Count == 0) return; IAdvanceAxis xAxis = (IAdvanceAxis)e.Grid["X"]; IAdvanceAxis yAxis = (IAdvanceAxis)e.Grid["Y"]; int width = Math.Abs(endPoint.X - startPoint.X); int height = Math.Abs(endPoint.Y - startPoint.Y); Box box = new Box(startPoint, width, height);
if (box.rect.Left < xAxis.MapMinimum || box.rect.Top < yAxis.MapMaximum || box.rect.Right > xAxis.MapMaximum || box.rect.Bottom > yAxis.MapMinimum) { valid = false; return; }
if (valid) { if (mouseDown) { e.SceneGraph.Add(box); }
else if (updateChartScale) { updateChartScale = false; double offsetX = (e.ChartCore.GridLayerBounds.Width / xAxis.Scale - e.ChartCore.GridLayerBounds.Width) * xAxis.Scroll; double offsetY = (e.ChartCore.GridLayerBounds.Height / yAxis.Scale - e.ChartCore.GridLayerBounds.Height) * yAxis.Scroll; scaleX = xAxis.Scale * box.rect.Width / e.ChartCore.GridLayerBounds.Width; scaleY = yAxis.Scale * box.rect.Height / e.ChartCore.GridLayerBounds.Height; scrollX = (box.rect.X - xAxis.MapMinimum + offsetX) / (e.ChartCore.GridLayerBounds.Width / xAxis.Scale - box.rect.Width); scrollY = (yAxis.MapMinimum - box.rect.Bottom + offsetY) / (e.ChartCore.GridLayerBounds.Height / yAxis.Scale - box.rect.Height); BeginInvoke(new MethodInvoker(SetChartAxes)); } }}
private void Form1_Load(object sender, EventArgs e){ ultraChart1.Data.DataSource = DemoTable.Table(); ultraChart1.Axis.X.ScrollScale.Visible = true; ultraChart1.Axis.Y.ScrollScale.Visible = true;}
private void ultraChart1_MouseDown(object sender, MouseEventArgs e){ startPoint = e.Location; mouseDown = true;}
private void ultraChart1_MouseUp(object sender, MouseEventArgs e){ mouseDown = false; updateChartScale = true; ultraChart1.InvalidateLayers();}
private void ultraChart1_MouseMove(object sender, MouseEventArgs e){ if (mouseDown) { endPoint = e.Location; ultraChart1.InvalidateLayers(); }}
private void SetChartAxes(){ ultraChart1.Axis.X.ScrollScale.Scale = scaleX; ultraChart1.Axis.Y.ScrollScale.Scale = scaleY; ultraChart1.Axis.X.ScrollScale.Scroll = scrollX; ultraChart1.Axis.Y.ScrollScale.Scroll = scrollY;}}}
Hi Max, I did that and I also have purchased infragistics license with standard support. Do I need to submit this request on a different link since I have the standard support? Thanks.
Unfortunately, no. I haven't seen anyone successfully implement this, sorry.You can submit a feature request here, though:http://devcenter.infragistics.com/Protected/RequestFeature.aspx