|
7 | 7 | using DevExpress.Utils; |
8 | 8 | using DevExpress.XtraBars; |
9 | 9 | using DevExpress.XtraCharts; |
10 | | -using DevExpress.XtraCharts.Native; |
11 | 10 | using DevExpress.XtraEditors; |
12 | 11 | using OSPSuite.Assets; |
13 | 12 | using OSPSuite.Core.Chart; |
@@ -47,7 +46,7 @@ public ChartDisplayView(IImageListRetriever imageListRetriever) |
47 | 46 | _doubleFormatter = new DoubleFormatter(); |
48 | 47 | _hintControl = new LabelControl(); |
49 | 48 | _toolTipController = new ToolTipController(); |
50 | | - PopupBarManager = new BarManager {Form = this, Images = imageListRetriever.AllImagesForContextMenu}; |
| 49 | + PopupBarManager = new BarManager { Form = this, Images = imageListRetriever.AllImagesForContextMenu }; |
51 | 50 | SetDockStyle(Presentation.Views.Dock.Fill); |
52 | 51 | } |
53 | 52 |
|
@@ -164,7 +163,6 @@ protected override void OnDragDrop(DragEventArgs dragDropEventArgs) |
164 | 163 | var seriesBeingMoved = dragDropEventArgs.Data.GetData(typeof(Series)).DowncastTo<Series>(); |
165 | 164 | if (seriesBeingMoved != null) |
166 | 165 | dropLegendHere(hitInfo.Series.DowncastTo<Series>(), seriesBeingMoved); |
167 | | - |
168 | 166 | } |
169 | 167 |
|
170 | 168 | protected override void OnDragOver(DragEventArgs dragOverEventArgs) |
@@ -275,9 +273,46 @@ private bool isInXAxis(ChartHitInfo hitInfo) |
275 | 273 |
|
276 | 274 | private void zoomAction(Control control, Rectangle rectangle) |
277 | 275 | { |
278 | | - var cc = control as IChartContainer; |
279 | | - if (cc != null && cc.Chart != null && !rectangle.IsEmpty) |
280 | | - cc.Chart.PerformZoomIn(rectangle); |
| 276 | + if (rectangle.IsEmpty || xyDiagram == null) |
| 277 | + return; |
| 278 | + |
| 279 | + var topLeftCoord = xyDiagram.PointToDiagram(rectangle.Location); |
| 280 | + var bottomRightCoord = xyDiagram.PointToDiagram(new Point(rectangle.Right, rectangle.Bottom)); |
| 281 | + |
| 282 | + if (topLeftCoord == null || bottomRightCoord == null) |
| 283 | + return; |
| 284 | + |
| 285 | + xyDiagram.AxisX.VisualRange.Auto = false; |
| 286 | + xyDiagram.AxisX.VisualRange.SetMinMaxValues( |
| 287 | + Math.Min(topLeftCoord.NumericalArgument, bottomRightCoord.NumericalArgument), |
| 288 | + Math.Max(topLeftCoord.NumericalArgument, bottomRightCoord.NumericalArgument)); |
| 289 | + |
| 290 | + setAxisVisualRange(AxisTypes.Y, topLeftCoord?.NumericalValue, bottomRightCoord?.NumericalValue); |
| 291 | + zoomAxis(AxisTypes.Y2, rectangle); |
| 292 | + zoomAxis(AxisTypes.Y3, rectangle); |
| 293 | + } |
| 294 | + |
| 295 | + private void zoomAxis(AxisTypes axisType, Rectangle rectangle) |
| 296 | + { |
| 297 | + var axis = getAxisFromType(axisType); |
| 298 | + if (axis == null) return; |
| 299 | + |
| 300 | + var topLeftCoord = xyDiagram.PointToDiagram(rectangle.Location).GetAxisValue(axis); |
| 301 | + var bottomRightCoord = xyDiagram.PointToDiagram(new Point(rectangle.Right, rectangle.Bottom)).GetAxisValue(axis); |
| 302 | + |
| 303 | + if (topLeftCoord == null || bottomRightCoord == null) |
| 304 | + return; |
| 305 | + |
| 306 | + setAxisVisualRange(axisType, topLeftCoord.NumericalValue, bottomRightCoord.NumericalValue); |
| 307 | + } |
| 308 | + |
| 309 | + private void setAxisVisualRange(AxisTypes axisType, double? minValue, double? maxValue) |
| 310 | + { |
| 311 | + var axis = getAxisFromType(axisType); |
| 312 | + if (axis == null || minValue == null || maxValue == null) return; |
| 313 | + |
| 314 | + axis.VisualRange.Auto = false; |
| 315 | + axis.VisualRange.SetMinMaxValues(Math.Min(minValue.Value, maxValue.Value), Math.Max(minValue.Value, maxValue.Value)); |
281 | 316 | } |
282 | 317 |
|
283 | 318 | private Color diagramBackColor |
|
0 commit comments